Re: A92: Stack and return values
[Prev][Next][Index][Thread]
Re: A92: Stack and return values
Niklas Brunlid wrote:
> Aaron Hill wrote:
> >
> > Hello all,
> >
> > I want to use the stack to return a value. Because JSR stores the PC on the
> > SP before jumping and RTS needs this value intact, I can't just push the
> > return value on the stack. Does anyone know how I can do a return value
> > without using the data registers?
>
> Easy - just pop the RTS value to a temporary register or variable, push
> your return values, and the push the RTS value again.
What would happen if you put it on the stack after the RTS value, but didn't
push it there. Just put it there. The RTS value would be popped from the stack,
and an instruction could be saved. By the way how big is the RTS value?
Follow-Ups:
References: