Re: A86: stop
[Prev][Next][Index][Thread]
Re: A86: stop
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!
Follow-Ups:
References: