Post Reply 
HP50g: local LBL and GOTO in user or sysRPL
09-07-2016, 10:15 PM
Post: #6
RE: HP50g: local LBL and GOTO in user or sysRPL
(09-07-2016 08:21 PM)3298 Wrote:  Why wouldn't relative GOTOs in Saturn ASM work? I thought the whole point of relative jumps was that you could relocate the entire code...

Anyway, I tried the PC=A approach Han mentioned...

I was also playing around with this concept, but using Debug4x/Emu48 instead of the onboard compiler. I was successful making the jump, but realized pretty quickly that the interpreter pointer (D0) needed to be updated to keep it from acting more like a GOSUB.

That's where things started getting messy. Updating D0 to point to the new next object seems straightforward enough, but "fixing" the RPL return stack has so far eluded me. Here's what I have so far as a test:
Code:
::
   "begin"

   CODEM
      A=PC
      *.Jmp1
      LC(5) (Lbl1-.Jmp1)
      A+C.A
      D0=A
      PC=(A)
   ENDCODE

   "skip this"
   "and this"
   TRUE ?SEMI

   LABEL Lbl1
   "Lbl1 1"
   "Lbl1 2"
;

The output of the above code is:
Code:
"begin"
"Lbl1 1"
"Lbl1 1"
"Lbl1 2"
...so clearly the RPL return stack needs to be adjusted. But my attempts so far have not been fruitful.

Having said all this, I still agree with 3298 and Han that this is probably not a very robust solution. I can imagine that a common place you might want to use a GOTO would be embedded in some kind of loop structure (or worse yet, multiple layers deep). Those are exactly the type of situations that would cause problems with this approach, since the RPL return stack would require manipulation that would depend on the exact status of the loop(s) you were trying to exit from. Keeping track of all that would quickly negate any GOTO advantage over simply using normal coding structures from the start.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP50g: local LBL and GOTO in user or sysRPL - DavidM - 09-07-2016 10:15 PM



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