477
|
1 * Main routine for REAL multiply - 6309 version
|
|
2 * 08/07/95 - Change L40DD to use CLRD/CLRW/STQ (Saves 1 cycle)
|
|
3 * - Changed entire routine as per Chris Dekker's RunB
|
|
4 * 08/08/95 - Took out PSHS/PULS X
|
|
5 L40D3 lda 2,y Get 1st byte of mantissa
|
|
6 bpl L40DD If mantissa is in lower range, force result to 0
|
|
7 lda 8,y Get 1st byte of mantissa from 2nd number
|
|
8 bmi L40E9 If in upper range, go do multiply
|
|
9 L40DD clrd Force REAL result to 0
|
|
10 clrw
|
|
11 stq 7,y Save 0 as result
|
|
12 sta $B,y
|
|
13 leay 6,y Eat temp var & return
|
|
14 rts
|
|
15
|
|
16 * Check for possible over/underflows before doing multiply
|
|
17 L40E9 lda 1,y Get exponent from temp var
|
|
18 adda 7,y Add to exponent from 1st var
|
|
19 bvc L40F6 If within 8 bit range, go do multiply
|
|
20 L40EF bpl L40DD If resulting exponent is too small, result=0
|
|
21 comb Resulting exponent too big, exit with
|
|
22 ldb #$32 Floating overflow error
|
|
23 rts
|
|
24
|
|
25 * Exponent possibly in range, process
|
|
26 L40F6 sta 7,y Save resultant exponent overtop 1st vars
|
|
27 ldb $B,y Get sign bit of 2nd #
|
|
28 eorb 5,y EOR with sign bit of 1st #
|
|
29 andb #$01 Only keep resulting sign bit
|
|
30 stb ,y Save what sign of result will be
|
|
31 lda $B,y Now, for actual multiply, force to positive
|
|
32 anda #$FE
|
|
33 sta $B,y
|
|
34 ldb 5,y Force both mantissa's to positive
|
|
35 andb #$FE
|
|
36 stb 5,y
|
|
37 * Possible 32x32 bit multiply routine?
|
|
38 mul Multiply LSB's together
|
|
39 clre
|
|
40 clr <u0014 Clear out 3rd byte to keep track of
|
|
41 tfr a,f Save MSB into middle byte
|
|
42 lda $B,y LSB * 2nd LSB
|
|
43 ldb 4,y
|
|
44 mul
|
|
45 addr d,w Add to previous #
|
|
46 bcc L4120 No carry required, skip ahead
|
|
47 inc <u0014
|
|
48 L4120 lda $A,y 2nd LSB * LSB
|
|
49 ldb 5,y
|
|
50 mul
|
|
51 addr d,w Add to previous #
|
|
52 bcc L412D
|
|
53 inc <u0014
|
|
54 L412D tfr e,f
|
|
55 lde <u0014
|
|
56 clr <u0014
|
|
57 lda $B,y
|
|
58 ldb 3,y
|
|
59 mul
|
|
60 addr d,w Add to previous #
|
|
61 bcc L4142
|
|
62 inc <u0014
|
|
63 L4142 lda $A,y
|
|
64 ldb 4,y
|
|
65 mul
|
|
66 addr d,w Add to previous #
|
|
67 bcc L414F
|
|
68 inc <u0014
|
|
69 L414F lda 9,y
|
|
70 ldb 5,y
|
|
71 mul
|
|
72 addr d,w Add to previous #
|
|
73 bcc L415C
|
|
74 inc <u0014
|
|
75 L415C tfr e,f
|
|
76 lde <u0014
|
|
77 clr <u0014
|
|
78 lda $B,y
|
|
79 ldb 2,y
|
|
80 mul
|
|
81 addr d,w Add to previous #
|
|
82 bcc L4171
|
|
83 inc <u0014
|
|
84 L4171 lda $A,y
|
|
85 ldb $3,y
|
|
86 mul
|
|
87 addr d,w Add to previous #
|
|
88 bcc L417E
|
|
89 inc <u0014
|
|
90 L417E lda 9,y
|
|
91 ldb 4,y
|
|
92 mul
|
|
93 addr d,w Add to previous #
|
|
94 bcc L418B
|
|
95 inc <u0014
|
|
96 L418B lda 8,y
|
|
97 ldb 5,y
|
|
98 mul
|
|
99 addr d,w Add to previous #
|
|
100 bcc L4198
|
|
101 inc <u0014
|
|
102 L4198 stf $B,y
|
|
103 tfr e,f
|
|
104 lde <u0014
|
|
105 clr <u0014
|
|
106 lda $A,y
|
|
107 ldb 2,y
|
|
108 mul
|
|
109 addr d,w Add to previous #
|
|
110 bcc L41AF
|
|
111 inc <u0014
|
|
112 L41AF lda 9,y
|
|
113 ldb 3,y
|
|
114 mul
|
|
115 addr d,w Add to previous #
|
|
116 bcc L41BC
|
|
117 inc <u0014
|
|
118 L41BC lda 8,y
|
|
119 ldb 4,y
|
|
120 mul
|
|
121 addr d,w Add to previous #
|
|
122 bcc L41C9
|
|
123 inc <u0014
|
|
124 L41C9 stf $A,y
|
|
125 tfr e,f
|
|
126 lde <u0014
|
|
127 clr <u0014
|
|
128 lda 9,y
|
|
129 ldb 2,y
|
|
130 mul
|
|
131 addr d,w Add to previous #
|
|
132 bcc L41E0
|
|
133 inc <u0014
|
|
134 L41E0 lda 8,y
|
|
135 ldb 3,y
|
|
136 mul
|
|
137 addr d,w Add to previous #
|
|
138 bcc L41ED
|
|
139 inc <u0014
|
|
140 L41ED lda 8,y
|
|
141 ldb 2,y
|
|
142 mul
|
|
143 tfr w,u
|
|
144 tfr e,f
|
|
145 lde <u0014
|
|
146 exg d,u
|
|
147 addr u,w
|
|
148 bmi L4202
|
|
149 asl $B,y
|
|
150 rol $A,y
|
|
151 rolb
|
|
152 rolw
|
|
153 dec 7,y
|
|
154 bvs L421B
|
|
155
|
|
156 L4202 tfr b,a
|
|
157 ldb $A,y
|
|
158 exg d,w
|
|
159 addw #1
|
|
160 adcd #0
|
|
161 bne L421B
|
|
162 rora
|
|
163 inc 7,y
|
|
164 L421B exg d,w
|
|
165 lsrb Clear sign bit
|
|
166 lslb
|
|
167 orb ,y Merge resultant sign bit
|
|
168 std $A,y
|
|
169 stw 8,y
|
|
170 leay 6,y
|
|
171 clrb No error, restore & return
|
|
172 rts
|