A83: Subroutines
[Prev][Next][Index][Thread]
A83: Subroutines
Hey guys, I was doing some thinking about the stack and I came up with
something. Assumming you haven't loaded up the stack with data, could
you pop out of a subroutine. This program waits for a key and then
quits. It looks like a waste of space, but if your program is like the
one I'm making, it's a space saver. This works because all running
programs is is calling them as subroutines from BASIC or whatever shell.
When the program is called, the address to go back to when the program is
done is pushed to the stack, and retrieved by ret. Basically call is
just this
push pc
jp Some_Label
and ret is
pop pc
So if you pop the return address from the call inside the program, it
skips over that call and and returns directly to the shell or OS's
address
Hope someone has a use for this info
Alan
BTW: Here's my example prog (Maybe you wanna use it James)
Getkey:
call _getkey
cp kEnter
call z,Quit
jp Getkey
Quit:
pop af
ret
_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]