Post Reply 
HP-41: Reusing local labels in same program.
10-23-2023, 02:00 PM
Post: #1
HP-41: Reusing local labels in same program.
@Valentin made the suggestion the other day where a local label was reused in such a way as to be effectively a NOP. After learning a bit more on how labels are parsed, I made up program "//Double label trouble 1" to demonstrate how a duplicate label may never be seen.

Yesterday I came across the part in the HP-41CX manual where it talks about 'compiling', i.e. the offset from GTO to label being remembered after first use. This got me wondering if one set up a program to try and make it possible that a local label could be reached if it would be. I write the program, "//Double label trouble 2" this morning to demonstrate this idea. To my surprise both 'LBL 01' instances are used. The offset recorded must me attached to each GTO. More reading on my part needed.

Someone else suggested the book "Extend Your HP-41", link below, which shows some other interesting uses of labels in section 6.4. These sorts of tricks are interesting to me but could lead to programs that are hard to understand and modify, particularly for a newbie.

Code:

//Double label trouble 1
LBL "EA"        ; First entry point
10              ; Entry marker
GTO 02          ; 
LBL 01          ; 1st LBL 01
11              ; Exit marker
RTN
LBL "EB"        ; Second entry point
20              ; Entry marker
GTO 02
LBL 01          ; 2nd LBL 01
22              ; Exit marker
RTN
LBL 02
GTO 01          ; Which LBL 01 will it goto?[/font]

Code:

//Double label trouble 2
LBL "E1"        ; First entry point
10              ; Entry marker
GTO 01          ; 
00              ; Line never hit
LBL 01          ; 1st LBL 01
11              ; Exit marker
LBL "E2"        ; Second entry point
20              ; Entry marker
GTO 01
00              ; Line never hit
LBL 01          ; 2nd LBL 01
22              ; Exit marker
RTN

Extend your HP-41
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP-41: Reusing local labels in same program. - Jeff_Birt - 10-23-2023 02:00 PM



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