To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 262
261  |  263
Subject: 
Re: signals / legOS internals
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Wed, 23 Jun 1999 03:28:54 GMT
Viewed: 
1008 times
  
Lou Sortman  <theball@bigfoot.com> wrote:
Lou Sortman wrote:

When you define a bunch of local variables (more than fit in available
registers), where are they?  Unless you happen to know the answer, I may
have to do some more experimenting.

Admittedly, it has been awhile, but the last time I was heavy into
assembler, it was under Unix, where in one direction (counting from SP),
you had any passed arguments and return addresses for previously called
(and not yet returned) functions.  In the other direction, that was
where you put your local variables.  So that you could call further
functions, the stub would adjust the SP at the beginning of the function
and restore it before returning.

I may have answered my own question here.  Since the SP is adjusted
before anything is actually done with the local variables, the rule
about it always pointing to the last valid datum is not violated even if
local variables are placed after the return address.

Yes, that is correct.  As for passing parameters to a function, they are
simply pushed onto the stack before the function call.  Therefore, the H8
stack usually looks something like e.g. this:

      function param     sp+10
      function param     sp+8
      return address     sp+6
      local variable     sp+4
      local variable     sp+2
sp -> local variable     sp+0

GCC complicates the picture somewhat.  It maintains r6 as a frame pointer,
and references local variables and function parameters relative to that:

      function param     fp+6
      function param     fp+4
      return address     fp+2
fp -> prev frame ptr     fp+0
      local variable     fp-2
      local variable     fp-4
sp -> local variable     fp-6

That actually isn't quite all there is to say about how GCC behaves, but
the details are mostly unimportant.

-Kekoa



Message is in Reply To:
  Re: signals / legOS internals
 
(...) I may have answered my own question here. Since the SP is adjusted before anything is actually done with the local variables, the rule about it always pointing to the last valid datum is not violated even if local variables are placed after (...) (25 years ago, 23-Jun-99, to lugnet.robotics.rcx.legos)

32 Messages in This Thread:









Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR