Userdefined functions in Free42

01132021, 05:19 PM
Post: #21




RE: Userdefined 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 oneinput, oneoutput functions like LN, or some twoinput, oneoutput functions like %. R_ZTTX  Leave X alone, restore Z to Y, T to Z and T, and X to L. Similar to twoinput, oneoutput functions like +. R_TTTX  Leave X alone, restore T into Y, Z, and T, and restore X to L. Threeinput, oneoutput function, or a fourinput, oneoutput function. (Are there any examples of these?) A few other examples that I could potentially implement if I needed them: RYZTTX  A oneinput, nooutput function that drops the stack, and saves the previous X in L. R_XYZL  A noinput, oneoutput function, like RCL, DATE, etc. R__ZTL  A noinput, twooutput function that overwrites X and Y, such as MEAN. 

« Next Oldest  Next Newest »

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