Re: A86: stop
[Prev][Next][Index][Thread]
Re: A86: stop
If you're wanting to return to a few calls back, then that would be about the
only thing to do (other than remembering how many pushes and calls you've done,
and doing that many pops), but if you just want to flat out exit the program,
use:
Jforcecmdnochar equ $409C
jp Jforcecmdnochar
Timothy Dixon wrote:
> Scalp wrote:
> >
> > Sorry , but I still have questions...
> > Is there a routine like "Stop" in basic that stop the program. Because with
> > "ret", the program goes to the last label... and that sucks.
> >
>
> Well, ret simply transfers control to the most recent call, so it
> figures that's what you'd see. Remember that we're programming at the
> machine level here, so some things will be really simple. We lack
> control structures like for, while, and so on, though of course we can
> write code to do this on our own. Ret (or any other machine-level
> instruction) doesn't have any way of knowing which call was to your
> program.
>
> Having said that, it's possible to trick ret into going anywhere you
> want. Call pushes the next address onto the stack. Ret simply pops the
> top 16 bits off the stack into IP, effectively transferring control back
> where it's supposed to be. Theoretically, I imagine you could store the
> stack pointer when you start your program, then pop everything off the
> stack to that point before executing your ret. (the easy way would be
> to store sp in some handy RAM location, then load it back into sp).
> This makes for code which isn't very clean and will be hard to maintain
> and debug, but since I don't imagine you're writing Linux for the TI-86,
> you can probably get away with it.
>
> Good luck!
--
Stephen Hicks
mailto:shicks@mindspring.com
UIN:5453914
AIM:Kupopo1
References: