Post Reply 
User-defined functions in Free42
01-13-2021, 05:19 PM
Post: #21
RE: User-defined functions in Free42
I have some stack save/restore routines on my 42S that might offer some inspiration on how to design this.

There's just one save routine:

SS - Save stack (saves the entire stack, including L)

Then there are a few different restore routines that restore the stack in various ways, called just before the program returns. The names start with R, followed by a list of what to restore to each stack register - X, Y, Z, T, L, in that order. An underscore signifies "leave it alone", i.e. that register contains an output of the program that's calling the save/restore routines.

R_YZTX - Leave X alone, restore Y, Z, T to their original positions, restore previous X into L. Similar to one-input, one-output functions like LN, or some two-input, one-output functions like %.

R_ZTTX - Leave X alone, restore Z to Y, T to Z and T, and X to L. Similar to two-input, one-output functions like +.

R_TTTX - Leave X alone, restore T into Y, Z, and T, and restore X to L. Three-input, one-output function, or a four-input, one-output function. (Are there any examples of these?)

A few other examples that I could potentially implement if I needed them:

RYZTTX - A one-input, no-output function that drops the stack, and saves the previous X in L.

R_XYZL - A no-input, one-output function, like RCL, DATE, etc.

R__ZTL - A no-input, two-output function that overwrites X and Y, such as MEAN.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: User-defined functions in Free42 - Dave Britten - 01-13-2021 05:19 PM



User(s) browsing this thread: 1 Guest(s)