Re: A83: Sub-routines
[Prev][Next][Index][Thread]
Re: A83: Sub-routines
John Kugelman wrote:
> Bad idea. By doing that, you've lost everything before that on the
> stack (memory leak), and that also assumes that whatever code will be
> returned to didn't have anything on the stack that it needs (for
> example, preserved registers).
You are so right, I wasn't thinking...
> A better idea, IMHO, would be to save the value of the stack pointer and
> set it back when you want to return (...if this is possible). Just
> realize that no matter how you exit from a sub-routine, since this is in
> assembly and the caller could have been doing anything, you are possibly
> leaving the machine in an unsafe state.
yes you can modify the stackpointer as other 16bit registers. so this is
probably the best way..
//Olle
References: