annotate lib/alib/div16x16.a @ 2474:7d70b7e1cb21

Moved net and alib files into here
author boisy
date Tue, 30 Mar 2010 02:44:42 +0000
parents
children aaba193af04f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2474
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
1 *********************************************
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
2 * 16 x 16 bit integer divide
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
3
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
4 * OTHER MODULES NEEDED: none
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
5
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
6 * ENTRY: D = divisor
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
7 * X = dividend
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
8
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
9 * EXIT: X = quotient
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
10 * D = remainder
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
11
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
12 nam 16x16 bit Divide
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
13 ttl Assembler Library Module
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
14
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
15
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
16 psect DIV16,0,0,0,0,0
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
17
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
18 vsect
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
19 negcount rmb 1
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
20 endsect
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
21
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
22 * Signed Divide
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
23 SDIV16:
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
24 clr negcount,u
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
25 PSHS D,X
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
26 tst ,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
27 bpl testquo
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
28 ldd ,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
29 comb
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
30 coma
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
31 addd #$0001
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
32 std ,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
33 inc negcount,u
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
34 testquo
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
35 tst 2,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
36 bpl ok
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
37 ldd 2,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
38 comb
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
39 coma
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
40 addd #$0001
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
41 std 2,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
42 inc negcount,u
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
43 ok
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
44 puls d,x
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
45 bsr DIV16
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
46 dec negcount,u
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
47 bne goforit
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
48 pshs d,x
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
49 ldd ,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
50 coma
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
51 comb
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
52 addd #$0001
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
53 std ,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
54 ldd 2,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
55 coma
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
56 comb
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
57 addd #$0001
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
58 std 2,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
59 puls d,x
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
60 goforit
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
61 rts
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
62
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
63
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
64 * Unsigned Divide
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
65 DIV16:
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
66 PSHS D,X save divisor & dividend
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
67 LDA #16 bit counter
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
68 PSHS A
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
69 CLRA initialize remainder
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
70 CLRB
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
71
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
72 div1
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
73 ASL 4,S shift dividend & quotient
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
74 ROL 3,S
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
75 ROLB shift dividend into B
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
76 ROLA
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
77 CMPD 1,S trial subtraction reqd?
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
78 BLO div2
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
79 SUBD 1,S yes, do subtraction
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
80 INC 4,S increment quotient
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
81
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
82 div2
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
83 DEC ,S count down another bit
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
84 BNE div1
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
85 LDX 3,S get quotient
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
86 LEAS 5,S clean stack
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
87 RTS
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
88
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
89 endsect
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
90