477
|
1 * Main routine for REAL multiply - 6809 version
|
|
2 L40D3 pshs x Preserve X
|
|
3 lda 2,y Get 1st byte of mantissa
|
|
4 bpl L40DD If mantissa is in lower range, force result to 0
|
|
5 lda 8,y Get 1st byte of mantissa from 2nd number
|
|
6 bmi L40E9 If in upper range, go do multiply
|
|
7 L40DD clra
|
|
8 clrb
|
|
9 std 7,y Save 0 as result
|
|
10 std 9,y
|
|
11 sta $B,y
|
|
12 leay 6,y Eat temp var
|
|
13 puls pc,x
|
|
14
|
|
15 * Check for possible over/underflows before doing multiply
|
|
16 L40E9 lda 1,y Get exponent from temp var
|
|
17 adda 7,y Add to exponent from 1st var
|
|
18 bvc L40F6 If within 8 bit range, go do multiply
|
|
19 L40EF bpl L40DD If resulting exponent is too small, result=0
|
|
20 comb Resulting exponent too big, exit with
|
|
21 ldb #$32 Floating overflow error
|
|
22 puls pc,x
|
|
23
|
|
24 * Exponent possibly in range, process
|
|
25 L40F6 sta 7,y Save resultant exponent overtop 1st vars
|
|
26 ldb $B,y Get sign bit of 2nd #
|
|
27 eorb 5,y EOR with sign bit of 1st #
|
|
28 andb #$01 Only keep resulting sign bit
|
|
29 stb ,y Save what sign of result will be
|
|
30 lda $B,y Now, for actual multiply, force to positive
|
|
31 anda #$FE
|
|
32 sta $B,y
|
|
33 ldb 5,y Force both mantissa's to positive
|
|
34 andb #$FE
|
|
35 stb 5,y
|
|
36 * Possible 32x32 bit multiply routine?
|
|
37 mul Multiply LSB's together
|
|
38 sta ,-s Save MSB of result only (drop LSB)
|
|
39 clr ,-s And make 2 zero hi-bytes (result is 3 byte #)
|
|
40 clr ,-s
|
|
41 lda $B,y LSB * 2nd LSB
|
|
42 ldb 4,y
|
|
43 mul
|
|
44 addd 1,s Add to previous #
|
|
45 std 1,s
|
|
46 bcc L4120 No carry required, skip ahead
|
|
47 inc ,s
|
|
48 L4120 lda $A,y 2nd LSB * LSB
|
|
49 ldb 5,y
|
|
50 mul
|
|
51 addd 1,s Add with carry to previous #
|
|
52 std 1,s
|
|
53 bcc L412D
|
|
54 inc ,s
|
|
55 L412D ldx ,s Done 16x8 multiply, now just keep MSW
|
|
56 stx 1,s
|
|
57 clr ,s Zero out hi-byte in 3 byte #
|
|
58 lda $B,y
|
|
59 ldb 3,y
|
|
60 mul
|
|
61 addd 1,s
|
|
62 std 1,s
|
|
63 bcc L4142
|
|
64 inc ,s
|
|
65 L4142 lda $0A,y
|
|
66 ldb $04,y
|
|
67 mul
|
|
68 addd $01,s
|
|
69 std $01,s
|
|
70 bcc L414F
|
|
71 inc ,s
|
|
72 L414F lda $09,y
|
|
73 ldb $05,y
|
|
74 mul
|
|
75 addd 1,s
|
|
76 std 1,s
|
|
77 bcc L415C
|
|
78 inc ,s
|
|
79 L415C ldb 2,s
|
|
80 ldx ,s
|
|
81 stx 1,s
|
|
82 clr ,s
|
|
83 lda $B,y
|
|
84 ldb $2,y
|
|
85 mul
|
|
86 addd 1,s
|
|
87 std 1,s
|
|
88 bhs L4171
|
|
89 inc ,s
|
|
90 L4171 lda $A,y
|
|
91 ldb $3,y
|
|
92 mul
|
|
93 addd 1,s
|
|
94 std 1,s
|
|
95 bhs L417E
|
|
96 inc ,s
|
|
97 L417E lda 9,y
|
|
98 ldb 4,y
|
|
99 mul
|
|
100 addd 1,s
|
|
101 std 1,s
|
|
102 bhs L418B
|
|
103 inc ,s
|
|
104 L418B lda $08,y
|
|
105 ldb $05,y
|
|
106 mul
|
|
107 addd $01,s
|
|
108 std $01,s
|
|
109 bhs L4198
|
|
110 inc ,s
|
|
111 L4198 ldb $02,s
|
|
112 ldx ,s
|
|
113 stx $01,s
|
|
114 clr ,s
|
|
115 stb $0B,y
|
|
116 lda $0A,y
|
|
117 ldb $02,y
|
|
118 mul
|
|
119 addd $01,s
|
|
120 std $01,s
|
|
121 bcc L41AF
|
|
122 inc ,s
|
|
123 L41AF lda $09,y
|
|
124 ldb $03,y
|
|
125 mul
|
|
126 addd $01,s
|
|
127 std $01,s
|
|
128 bcc L41BC
|
|
129 inc ,s
|
|
130 L41BC lda $08,y
|
|
131 ldb $04,y
|
|
132 mul
|
|
133 addd $01,s
|
|
134 std $01,s
|
|
135 bcc L41C9
|
|
136 inc ,s
|
|
137 L41C9 ldb $02,s
|
|
138 ldx ,s
|
|
139 stx $01,s
|
|
140 clr ,s
|
|
141 stb $0A,y
|
|
142 lda $09,y
|
|
143 ldb $02,y
|
|
144 mul
|
|
145 addd $01,s
|
|
146 std $01,s
|
|
147 bcc L41E0
|
|
148 inc ,s
|
|
149 L41E0 lda $08,y
|
|
150 ldb $03,y
|
|
151 mul
|
|
152 addd $01,s
|
|
153 std $01,s
|
|
154 bcc L41ED
|
|
155 inc ,s
|
|
156 L41ED lda $08,y
|
|
157 ldb $02,y
|
|
158 mul
|
|
159 addd ,s
|
|
160 bmi L4202
|
|
161 lsl $0B,y
|
|
162 rol $0A,y
|
|
163 rol $02,s
|
|
164 rolb
|
|
165 rola
|
|
166 dec 7,y
|
|
167 bvs L421B
|
|
168 L4202 std 8,y
|
|
169 lda 2,s
|
|
170 ldb $A,y
|
|
171 addd #$0001
|
|
172 bcc L4220
|
|
173 inc 9,y
|
|
174 bne L4222
|
|
175 inc 8,y
|
|
176 bne L4222
|
|
177 ror 8,y
|
|
178 inc 7,y
|
|
179 bvc L4222
|
|
180 L421B leas 3,s
|
|
181 lbra L40EF
|
|
182
|
|
183 L4220 andb #$FE
|
|
184 L4222 orb ,y
|
|
185 std $A,y
|
|
186 leay 6,y
|
|
187 leas 3,s
|
|
188 clrb No error, restore & return
|
|
189 puls pc,x
|