annotate lib/alib/div16x8.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 8 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 * Result must be an 8 bit value
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: A = 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: A = remainder
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
10 * B = quotient
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
11 * all other registers (except CC) preserved
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
12
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
13 nam 16x8 bit Divide
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
14 ttl Assembler Library Module
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
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
17 psect DIV168,0,0,0,0,0
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
18
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
19 vsect
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
20 negcount rmb 1
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
21 endsect
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
22
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
23 * Signed Divide
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
24 SDIV168:
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
25 clr negcount,u
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
26 PSHS A,X
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
27 tst ,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
28 bpl testquo
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
29 lda ,s
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 inca
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
32 sta ,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 1,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 1,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 1,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 a,x
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
45 bsr DIV168
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 a,x
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
49 lda ,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 inca
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
52 sta ,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
53 ldd 1,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
54 coma
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
55 comb
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
56 addd #$0001
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
57 std 1,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
58 puls a,x
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
59 goforit
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
60 rts
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
61
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 DIV168:
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
64 LDB #8 bit counter
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
65 PSHS A,B,X save count and divisor and value
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
66 TFR X,D put dividend in D
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
67
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
68 div1
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
69 ASLB shift dividend and quotient
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
70 ROLA
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
71 CMPA 0,S is trial subtraction successful?
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
72 BCS div2
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
73 SUBA 0,S yes, subtract and set bit
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
74 INCB in quotient
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
75
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
76 div2
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
77 DEC 1,S count down bits
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
78 BNE div1 loop till done
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
79 LEAS 2,S clean stack
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
80 PULS X,PC return
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 endsect
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
83