The GTO function is pretty straight forward in the HP-65 calculator. Here’s how it works:
GTO from the keyboard looks like this:
00715 rom 2 01316 key -> rom ; f= ..23.5.. ; [GTO] 01054 goto 01347 01347 rom 4 02350 buffer -> rom address 02351 goto 02000 02054 goto 02166
It goes on to set M[11] to 1:
02120 c + 1 -> c[p] ; C= 00100000000221 (set GTO prefix) 02276 c <-> m ; C= 00000000000000 M= 00100000000221
Then when [C] is pressed:
00715 rom 2 01316 key -> rom ; f= ..23.5.. ; [C] pressed 01033 goto 01351 01351 rom 4 02352 0 -> f5 ; S= ...........b f= ..23....
It determines that GTO was pressed beforehand:
02366 11 -> p ; P= 11 02367 if c[p] >= 1 02370 goto 02257
and ends up here:
; doing GTO C 02257 search for label ; f= ..23.... 02260 (wait for ready) 02261 goto 02360 02360 0 -> c[m] ; C= 00000000000221 02361 c <-> m ; C= 00000000000000 M= 00000000000221 02362 ... display:
There is nothing fancy in the process. It doesn’t start running. It doesn’t save a return address or activate a secondary pointer. It’s just:
if GTO pressed set prefix-GTO
if C pressed
if prefix-GTO
search for label
clear prefixes
…
In a program it works the same way:
00763 rom 2 ; f= ..23.5.. 01364 buffer -> rom address 01365 goto 01000 ; 054 = GTO 01054 goto 01347
and
00763 rom 2 ; f= ..23.5.. 01364 buffer -> rom address 01365 goto 01000 ; 036 = [A] 01036 goto 01351 01351 rom 4 02352 0 -> f5 ; f= ..23....
The program uses GTO A but the process is the same. The only differences are:
- It checks and re-sets the running flag again when it does a “clear status”.
- If running it goes to get next program step instead of wait for key press.
More detail is available in 65-gto-c.txt.
The mechanism splits the GTO and the target label into two program steps ([GTO] then [C]). This opens the door to interesting combinations like “GTO” “STO 6”. Whilst interesting, they are unlikely to do anything as most invalid combinations just clear prior prefixes. In this case the GTO would start (set a prefix) then get ignored (prefix reset) as the “STO 6” gets run.
The HP-67 merges the GTO program step so you don’t get the chance to tinker this way. Of course it has 8-bit program steps instead of the 6-bit ones that the HP-65 uses. That gives the HP-67 more scope for merging steps.