annotate 3rdparty/packages/basic09/basic09.real.mul.63.asm @ 477:7a5d3fcbe2d8

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