Post Reply 
HP-41 END vs RTN
07-14-2019, 02:33 AM
Post: #1
HP-41 END vs RTN
One thing that I have never been 100% clear on with this calculator is when is it better, or more appropriate, to use END or RTN at the end of each program? I don't have a card reader so saving programs to cards is not an option. In that case, I can see the logic in grouping together programs by using RTN and only one END at the "end".

But generally, does anybody have any opinion regarding the relative merits of RTN vs END?

BTW - On my DM42 I always use RTN because then I can save all the programs as a single file.
Find all posts by this user
Quote this message in a reply
07-14-2019, 02:54 AM
Post: #2
RE: HP-41 END vs RTN
The advantage of using END to separate programs from each other is that each program gets its own space for searching local labels (i.e. LBL 00-99, A-J, and a-e.)

Let's say you have two programs, each containing a loop. The loop requires a GTO that jumps backwards, back to the beginning of the loop. If the two programs are joined, that is, there is no END separating them, then the two loops must be written with different labels, or else each of the two GTOs would jump to the wrong label, that is, the one in the other program, since that would be the first one found while searching downwards (towards higher line numbers) from the GTO. If the programs are separated by an END, you can choose the labels within each program without worrying about interfering with the other program.

If you are writing your own programs, you can, of course, choose your labels such that these kinds of collisions do not occur, and so, using RTN to end your programs is fine. If, on the other hand, you are using pre-written programs, you may have to use END to separate them.

Regarding your point of being able to save multiple programs in one file if they are separated by RTN: I don't have my DM42 at hand to check, but in Free42, you can save multiple programs to one file even if they are separated by ENDs. In fact, they don't even have to be contiguous in memory. Does the DM42 not allow that?
Find all posts by this user
Quote this message in a reply
07-14-2019, 03:58 AM
Post: #3
RE: HP-41 END vs RTN
Thomas,

As always, you are a font of knowledge. Thank you for your input. I'm leaning back towards END instead of RTN. Cleaner and as you say allows local labels to be reused with safety.
Find all posts by this user
Quote this message in a reply
07-14-2019, 07:43 AM
Post: #4
RE: HP-41 END vs RTN
(07-14-2019 02:54 AM)Thomas Okken Wrote:  Regarding your point of being able to save multiple programs in one file if they are separated by RTN: I don't have my DM42 at hand to check, but in Free42, you can save multiple programs to one file even if they are separated by ENDs. In fact, they don't even have to be contiguous in memory. Does the DM42 not allow that?

Indeed it does.
Find all posts by this user
Quote this message in a reply
Post Reply 




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