HP-29C Input Mode

When you press digits on the HP-29C, you go into “Input Mode”. What is that, and how does it work?

The input_mode process is quite lengthy as you need to see what happens before and after pressing the decimal point “dot” key, and you also need a few digits on each side to see how it deals with tens as well as ones, and hundredths as well as tenths.

Short Summary

The short version is: it saves the display formatted value in ram[30] and also adds two settings in there. The sign digit gets set to 1 if the decimal point has already been pressed. ram[30][0] is the exponent for the current value.

It is clever to save the display formatted value and decimal point settings. That IS the current state during input mode and it is easy to add digits and update the display accordingly. But, boy oh boy, it isn’t simple to follow.

You won’t believe it but, the following is what started as the summary of how input mode works.

First Digit

When you press the first digit, it sets input_mode by setting s12.
It also shuffles the digit to the left of the display and updates ram[30] and ram[47].

The sequence looks like:

00173: if 0 = s 15 then goto 00152         ; 4 pressed s15=1
00175: display off                         ;
00176: ...
00222: a -> rom address                    ; A=0000FFFFFFF340

key_4:
00464: ...                                 ; C=00000000000004

digit:
00745: c + 1 -> c[p]                       ; C=00000000000014 (hex code)
00746: ...                                 ;
01167: ...                                 ; clear prefixes (s 4,6,7,8,10) and s0,13,14
00563: ...                                 ; A=00000000000014 M1=00000000000014
01167: ...                                 ; clear prefixes (s 4,6,7,8,10) and s0,13,14
00570: ...                                 ; C=00000000000000 (B->C)
06025: p <- 12                             ; P=12
06026: 0 -> s 11                           ;
06027: a -> rom address                    ;

hex_1x:                                    ; hex codes 10-19 (digit 0-9), and others
06001: ...                                 ;
07014: ...                                 ; check 1x, x is 0-9
07164: ...                                 ;
07400: if 1 = s 12 then goto 01417         ; if not first digit
07402: if 0 = s 9 then goto 01405          ; if auto_enter
07404: c -> stack                          ;    push existing X up the stack
07405: 1 -> s 9                            ; endif (and set auto_enter for nxt)
07406: 0 -> c[w]                           ; X=0
07407: binary                              ;
07410: c - 1 -> c[w]                       ; C=FFFFFFFFFFFFFF
07411: 0 -> c[s]                           ; C=0FFFFFFFFFFFFF
07412: f exch a                            ; A=00000000000010
07413: 0 -> a[x]                           ; A=00000000000000
07414: f exch a                            ; A=00000000000004
07415: 1 -> s 12                           ; S=...3.5...9..C..F input_mode
07416: if n/c goto 0022                    ;
;
; shift digit from A[0] to correct position
07422: p <- 1                              ; P= 1
07423: c + 1 -> c[p]                       ; C=0FFFFFFFFFFF0F
07424: if n/c goto 0051                    ;
07425: shift left a[w]                     ; A=00000000000040
07426: p + 1 -> p                          ; P= 2
07427: if p # 13 then goto 01423           ;
07423: ...                                 ; C=0FFFFFFFFFF00F A=00000000000400 P= 3
07423: ...                                 ; C=0FFFFFFFFF000F A=00000000004000 P= 4
07423: ...                                 ; C=0FFFFFFFF0000F A=00000000040000 P= 5
07423: ...                                 ; C=0FFFFFFF00000F A=00000000400000 P= 6
07423: ...                                 ; C=0FFFFFF000000F A=00000004000000 P= 7
07423: ...                                 ; C=0FFFFF0000000F A=00000040000000 P= 8
07423: ...                                 ; C=0FFFF00000000F A=00000400000000 P= 9
07423: ...                                 ; C=0FFF000000000F A=00004000000000 P=10
07423: ...                                 ; C=0FF0000000000F A=00040000000000 P=11
07423: ...                                 ; C=0F00000000000F A=00400000000000 P=12
07423: ...                                 ; C=0000000000000F A=04000000000000 P=13
07431: p - 1 -> p                          ; P=12
07432: a exchange c[wp]                    ; A=0000000000000F C=04000000000000
07433: p - 1 -> p                          ; P=11
07434: c -> a[w]                           ; A=04000000000000
07435: c - 1 -> c[wp]                      ; C=04FFFFFFFFFFFF (" 4     ")
07436: a exchange c[x]                     ; A=04000000000FFF C=04FFFFFFFFF000
07437: if a[m] # 0 then goto 01465         ;
07465: jsb 0067                            ;

; looks like it adjusts exponent for precision (f) and
; normalizes - don't want C[12] (first digit) =0
07467: a exchange b[x]                     ; A=04000000000000 B=00000000000FFF
07470: decimal                             ;
07471: 0 -> a[x]                           ;
07472: f -> a                              ;
07473: a + c -> c[x]                       ;
07474: p <- 12                             ; P=12
07475: if c[p] # 0 then goto 01505         ;
07505: a exchange b[x]                     ; A=04000000000FFF B=00000000000000
07506: binary                              ;
07507: return                              ;

07466: if n/c goto 0041                    ;
07441: a exchange c[ms]                    ; A=04FFFFFFFFFFFF C=04000000000000
07442: ...                                 ; C->B,            B=04000000000000
07444: jsb 0203                            ;

; A[0]=f; A->ram[30]
07603: if 0 = s 4 then goto 01607          ;
07607: f -> a                              ; A=04FFFFFFFFFFF0
07610: binary                              ;
07611: if 0 = s 7 then goto 01617          ;
07617: p <- 1                              ; P= 1
07620: load constant 1                     ; C=04000000000010 P= 0
07621: c -> addr                           ;
07622: a exchange c[w]                     ; A=04000000000010 C=04FFFFFFFFFFF0
07623: c -> data register 14               ;
07624: a exchange c[w]                     ; A=04FFFFFFFFFFF0 C=04000000000010
07625: c -> a[s]                           ;
07626: return                              ;

07445: b -> c[w]                           ; C=04000000000000
07446: jsb 0347                            ;

; B->C->ram[47]
07747: p <- 1                              ; P= 1
07750: load constant 2                     ; C=04000000000020 P= 0
07751: c -> addr                           ;
07752: b -> c[w]                           ; C=04000000000000
07753: c -> data register 15               ;
07754: return                              ;

07447: delayed rom 0                       ;
07450: if n/c goto 0063                    ;
00063: jsb 0323                            ;

; B->C, ram[47]->B
00323: p <- 1                              ; P= 1
00324: load constant 2                     ; C=04000000000020 P= 0
00325: c -> addr                           ;
00326: data register -> c 15               ; C=04000000000000
00327: b exchange c[w]                     ;
00330: return                              ;

00064: if n/c goto 0114                    ;
00114: jsb 0315                            ;

00315: if 1 = s 2 then goto 00321          ;
00317: if 0 = s 1 then goto 00322          ;
00322: return                              ;

00115: ...                                 ;
01167: ...                                 ; clear prefixes (s 4,6,7,8,10) and s0,13,14
00120: b -> c[w]                           ;
00121: if 1 = s 2 then goto 00223          ;
00123: 0 -> s 1                            ;

; A=04FFFFFFFFFFF0 B=04000000000000 C=04000000000000
; M1=00000000000014 S=...3.5...9..C..F f=0

00124: ...

Second Digit

It behaves a little differently if you press another digit key:

00173: if 0 = s 15 then goto 00152         ; 5 pressed (S=...3.5...9..C..F)
00175: display off                         ; 
00176: ...                                 ; B=04000000000000 C=04000000000000
00222: a -> rom address                    ; A=04FFFFFFFFF330 P= 1

key_5:
00463: ...                                 ; C=04000000000005

digit:
00745: c + 1 -> c[p]                       ; C=04000000000015 C[1,0]=hex code
00746: ...                                 ; A=04000000000015 M1=04000000000015
06024: b -> c[w]                           ; C=04000000000000
06025: p <- 12                             ; P=12
06026: 0 -> s 11                           ;
06027: a -> rom address                    ;

hex_1x:
06001: ...
07014: ...                                 ; check 1x, x is 0-9
07164: ...                                 ;
07400: if 1 = s 12 then goto 01417         ;

; second or later digit (s12 already set)
07417: jsb 0142                            ;

; ram[30]->C c[0]<>f
07542: p <- 1                              ; P= 1
07543: binary                              ;
07544: load constant 1                     ; C=04000000000010 P= 0
07545: c -> addr                           ;
07546: data register -> c 14               ; C=04FFFFFFFFFFF0
07547: a exchange c[p]                     ; A=04000000000010 C=04FFFFFFFFFFF5
07550: f exch a                            ; (A[0]=0 f=0)
07551: a exchange c[p]                     ; A=04000000000015 C=04FFFFFFFFFFF0
07552: p <- 13                             ; P=13
07553: if c[s] = 0 then goto 01601         ;
07601: binary                              ;
07602: return                              ;

07420: if 1 = s 4 then goto 01510          ;

; shift digit from A[0] to correct position
07422: p <- 1                              ; P= 1
07423: c + 1 -> c[p]                       ; C=04FFFFFFFFFF00
07424: if n/c goto 0051                    ;
07425: shift left a[w]                     ; A=40000000000150
07426: p + 1 -> p                          ; P= 2
07427: if p # 13 then goto 01423           ;
07423: ...                                 ; C=04FFFFFFFFF000 A=00000000001500 P= 3
07423: ...                                 ; C=04FFFFFFFF0000 A=00000000015000 P= 4
07423: ...                                 ; C=04FFFFFFF00000 A=00000000150000 P= 5
07423: ...                                 ; C=04FFFFFF000000 A=00000001500000 P= 6
07423: ...                                 ; C=04FFFFF0000000 A=00000015000000 P= 7
07423: ...                                 ; C=04FFFF00000000 A=00000150000000 P= 8
07423: ...                                 ; C=04FFF000000000 A=00001500000000 P= 9
07423: ...                                 ; C=04FF0000000000 A=00015000000000 P=10
07423: ...                                 ; C=04F00000000000 A=00150000000000 P=11
07423: ...                                 ; C=04000000000000 A=01500000000000 P=12
07423: ...                                 ; C=05000000000000
07424: if n/c goto 0051                    ;
; exited loop before P=13 (12) because found non-F value at C[12]
07451: c - 1 -> c[p]                       ; C=04000000000000, put value back
07452: if p # 3 then goto 01457            ;
07457: if 1 = s 7 then goto 01431          ;
;
; f++ 
07461: f exch a                            ;
07462: a + 1 -> a[x]                       ; A=01500000000001
07463: f exch a                            ; A=01500000000000 f=1
07464: if n/c goto 0031                    ;
;
07431: p - 1 -> p                          ; P=11
07432: a exchange c[wp]                    ; A=01000000000000 C=04500000000000
07433: p - 1 -> p                          ; P=10
07434: c -> a[w]                           ; A=04500000000000
07435: c - 1 -> c[wp]                      ; C=045FFFFFFFFFFF
07436: a exchange c[x]                     ; A=04500000000FFF C=045FFFFFFFF000
07437: if a[m] # 0 then goto 01465         ;
07465: jsb 0067                            ;

; looks like it adjusts exponent for precision (f) and
; normalizes - don't want C[12] (first digit) =0
07467: a exchange b[x]                     ; A=04500000000000 B=04000000000FFF
07470: decimal                             ;
07471: 0 -> a[x]                           ;
07472: f -> a                              ; A=04500000000001
07473: a + c -> c[x]                       ; C=045FFFFFFFF001
07474: p <- 12                             ; P=12
07475: if c[p] # 0 then goto 01505         ;
07505: a exchange b[x]                     ; A=04500000000FFF B=04000000000001
07506: binary                              ;
07507: return                              ;

07466: if n/c goto 0041                    ;
07441: a exchange c[ms]                    ; A=045FFFFFFFFFFF C=04500000000001
07442: ...                                 ; C->B B=04500000000001
07444: jsb 0203                            ;

; A[0]=f; A->ram[30]
07603: if 0 = s 4 then goto 01607          ;
07607: f -> a                              ; A=045FFFFFFFFFF1
07610: binary                              ;
07611: if 0 = s 7 then goto 01617          ;
07617: p <- 1                              ; P= 1
07620: load constant 1                     ; C=04500000000011 P= 0
07621: c -> addr                           ;
07622: a exchange c[w]                     ; A=04500000000011 C=045FFFFFFFFFF1
07623: c -> data register 14               ;
07624: a exchange c[w]                     ; A=045FFFFFFFFFF1 C=04500000000011
07625: c -> a[s]                           ;
07626: return                              ;

07445: ...                                 ; B->C C=04500000000001
07747: ...                                 ; B->C->ram[47], P=0
00323: ...                                 ; B->C, ram[47]->B, P=0
00115: ...                                 ;
01167: ...                                 ; clear prefixes (s 4,6,7,8,10) and s0,13,14
00120: ...                                 ;

; A=045FFFFFFFFFF1 B=04000000000001 C=04500000000001
; M1=04000000000015 S=...3.5...9..C..F f=1

00124: ...
; M1=04500000000001
; C=04500000000001 B=20900000000000 A=045FFFFFFFFF00 P=11

00144: cpu woodstock                       ;
00145: display off                         ;
00146: display toggle                      ;
00147: 0 -> s 15                           ; S=...3.5...9..C...
00150: if 1 = s 15 then goto 00147         ;
00152: ...

Press Dot

At some point, we press dot to mark the decimal point.

00173: if 0 = s 15 then goto 00152         ; S=...3.5...9..C..F (dot pressed)
00175: display off                         ;
00176: ...                                 ; B=04500000000001 C=04500000000000 P=1
00222: a -> rom address                    ; A=045FFFFFFFF2E0

key_dot:
00456: ...                                 ; C=0450000000001A P=1
01167: ...                                 ; clear prefixes (s 4,6,7,8,10) and s0,13,14
00565: ...                                 ; A=0450000000001A
00566: ...                                 ; C=04500000000001 M1=0450000000001A
01167: ...                                 ; clear prefixes (s 4,6,7,8,10) and s0,13,14
06021: ...
06025: p <- 12                             ; P=12
06026: 0 -> s 11                           ;
06027: a -> rom address                    ; A=0450000000001A

hex_1x:
06001: ...                                 ; dot is hex code 1A 
07014: ...                                 ; check 1x, x is 0-9 - it's not
07025: ...                                 ; A=450000000001A0
07027: a -> rom address                    ;

func_dot:
07032: ...                                 ;
07627: if 1 = s 12 then goto 01635         ; if input_mode (yes)
07635: jsb 0142                            ;

; ram[30]->C, mainly
07542: p <- 1                              ; P= 1
07543: binary                              ;
07544: load constant 1                     ; C=04500000000011 P= 0
07545: c -> addr                           ;
07546: data register -> c 14               ; C=045FFFFFFFFFF1
07547: a exchange c[p]                     ; A=450000000001A1 C=045FFFFFFFFFF0
07550: f exch a                            ; (A[0]=1 f=1)
07551: a exchange c[p]                     ; A=450000000001A0 C=045FFFFFFFFFF1
07552: p <- 13                             ; P=13
07553: if c[s] = 0 then goto 01601         ;
07601: binary                              ;
07602: return                              ;

07636: 1 -> s 7                            ; S=...3.5.7.9..C..F
07637: a exchange c[w]                     ; A=045FFFFFFFFFF1 C=450000000001A0
07640: b -> c[w]                           ; C=04500000000001
07641: if 0 = s 4 then goto 01444          ;
07444: jsb 0203                            ;

; A[0]=f; A->ram[30]
07603: if 0 = s 4 then goto 01607          ;
07607: f -> a                              ;
07610: binary                              ;
07611: if 0 = s 7 then goto 01617          ;
07613: a + 1 -> a[s]                       ; A=145FFFFFFFFFF1
07614: if 0 = s 4 then goto 01617          ;
07617: p <- 1                              ; P= 1
07620: load constant 1                     ; C=04500000000011 P= 0
07621: c -> addr                           ;
07622: a exchange c[w]                     ; A=04500000000011 C=145FFFFFFFFFF1
07623: c -> data register 14               ;
07624: a exchange c[w]                     ; A=145FFFFFFFFFF1 C=04500000000011
07625: c -> a[s]                           ; A=045FFFFFFFFFF1
07626: return                              ;

07445: b -> c[w]                           ; C=04500000000001
07446: ...                                 ; B->ram[47]
07447: delayed rom 0                       ;
07450: if n/c goto 0063                    ;
00063: ...                                 ; ram[47]->B
00064: ...                                 ;
01167: ...                                 ; clear prefixes (s 4,6,7,8,10) and s0,13,14
00120: ...                                 ;

; A=045FFFFFFFFFF1 B=04500000000001 C=04500000000001
; S=...3.5...9..C..F f=1

00124: ...

; A=045FFFFFFFFF00 B=20900000000000 C=04500000000001
; M1=04500000000001 P=11

00144: cpu woodstock                       ;
00145: display off                         ;
00146: display toggle                      ;
00147: 0 -> s 15                           ; S=...3.5...9..C...
00150: if 1 = s 15 then goto 00147         ;
00152: ...

Press 6

00173: if 0 = s 15 then goto 00152         ; S=...3.5...9..C..F
00175: display off                         ;
00176: ...                                 ; B=04500000000001 C=04500000000000 P= 1
00222: a -> rom address                    ; A=045FFFFFFFF320 (0x32=062)

key_6:                                     ; (s13 gets set if digit>5, see prefixes)
00462: ...                                 ; S=...3.5...9..CD.F C=04500000000006

digit:
00745: c + 1 -> c[p]                       ; C=04500000000016 (hex code)
00746: ...                                 ;
01167: ...                                 ; clear prefixes (s 4,6,7,8,10) and s0,13,14
01177: ...                                 ; S=...3.5...9..C..F
00563: ...                                 ; A=04500000000016 M1=04500000000016
01167: ...                                 ; clear prefixes (s 4,6,7,8,10) and s0,13,14
00570: ...                                 ; B->C=04500000000001
06025: p <- 12                             ; P=12
06026: 0 -> s 11                           ;
06027: a -> rom address                    ;

hex_1x:
06001: ...                                 ;
07014: ...                                 ; check 1x, x is 0-9
07164: ...                                 ;
07400: if 1 = s 12 then goto 01417         ; if not first digit - true, go

; second or later digit (s12 already set)
07417: jsb 0142                            ; ram[30]->C, C[0]<>f s7=(dot?)1:0
07542: p <- 1                              ; P= 1
07543: binary                              ;
07544: load constant 1                     ; C=04500000000011 P= 0
07545: c -> addr                           ;
07546: data register -> c 14               ; C=145FFFFFFFFFF1
07547: a exchange c[p]                     ; A=04500000000011 C=145FFFFFFFFFF6
07550: f exch a                            ;
07551: a exchange c[p]                     ; A=04500000000016 C=145FFFFFFFFFF1
07552: p <- 13                             ; P=13
07553: if c[s] = 0 then goto 01601         ;
07555: c - 1 -> c[s]                       ; C=045FFFFFFFFFF1
07556: if c[s] # 0 then goto 01562         ;
07560: 1 -> s 7                            ; S=...3.5.7.9..C..F
07561: if n/c goto 0201                    ;
07601: binary                              ;
07602: return                              ;
; note ram[30][s]==1 so s7 got set

07420: if 1 = s 4 then goto 01510          ;

; shift digit from A[0] to correct position
07422: p <- 1                              ; P= 1
07423: c + 1 -> c[p]                       ; C=045FFFFFFFFF01
07424: if n/c goto 0051                    ;
07425: shift left a[w]                     ; A=45000000000160
07426: p + 1 -> p                          ; P= 2
07427: if p # 13 then goto 01423           ;
07423: ...                                 ; C=045FFFFFFFF001 A=50000000001600 P= 3
07423: ...                                 ; C=045FFFFFFF0001 A=00000000016000 P= 4
07423: ...                                 ; C=045FFFFFF00001 A=00000000160000 P= 5
07423: ...                                 ; C=045FFFFF000001 A=00000001600000 P= 6
07423: ...         ]                       ; C=045FFFF0000001 A=00000016000000 P= 7
07423: ...                                 ; C=045FFF00000001 A=00000160000000 P= 8
07423: ...                                 ; C=045FF000000001 A=00001600000000 P= 9
07423: ...                                 ; C=045F0000000001 A=00016000000000 P=10
07423: ...                                 ; C=04500000000001 A=00160000000000 P=11
07423: c + 1 -> c[p]                       ; C=04600000000001
07424: if n/c goto 0051                    ;
; exit loop
07451: c - 1 -> c[p]                       ; C=04500000000001, put value back
07452: if p # 3 then goto 01457            ;
07457: if 1 = s 7 then goto 01431          ; if dot_pressed (yes, go)
;
; NOTE: skipping bit that incremented f with each digit
;
07431: p - 1 -> p                          ; P=10
07432: a exchange c[wp]                    ; A=00100000000001 C=04560000000000
07433: p - 1 -> p                          ; P= 9
07434: c -> a[w]                           ; A=04560000000000
07435: c - 1 -> c[wp]                      ; C=0456FFFFFFFFFF
07436: a exchange c[x]                     ; A=04560000000FFF C=0456FFFFFFF000
07437: if a[m] # 0 then goto 01465         ;
07465: jsb 0067                            ;

; looks like it adjusts exponent for precision (f) and
; normalizes - don't want C[12] (first digit) =0
07467: a exchange b[x]                     ; A=04560000000001 B=04500000000FFF
; b[x] is the exponent we had last time, 001, for 045... = 4.5e1 = "45."
07470: decimal                             ;
07471: 0 -> a[x]                           ; A=04560000000000
07472: f -> a                              ; A=04560000000001 (f is still 1)
07473: a + c -> c[x]                       ; C=0456FFFFFFF001 "45.6 blanks"
07474: p <- 12                             ; P=12
07475: if c[p] # 0 then goto 01505         ; mantissa in range 1-9, ok
07505: a exchange b[x]                     ; A=04560000000FFF B=04500000000001
07506: binary                              ;
07507: return                              ;

07466: if n/c goto 0041                    ;
07441: a exchange c[ms]                    ; A=0456FFFFFFFFFF C=04560000000001
07442: b exchange c[w]                     ; B=04560000000001 C=04500000000001
07443: b -> c[w]                           ; C=04560000000001
; A is displayable. B & C have X value
07444: jsb 0203                            ;

; save display value and info in ram[30]
07603: if 0 = s 4 then goto 01607          ;
07607: f -> a                              ; A=0456FFFFFFFFF1
07610: binary                              ;
07611: if 0 = s 7 then goto 01617          ; if not dot_pressed (no - stay)
07613: a + 1 -> a[s]                       ; A=1456FFFFFFFFF1 (flag, A[s]=1)
07614: if 0 = s 4 then goto 01617          ;
; A->ram[30] (A[s] is flag: 1 if dot pressed. A[0]=dot position. Rest: displayable
07617: p <- 1                              ; P= 1
07620: load constant 1                     ; C=04560000000011 P= 0
07621: c -> addr                           ; addr=16
07622: a exchange c[w]                     ; A=04560000000011 C=1456FFFFFFFFF1
07623: c -> data register 14               ;
07624: a exchange c[w]                     ; A=1456FFFFFFFFF1 C=04560000000011
07625: c -> a[s]                           ; A=0456FFFFFFFFF1
07626: return                              ;

07445: ...                                 ; B->C C=04560000000001
07747: ...                                 ; B->C, C->ram[47], P= 0
00323: ...                                 ; B->C, ram[47]->B, P= 0
00115: ...                                 ;
01167: ...                                 ; clear prefixes (s 4,6,7,8,10) and s0,13,14
00120: ...                                 ;

; A=0456FFFFFFFFF1 B=04560000000001 C=04560000000001
; M1=04500000000016 S=...3.5...9..C..F f=1

00124: ...
; M1=04560000000001
; C=04560000000001 B=20900000000000 A=0456FFFFFFFF00 P=11

00144: cpu woodstock                       ;
00145: display off                         ;
00146: display toggle                      ;
00147: 0 -> s 15                           ; S=...3.5...9..C...
00150: if 1 = s 15 then goto 00147         ;
00152: ...

Press 7

00152: 0 -> s 1                            ; 7 pressed (S=...3.5...9..C..F)
00153: 0 -> s 3                            ;
00154: if 0 = s 3 then goto 00163          ;
00156: if 0 = s 11 then goto 00165         ;
00165: 0 -> s 5                            ;
00166: if 1 = s 5 then goto 00173          ;
00173: if 0 = s 15 then goto 00152         ;
00175: display off                         ;
00176: ...                                 ; B=04560000000001 C=04560000000000
00222: a -> rom address                    ; (A=0456FFFFFFF200 P= 1)

key_7:
00440: ...                                 ; S=...3.5...9..CD.F C=04560000000007

digit:
00745: c + 1 -> c[p]                       ; C=04560000000017 C[1,0]=hex code
00746: ...                                 ; S=...3.5...9..C..F
00565: ...                                 ; A=04560000000017 M1=04560000000017
06024: b -> c[w]                           ; C=04560000000001
06025: p <- 12                             ; P=12
06026: 0 -> s 11                           ;
06027: a -> rom address                    ;

hex_1x:
06001: ...                                 ;
07014: ...                                 ; check 1x, x is 0-9
07164: ...                                 ;
07400: if 1 = s 12 then goto 01417         ;

07417: jsb 0142                            ;

; get last display value and settings (decimal point & position) from ram[30]
; put decimal point position in f (4: 0->f, 45: 1->f, 452: 2->f, etc)
; set s7 if dot was pressed already
; fix c[s] given dot_pressed was stored there in ram[30]
07542: p <- 1                              ; P= 1
07543: binary                              ;
07544: load constant 1                     ; C=04560000000011 P= 0
07545: c -> addr                           ;
07546: data register -> c 14               ; C=1456FFFFFFFFF1
07547: a exchange c[p]                     ; A=04560000000011 C=1456FFFFFFFFF7
07550: f exch a                            ; (f is 1)
07551: a exchange c[p]                     ; A=04560000000017 C=1456FFFFFFFFF1
07552: p <- 13                             ; P=13
07553: if c[s] = 0 then goto 01601         ;
07555: c - 1 -> c[s]                       ; C=0456FFFFFFFFF1
07556: if c[s] # 0 then goto 01562         ;
07560: 1 -> s 7                            ; S=...3.5.7.9..C..F
07561: if n/c goto 0201                    ;
07601: binary                              ;
07602: return                              ;

07420: if 1 = s 4 then goto 01510          ;

; shift digit from A[0] to correct position
07422: p <- 1                              ; P= 1
07423: c + 1 -> c[p]                       ; C=0456FFFFFFFF01
07424: if n/c goto 0051                    ;
07425: shift left a[w]                     ; A=45600000000170
07426: p + 1 -> p                          ; P= 2
07427: if p # 13 then goto 01423           ;
07423: ...                                 ; C=0456FFFFFFF001 A=56000000001700 P= 3
07423: ...                                 ; C=0456FFFFFF0001 A=60000000017000 P= 4
07423: ...                                 ; C=0456FFFFF00001 A=00000000170000 P= 5
07423: ...                                 ; C=0456FFFF000001 A=00000001700000 P= 6
07423: ...                                 ; C=0456FFF0000001 A=00000017000000 P= 7
07423: ...                                 ; C=0456FF00000001 A=00000170000000 P= 8
07423: ...                                 ; C=0456F000000001 A=00001700000000 P= 9
07423: ...                                 ; C=04560000000001 A=00017000000000 P=10
07423: c + 1 -> c[p]                       ; C=04570000000001
07424: if n/c goto 0051                    ;
; exit loop
07451: c - 1 -> c[p]                       ; C=04560000000001, put value back
07452: if p # 3 then goto 01457            ;
07457: if 1 = s 7 then goto 01431          ; if dot_pressed (yes, go)
;
; NOTE: skipping bit that incremented f with each digit
;
07431: p - 1 -> p                          ; P= 9
07432: a exchange c[wp]                    ; A=00010000000001 C=04567000000000
07433: p - 1 -> p                          ; P= 8
07434: c -> a[w]                           ; A=04567000000000
07435: c - 1 -> c[wp]                      ; C=04567FFFFFFFFF
07436: a exchange c[x]                     ; A=04567000000FFF C=04567FFFFFF000
07437: if a[m] # 0 then goto 01465         ;
07465: jsb 0067                            ;

; looks like it adjusts exponent for precision (f) and
; normalizes - don't want C[12] (first digit) =0
07467: a exchange b[x]                     ; A=04567000000001 B=04560000000FFF
07470: decimal                             ;
07471: 0 -> a[x]                           ; A=04567000000000
07472: f -> a                              ; A=04567000000001 (f still 1)
07473: a + c -> c[x]                       ; C=04567FFFFFF001 "45.67 blanks"
07474: p <- 12                             ; P=12
07475: if c[p] # 0 then goto 01505         ; mantissa in range 1-9, ok
07505: a exchange b[x]                     ; A=04567000000FFF B=04560000000001
07506: binary                              ;
07507: return                              ;

07466: if n/c goto 0041                    ;
07441: a exchange c[ms]                    ; A=04567FFFFFFFFF C=04567000000001
07442: b exchange c[w]                     ; B=04567000000001 C=04560000000001
07443: b -> c[w]                           ; C=04567000000001
; A is displayable. B & C have X value
07444: jsb 0203                            ;

; save display value and info in ram[30]
07603: ...                                 ; ram[30]=14567FFFFFFFF1 dot_pressed e1
       ...                                 ; A=04567FFFFFFFF1 C=04567000000011 P= 0
07626: return                              ;

07445: ...                                 ; B->C, C=04567000000001
07747: ...                                 ; B->C, C->ram[47], P= 0
00323: ...                                 ; B->C, ram[47]->B, P= 0
00115: ...                                 ;
01167: ...                                 ; clear prefixes (s 4,6,7,8,10) and s0,13,14

00120: ...

; A=04567FFFFFFFF1 B=04567000000001 C=04567000000001 
; M1=04560000000017 S=...3.5...9..C..F f=1

00124: ...
; M1=04567000000001
; C=04567000000001 B=20900000000000 A=04567FFFFFFF00 P=11

00144: cpu woodstock                       ;
00145: display off                         ;
00146: display toggle                      ;
00147: 0 -> s 15                           ; S=...3.5...9..C...
00150: if 1 = s 15 then goto 00147         ;
00152: ...

That was a summary. The real thing (45dot67.txt) is even longer.

I’ve also skipped what happens if you start with dot, press CHS in the middle of the above, or press EEX.

It's only fair to share...Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUponDigg thisPin on PinterestEmail this to someone

Leave a Reply

Your email address will not be published. Required fields are marked *