-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathcode19
212 lines (212 loc) · 2.37 KB
/
code19
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
.PAG 'CODE19'
LOG JSR SIGN
BEQ LOGERR
BPL LOG1
LOGERR JMP FCERR
LOG1 LDA FACEXP
SBC #@177
PHA
LDA #@200
STA FACEXP
LDA #<SQR05
LDY #>SQR05
JSR FADD
LDA #<SQR20
LDY #>SQR20
JSR FDIV
LDA #<FONE
LDY #>FONE
JSR FSUB
LDA #<LOGCN2
LDY #>LOGCN2
JSR POLYX
LDA #<NEGHLF
LDY #>NEGHLF
JSR FADD
PLA
JSR FINLOG
LDA #<LOG2
LDY #>LOG2
FMULT JSR CONUPK
FMULTT BEQ MULTRT
JSR MULDIV
LDA #0
STA RESHO
STA RESMOH
STA RESMO
STA RESLO
LDA FACOV
JSR MLTPLY
LDA FACLO
JSR MLTPLY
LDA FACMO
JSR MLTPLY
LDA FACMOH
JSR MLTPLY
LDA FACHO
JSR MLTPL1
JMP MOVFR
MLTPLY BNE *+5
JMP MULSHF
MLTPL1 LSR A
ORA #@200
MLTPL2 TAY
BCC MLTPL3
CLC
LDA RESLO
ADC ARGLO
STA RESLO
LDA RESMO
ADC ARGMO
STA RESMO
LDA RESMOH
ADC ARGMOH
STA RESMOH
LDA RESHO
ADC ARGHO
STA RESHO
MLTPL3 ROR RESHO
ROR RESMOH
ROR RESMO
ROR RESLO
ROR FACOV
TYA
LSR A
BNE MLTPL2
MULTRT RTS
CONUPK STA INDEX1
STY INDEX1+1
LDY #4
LDA (INDEX1)Y
STA ARGLO
DEY
LDA (INDEX)Y
STA ARGMO
DEY
LDA (INDEX1)Y
STA ARGMOH
DEY
LDA (INDEX1)Y
STA ARGSGN
EOR FACSGN
STA ARISGN
LDA ARGSGN
ORA #@200
STA ARGHO
DEY
LDA (INDEX1)Y
STA ARGEXP
LDA FACEXP
RTS
MULDIV LDA ARGEXP
MLDEXP BEQ ZEREMV
CLC
ADC FACEXP
BCC TRYOFF
BMI GOOVER
CLC
.BYT $2C
TRYOFF BPL ZEREMV
ADC #@200
STA FACEXP
BNE *+5
JMP ZEROML
LDA ARISGN
STA FACSGN
RTS
MLDVEX LDA FACSGN
EOR #@377
BMI GOOVER
ZEREMV PLA
PLA
JMP ZEROFC
GOOVER JMP OVERR
MUL10 JSR MOVAF
TAX
BEQ MUL10R
CLC
ADC #2
BCS GOOVER
FINML6 LDX #0
STX ARISGN
JSR FADDC
INC FACEXP
BEQ GOOVER
MUL10R RTS
TENC .BYT @204,@40,0,0,0
DIV10 JSR MOVAF
LDA #<TENC
LDY #>TENC
LDX #0
FDIVF STX ARISGN
JSR MOVFM
JMP FDIVT
FDIV JSR CONUPK
FDIVT BEQ DV0ERR
JSR ROUND
LDA #0
SEC
SBC FACEXP
STA FACEXP
JSR MULDIV
INC FACEXP
BEQ GOOVER
LDX #$FC
LDA #1
DIVIDE LDY ARGHO
CPY FACHO
BNE SAVQUO
LDY ARGMOH
CPY FACMOH
BNE SAVQUO
LDY ARGMO
CPY FACMO
BNE SAVQUO
LDY ARGLO
CPY FACLO
SAVQUO PHP
ROL A
BCC QSHFT
INX
STA RESLO,X
BEQ LD100
BPL DIVNRM
LDA #1
QSHFT PLP
BCS DIVSUB
SHFARG ASL ARGLO
ROL ARGMO
ROL ARGMOH
ROL ARGHO
BCS SAVQUO
BMI DIVIDE
BPL SAVQUO
DIVSUB TAY
LDA ARGLO
SBC FACLO
STA ARGLO
LDA ARGMO
SBC FACMO
STA ARGMO
LDA ARGMOH
SBC FACMOH
STA ARGMOH
LDA ARGHO
SBC FACHO
STA ARGHO
TYA
JMP SHFARG
LD100 LDA #@100
BNE QSHFT
DIVNRM ASL A
ASL A
ASL A
ASL A
ASL A
ASL A
STA FACOV
PLP
JMP MOVFR
DV0ERR LDX #ERRDVO
JMP ERROR
.FIL CODE20