HP50g: local LBL and GOTO in user or sysRPL
|
09-09-2016, 02:34 AM
(This post was last modified: 09-12-2016 04:24 PM by DavidM.)
Post: #10
|
|||
|
|||
RE: HP50g: local LBL and GOTO in user or sysRPL
My curiosity got the better of me and I spent a little more time on this trying a few things. Cyrille's post provided a big clue that took me a while to understand due to the multiple interpretations of the "RPL" statement in his sample code. While I initially thought that it was a compiler directive indicating to switch compilation modes (which didn't make sense to me), I ultimately realized it was the shortcut for the standard "LOOP" phrase that triggers the next RPL object execution:
Code: A=DAT0 A At that point things fell into place nicely and it became clear how to proceed. Reminder: everything below is source code applicable to Debug4x; if you use the on-board compiler, the syntax would be different (though similar). To make things slightly more readable, I cooked up this macro to assist with the GOTO step: Code: ASSEMBLE This removes some of the clutter in the final code segment. The macro call still has to be bracketed by "ASSEMBLE" and "RPL" tokens, and unfortunately they need to be on separate lines. Hence the 3-line invocation for each GOTO. With that, I present (in all its spaghetti-code glory) a working example of a code segment that jumps around to arbitrary labels: Code: :: The above code object leaves this on the stack at exit: Code: "first line" Hope this helps. EDIT: changed the "exit" SEMI to "[;]", which is a better way to generate the appropriate code without RPLCOMP ditching the rest of the program due to its tracking of code blocks. Also shortened the Saturn code by jumping to Loop instead of executing directly. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)