??? 08/07/05 21:24 Read: times |
#98966 - And another thought Responding to: ???'s previous message |
Jan Waclawek said:
Ian, note , what is that "whatever" pushed onto the stack last: it is the content of the stack before the first push - i.e. the return address - recovered by the xch a,@r0 instructions (r0 has been filled by sp and decremented down to the position of return address).
It is similar with the other, restore context, routine - first the return address gets popped out into dptr, but later it gets stored back into stack so after all popsare done it is just at the top of the stack. Btw, this is the key to answer to Oleg's puzzle. Also, I find it difficult to see why you would need to do this. The dangerous stack manipulation is only necessary in order to be able to call the function as a subroutine. All this could be avoided by using a macro instead. The downside of a macro is it uses more code space. And there is my problem. I cannot think of a code size constrained applicatiion that would need to save such a large context and do it so many times it needed a subroutine to fit it into the available code memory. And then there is the question of what happens if an interrupt occurs during one of these routines. Personaly I think this is a solution that should be avoided if at all possible. Ian |