Subject:
|
Re: signals / legOS internals
|
Newsgroups:
|
lugnet.robotics.rcx.legos
|
Date:
|
Wed, 23 Jun 1999 01:33:08 GMT
|
Viewed:
|
1100 times
|
| |
| |
Kekoa Proudfoot wrote:
>
> Lou Sortman <theball@bigfoot.com> wrote:
> > I was rolling along, planning this out, then it occurred to me that
> > local (to the function) variables are on the stack above the stack
> > pointer. That means that pushing anything on the stack asynchronously
> > is going to toast those variables. It makes me wonder why that doesn't
> > happen whenever OC1A happens.
>
> The stack pointer must always always always point at the bottom of the
> stack data area, i.e. to the last valid data item on the stack. As a
> consequence, push val (or mov.w val,@-r7) never overwrites data.
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 assume that something about that is simply not how it is done with
this compiler. Obviously, I want to make sure that what I do doesn't
suddenly break when somebody has a function with 8 local shorts.
Basically, if the "always always always" rule holds up, I think I'm in
good shape. I'm just trying to make sure there is no case in which it
might be false.
> When an interrupt occurs, the first thing that happens is that two data
> values are pushed onto the stack. See pp. 68-71 and Fig 4-5 of the
> hardware manual for more details.
One of those being the program counter, and, I guess, the other being
the status register. Such operation is typical.
I guess I'm going to have to print that thing out.
|
|
Message has 2 Replies: | | 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)
| | | Re: signals / legOS internals
|
| (...) Since it sounds like it might matter to you, I should point out that the interrupt situation on the RCX is a bit more complicated than the H8 manual makes it out to be. Interrupt vectors are in ROM, but the ROM does a dispatch to interrupt (...) (25 years ago, 23-Jun-99, to lugnet.robotics.rcx.legos)
|
Message is in Reply To:
| | Re: signals / legOS internals
|
| (...) The stack pointer must always always always point at the bottom of the stack data area, i.e. to the last valid data item on the stack. As a consequence, push val (or mov.w val,@-r7) never overwrites data. When an interrupt occurs, the first (...) (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
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|