Post Reply 
HP-41C weird program behaviour
04-14-2023, 06:39 AM (This post was last modified: 04-14-2023 06:40 AM by ThomasF.)
Post: #14
RE: HP-41C weird program behaviour
(04-09-2023 09:22 PM)JurgenRo Wrote:  
(04-04-2023 09:15 PM)David Hayden Wrote:  Try replacing RTN with END.

Will do, thanks for your input! Although, I don't think that it makes a difference because the program pointer should never see neither the RTN nor the End, shouldn't it?

It might.
What I think David tries to indicate is that if your program ends with END, we know that we see the whole complete program (assuming that LBL TST is at line 01), meaning that there could be no instructions after the GTO 01.

I don't think this is the case here, but you could have several programs after each other (i.e. as part of larger collection of smaller routines), separated by RTN but just listed the first part:

Code:
LBL TST
LBL 01
1
+
GTO 01
RTN
LBL TST2
LBL 01
2
+
GTO 01
RTN
END

And this would mess up things, as the first GTO 01 would jump to the LBL 01 after the LBL TST2, since GTO will search downwards looking for the first LBL 01 it can find before looping back to the start of the program.
But, if you end your program with END instead, you are guaranteed that the LBL 01 is unique and local (as there can't be any instructions following the END instruction):

Code:
01 LBL TST
02 LBL 01
03 1
04 +
05 GTO 01
06 END

Cheers,
Thomas

[35/45/55/65/67/97/80 21/25/29C 31E/32E/33E|C/34C/38E 41C|CV|CX 71B 10C/11C/12C/15C|CE/16C 32S|SII/42S 28C|S 48GX/49G/50G 35S 41X]
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP-41C weird program behaviour - JurgenRo - 03-19-2023, 06:46 PM
RE: HP-41C weird program behaviour - ThomasF - 04-14-2023 06:39 AM



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