Post Reply 
HP 41 - branching to local label and return stack - FINAL RESULTS AND PROGRAMS
05-20-2019, 10:03 PM (This post was last modified: 05-20-2019 10:04 PM by Garth Wilson.)
Post: #18
RE: HP 41 - branching to local label and return stack
I've been using GETKEY. This is a portion from a program I've been using for decades:

LBL 43  "GET F,X,L,C ESC"   AVIEW    \ "OK" in entry menu comes here.  Calc: key numbers here are 21, 64, 33, 13, and 15.
LBL 10   GETKEY   10 +
         SF 25   GTO IND X   GTO 43  \ If no key is pressed, GETKEY gives 0, you add 10, and loop again.  Invalid key will
                                     \ flash display once and repeat.  GTO 43, not 10 because of LCD rotate bug.

GETKEY does not stop the program, so you shouldn't lose your return stack contents (although I don't remember if I've tried it). The "add 10" part was to keep key numbers from conflicting with local-label keys, IIRC. The SF 25 is there so GTO IND X won't stop if there's no label that corresponds to the number of the key that was pressed.

Here's a slightly strange thing about it. If you don't press a key within ten seconds, it moves on (with 0 in X). If there was no key pressed whose key number matches a numerical label, I have it go around again to keep waiting. If you press a key in the short time it takes to make its way back around to re-start GETKEY, it won't see it, and you'll have to press it again. (Lots of HP-41 links at the bottom of the links page, )
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
RE: HP 41 - branching to local label and return stack - Garth Wilson - 05-20-2019 10:03 PM

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