Re: A86: A Stack Question
[Prev][Next][Index][Thread]
Re: A86: A Stack Question
rabidcow@juno.com wrote:
> On Thu, 2 Jul 1998 16:35:19 -0500 sampablo@juno.com (Samuel P Camp)
> writes:
> >
> >Hi, Sam here with a stack question.
> >Is it possible to make the stack, which is First In Last Out, into
> >Last In Last Out? Or in other words can you load the SP with a value
> >,and
> >then perform inc/dec on it?
>
> yes, you can do these to sp:
> inc sp
> dec sp
> ld sp,(nn)
> ld sp,hl
> ld sp,ix
> ld sp,iy
> ld sp,nn
>
> you can also add/sub it from hl.
>
> -josh
>
You want to preserve the stack location if you change it, though. Here's
how I would do it:
ld ix,0
add ix,sp
;stack code, possible push/pop of ix
ld sp,ix
...
or else it will crash when you try to return
References: