[A83] Re: returning to OS in call routines


[Prev][Next][Index][Thread]

[A83] Re: returning to OS in call routines



You are right, to a certain extent. The exception being when the return
path is not predictable. Usually this is something that happens in more
complicated situations, but a lot of times they can be avoided.. For
example only though, take a look at this code chunk:

main:
	(input)
	call dosomething
	ret

dosomething:
	(if cond then) call dosomething
	(dosomething)
	ret

This is just a simple recursive case.. depending on the conditional, we
could go several times in dosomething, and then decide via cond that it
has went deep enough and now needs to work its way back out.. even
though the ultimate point of return is predictable, we can't simply jp
out of the function.. This is non-tail-end recursion. Anyways, there are
many other cases in which the return path is not able to be predicted
readily, and in those cases, we must rely on call/ret to navigate it.

Often when you make a chunks of code that is used in several locations
in the program's execution path, it can't be "unrolled" into jp/jrs.

The solution of saving the initial stack is probably frowned upon by
many because it breaks the perfect academic model, but it usually ends
up requiring less code in the end.

--
Scott Dial
scott@scottdial.com
AIM GeekMug : ICQ# 3608935

-----Original Message-----
From: assembly-83-bounce@lists.ticalc.org
[mailto:assembly-83-bounce@lists.ticalc.org] On Behalf Of Tim Wiser
Sent: Thursday, August 07, 2003 9:09 PM
To: assembly-83@lists.ticalc.org
Subject: [A83] Re: returning to OS in call routines

Ok, I'm new to this list, but I have an idea.
Instead of 'call'ing, you could 'jp' or 'jr' to the function which would
'ret' back to the OS rather than the calling function. Then 'jp' back to
the calling function if you don't have to return.  I know this isn't
practical, but it's the only way I know how.

Hope this helps,
t.wiser

------------------------------

From: "Tobias" <supermobbe@yahoo.de>
Subject: [A83] returning to OS in call routines
Date: Thu, 7 Aug 2003 22:49:36 +0200


i  write often call routines and also call routines in call routines. In
one of these routines i want to check if the "clear-button" is pressed
and if so then program should exit. And for this you usually use "ret"
but this would exit the routine?! So how to return to OS from a routine?
Impossible? Thanks


------------------------------




Follow-Ups: References: