HP 41-XEQ/GTO and RTN - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: HP 41-XEQ/GTO and RTN (/thread-8620.html) |
HP 41-XEQ/GTO and RTN - Jotne - 07-03-2017 08:17 AM I was looking at the Caves game for HP-41, there I see some I do not understand fully. http://www.hpmuseum.org/software/41td/caves.htm These lines: Code: 318 LBL 33 I do understand how to works when you call it using XEQ commands like this: Code: 129 XEQ 33 But In the Caves there are several calls to same subroutine using GTO like this: Code: 176 GTO 33 When I test this, it seem that the program stops at the RTN when GTO is used. Does the program continue with 322 LBL 13 when this happens? Is this wrong within the program? Or do I miss something? RE: HP 41-XEQ/GTO and RTN - Dieter - 07-03-2017 10:50 AM (07-03-2017 08:17 AM)Jotne Wrote: But In the Caves there are several calls to same subroutine using GTO like this: Right. But this is not a call of subroutine 33, it's a jump to that label. (07-03-2017 08:17 AM)Jotne Wrote: Does the program continue with 322 LBL 13 when this happens? It's quite simple. If a RTN is encountered and there is a pending subroutine call the program returns to the line following that (XEQ-)call. If there is no pending subroutine, RTN simply stops., just like a R/S. Code: "ONE" If you run this, "ONE", "TWO" and "THREE" will be displayed, then the program stops at the RTN. The following "even more code" will not be executed until you press R/S to continue. Of course it is possible that a GTO 33 occurs within a pending subroutine that has been called by an XEQ before. In this case the RTN makes the program return to the line after that subroutine call. ;-) Dieter RE: HP 41-XEQ/GTO and RTN - Jotne - 07-03-2017 02:30 PM Thanks allot for the detailed explanation. I am some rusty in the 41cx programming. Just for fun I made a Visio of the whole Caves program. What a big mess of routines and calls in the program RE: HP 41-XEQ/GTO and RTN - Jotne - 07-22-2017 06:58 AM Some more question about the Caves program. From what I read in the Extend you HP-41 book, page 137 regarding LBL 00 to LBL 14: Quote:For now, its best to remember that these short-form labels 00 to 14 and their GTO's saves spacce but should only be used it the are less than about 40 lines apart. Taken from the Caves program Code: 135 LBL 00 Will these works correctly, many of them are more than 40 lines apart? RE: HP 41-XEQ/GTO and RTN - Paul Dale - 07-22-2017 07:34 AM Yes, they'll work. They just can't cache the destination and will be slower. Pauli RE: HP 41-XEQ/GTO and RTN - SlideRule - 07-22-2017 12:26 PM (07-03-2017 02:30 PM)Jotne Wrote: ... detailed explanation ... a Visio of the whole Caves program... Is your VISIO® available? BEST! SlideRule RE: HP 41-XEQ/GTO and RTN - Dieter - 07-22-2017 04:07 PM (07-22-2017 06:58 AM)Jotne Wrote: Will these works correctly, many of them are more than 40 lines apart? The actual limit is not 40 lines but 112 bytes. If a jump to LBL 00...14 has no greater distance the jump target (the position of the LBL in memory) can be stored within the GTO command as the first jump is performed, so that afterwards no label search is required. This can speed up the program significantly. Of course the GTO will also work if the corresponding LBL is more than 112 bytes away, but it may require more time since the label has to be searched each time the program reaches the GTO. That's why you should use LBL 15 and up for long distance jumps. The corresponding GTOs do not have this 112-byte-limit so that, once the label has been found, all subsequent jumps can be done without a label search. So in the Caves program it would have been a good idea to replace LBL 00 all all corresponding GTOs with, say, LBL 88. Just as it was done with the random number generator at LBL 99 which can be accessed quickly from any point in the program. Dieter RE: HP 41-XEQ/GTO and RTN - Jotne - 07-22-2017 07:45 PM (07-22-2017 12:26 PM)SlideRule Wrote: Is your VISIO® available? I will post it when it looks some complete. Just now it covers 12 A4 page. Here is a teaser PS I see that I am limited to only post files of 200K, that is some small. I may need to post a link. PS thanks Dieter and Paul for explaining the jumps.. |