annotate lib/alib/bin_dec.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 *
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
3 * Binary to decimal conversion
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
4
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
5 * OTHER MODULES NEEDED: DECTAB$
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
6
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
7 * ENTRY: X=buffer for ascii string
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
8 * D=binary value to convert
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
9
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
10 * EXIT: all registers (except cc) preserved
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 * BGP - 04/11/2009 - Fixed issue where BIN_DEC was printing negative
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
13 * sign in certain cases. Cleared nega flag to fix issue.
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 nam Binary to Decimal Conversion
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
16 ttl Assembler Library Module
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
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
19 psect BIN_DEC,0,0,0,0,0
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
20
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
21 vsect
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
22 nega rmb 1
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
23 endsect
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
24
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
25 BIN_SDEC:
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
26 clr nega,u
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
27 tsta
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
28 bpl BIN_DEC
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
29 sta nega,u
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
30 comb
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
31 coma
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
32 addd #$0001
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
33 bra BIN_DEC_COMMON +++ added BGP
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
34
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
35 BIN_DEC:
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
36 clr nega,u +++ added BGP
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
37 BIN_DEC_COMMON
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
38 pshs a,b,x,y
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
39 lda #7 clear out 7 bytes in buffer
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
40
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
41 bindc1
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
42 clr ,x+
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
43 deca
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
44 bne bindc1
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
45 ldx 2,s restore buffer start address
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
46 ldd ,s get data
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
47 bne bindc2 not 0, do convert
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
48 lda #'0
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
49 sta ,x
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
50 bra bindc8 exit
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
51
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
52 bindc2
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
53 tst nega,u
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
54 beq bindc25
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
55 pshs a
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
56 lda #'-
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
57 sta ,x+
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
58 puls a
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
59 bindc25
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
60 leay DECTAB$,pcr point to conversion table
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
61 clr ,--s temps, flag 1st dgt not placed
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 bindc3
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
64 clr 1,s current digit=0
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
65
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
66 bindc4
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
67 subd ,y sub table element
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
68 bcs bindc5 too far, correct
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
69 inc 1,s bump digit
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
70 bra bindc4 loop til done
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 bindc5
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
73 addd ,y restore, 1 too many subtracts
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
74 pshs a,b save rest of number
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
75 lda 3,s get the digit
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
76 adda #$30 make it ascii
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
77 cmpa #'0 is it zero?
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
78 bne bindc6 no, skip
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
79 tst 2,s is it 1st digit in string?
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
80 beq bindc7 yes, don't do leading 0s
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 bindc6
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
83 inc 2,s indidicate at least 1 digit
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
84 sta ,x+ save in buffer
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
85
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
86 bindc7
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
87 leay 2,y next table entry
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
88 tst 1,y end of table
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
89 puls a,b restore data
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
90 bne bindc3 no..loop
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
91 leas 2,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
92
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
93 bindc8
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
94 puls a,b,x,y,pc restore and return
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
95
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
96 endsect
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
97