Re: A86: Re: calling and returning
[Prev][Next][Index][Thread]
Re: A86: Re: calling and returning
If you want to save the sp, there is a much shorter/easier way to do it:
;at the beginning of the program
ld (StackSave),sp
;and later in the code
ld sp,0
StackSave = $-2
ret
In a message dated 12/5/99 20:39:23 Eastern Standard Time, david@acz.org
writes:
> Actually, there's another way, and that is to store the stack location when
> the program starts:
>
> StackSave = ... ; somewhere free in ram, like _textShadow or something
>
> ld hl,0
> add hl,sp ; HL = SP
> ld (StackSave),hl ; ah, I miss 16 bit loads...
>
> ...
>
> ReturnToOSNoMatterWhereWeAre:
> ld hl,(StackSave) ; get the stack pointer back
> ld sp,hl ; restore the stack pointer
> ret ; back to the OS!!!
----
Jonah Cohen
<ComAsYuAre@aol.com>
http://linux.hypnotic.org/~jonah/