-
Notifications
You must be signed in to change notification settings - Fork 82
/
code22.src
183 lines (178 loc) · 1.94 KB
/
code22.src
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
.page
.subttl 'code22'
n0999 .byte $9b,$3e,$bc,$1f,$fd
n9999 .byte $9e,$6e,$6b,$27,$fd
nmil .byte $9e,$6e,$6b,$28,$00
inprt
jsr primm
.byte ' IN ', 0
curprt
lda curlin+1
ldx curlin
linprt
sta facho
stx facho+1
ldx #@220
sec
jsr floatc
jsr foutc
jmp strout
fout
ldy #1
foutc
lda #' ' ;if positive, print space
bit facsgn
bpl fout1
lda #'-' ;if neg
fout1
sta fbuffr-1,y
sta facsgn
sty fbufpt
iny
lda #'0' ;get zero to type if fac = 0
ldx facexp
bne *+5
jmp fout19
lda #0
cpx #@200 ;is number < 1?
beq fout37 ;no
bcs fout7
fout37
lda #<nmil ;mult by 10~6
ldy #>nmil
jsr rommlt
lda #250-addpr2-addprc
fout7
sta deccnt
fout4
lda #<n9999
ldy #>n9999
jsr fcomp
beq bigges
bpl fout9
fout3
lda #<n0999
ldy #>n0999
jsr fcomp
beq fout38
bpl fout5
fout38
jsr mul10
dec deccnt
bne fout3
fout9
jsr div10
inc deccnt
bne fout4
fout5
jsr faddh
bigges
jsr qint
ldx #1
lda deccnt
clc
adc #addpr2+addprc+7
bmi foutpi
cmp #addpr2+addprc+@10
bcs fout6
adc #$ff
tax
lda #2
foutpi
sec
fout6
sbc #2
sta tenexp
stx deccnt
txa
beq fout39
bpl fout8
fout39
ldy fbufpt
lda #'.'
iny
sta fbuffr-1,y
txa
beq fout16
lda #'0'
iny
sta fbuffr-1,y
fout16
sty fbufpt
fout8
ldy #0
foutim
ldx #@200
fout2
lda faclo
clc
adc foutbl+2+addprc,y
sta faclo
lda facmo
adc foutbl+1+addprc,y
sta facmo
lda facmoh
adc foutbl+1,y
sta facmoh
lda facho
adc foutbl,y
sta facho
inx
bcs fout41
bpl fout2
bmi fout40
fout41
bmi fout2
fout40
txa
bcc foutyp
eor #@377
adc #@12
foutyp
adc #@57
iny
iny
iny
iny
sty fdecpt
ldy fbufpt
iny
tax
and #@177
sta fbuffr-1,y
dec deccnt
bne stxbuf
lda #'.'
iny
sta fbuffr-1,y
stxbuf
sty fbufpt
ldy fdecpt
txa
eor #@377
and #@200
tax
cpy #fdcend-foutbl
beq fouldy
cpy #timend-foutbl
bne fout2
fouldy
ldy fbufpt
fout11
lda fbuffr-1,y
dey
cmp #'0'
beq fout11
cmp #'.'
beq fout12
iny
fout12
lda #'+'
ldx tenexp
beq fout17
bpl fout14
lda #0
sec
sbc tenexp
tax
;.end