2474
|
1 ************************************
|
|
2
|
|
3 * 16 x 16 Multiply
|
|
4
|
|
5 * ENTRY: D = multiplier
|
|
6 * X = multiplicand
|
|
7
|
|
8 * EXIT: Y = product 2 msbs
|
|
9 * U = " 2 lsbs
|
|
10 * D & X preserved
|
|
11
|
|
12 nam 16x16 bit Multiply
|
|
13 ttl Assembler Library Module
|
|
14
|
|
15
|
|
16 psect MULT16,0,0,0,0,0
|
|
17
|
|
18 MULT16:
|
|
19 PSHS D,X,Y,U save #s and make stack room
|
|
20 CLR 4,S reset overflow flag
|
|
21 LDA 3,S get byte
|
|
22 MUL
|
|
23 STD 6,S save B x Xl
|
|
24 LDD 1,S
|
|
25 MUL B x Xh
|
|
26 ADDB 6,S
|
|
27 ADCA #0
|
|
28 STD 5,S add 1st 2 mult.
|
|
29 LDB 0,S
|
|
30 LDA 3,S
|
|
31 MUL A x Xl
|
|
32 ADDD 5,S
|
|
33 STD 5,S add result to previous
|
|
34 BCC no.ov branch if no overflow
|
|
35 INC 4,S set overflow flag
|
|
36
|
|
37 no.ov
|
|
38 LDA 0,S
|
|
39 LDB 2,S
|
|
40 MUL A x Xh
|
|
41 ADDD 4,S
|
|
42 STD 4,S
|
|
43 PULS D,X,Y,U,PC return
|
|
44
|
|
45 endsect
|
|
46
|
|
47 |