File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4545 jsr get_str_eol
4646 jsr read_word
4747 bcc :+
48- lda #18
49- sta IOERROR
48+ ldy #18
49+ sty IOERROR
5050: jmp next_instruction
5151.endproc
5252
@@ -57,10 +57,6 @@ SKBLANK = $DBA1
5757 ; Skips white space at start
5858 jsr SKBLANK
5959
60- ; Clears result
61- ldx #0
62- stx tmp1
63-
6460 ; Reads a '+' or '-'
6561 lda (INBUFF), y
6662 cmp #'+'
@@ -77,34 +73,39 @@ SKBLANK = $DBA1
7773skip: iny
7874convert:
7975 sty tmp2+1 ; Store starting Y position - used to check if read any digits
76+ ; Clears result
77+ lda #0
78+ tax
8079loop:
80+ ; Store A/X
81+ sta tmp1
82+ stx tmp1+1
83+
8184 ; Reads one character
8285 lda (INBUFF), y
8386 sec
8487 sbc #'0'
8588 cmp #10
89+ sta tmp2 ; save digit
90+ lda tmp1 ; and restore A
91+
8692 bcs xit_n ; Not a number
8793
8894 iny ; Accept
8995
90- sta tmp2 ; and save digit
96+ cpx #26 ; Reject numbers > $1A00 (6656)
97+ bcs ebig
9198
9299 ; Multiply "tmp1" by 10 - uses A,X, keeps Y
93- lda tmp1
94- stx tmp1+1
95-
96100 asl
97101 rol tmp1+1
98- bcs ebig
99102 asl
100103 rol tmp1+1
101- bcs ebig
102104
103105 adc tmp1
104106 sta tmp1
105107 txa
106108 adc tmp1+1
107- bcs ebig
108109
109110 asl tmp1
110111 rol a
@@ -114,7 +115,6 @@ loop:
114115 ; Add new digit
115116 lda tmp2
116117 adc tmp1
117- sta tmp1
118118 bcc loop
119119 inx
120120 bne loop
@@ -124,9 +124,8 @@ ebig:
124124xit: rts
125125
126126xit_n: cpy tmp2+1
127- beq ebig ; No digits read
127+ beq xit ; No digits read
128128
129- lda tmp1
130129 clc
131130 rts
132131.endproc
Original file line number Diff line number Diff line change @@ -8,6 +8,10 @@ input "Prompt:", a
88? err (), a
99input a
1010? err (), a
11+ input a
12+ ? err (), a
13+ input a
14+ ? err (), a
1115input s$
1216? err (), s $
1317input s$
Original file line number Diff line number Diff line change 552345
663456
77
8+ 65535
9+ 65536
810hello
911.
1012Output:
1113Start
1214?1 1234
13151 2345
1416Prompt: 1 3456
15- ?18 18
17+ ?18 0
18+ ?1 -1
19+ ?18 0
1620?1 hello
1721?136
You can’t perform that action at this time.
0 commit comments