annotate lib/alib/dec_bin.a @ 2652:32908c617568

Now pressing a key quits demo sound temporarily rts's until we figure out PIC code
author Boisy Pitre <boisy.pitre@nuance.com>
date Mon, 02 Apr 2012 21:54:25 -0500
parents 7d70b7e1cb21
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 * DECIMAL to BINARY conversion routine
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$, IS_TERMIN
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 = start of asci decimal string terminated by
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
8 * a space, comma, CR or null.
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: D = binary value
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
11 * CC carry set if error (too large, not numeric)
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
12 * Y = terminator or error char.
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
13
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
14 nam Convert Decimal String to Binary
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
15 ttl Assembler Library Module
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
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
18 psect DEC_BIN,0,0,0,0,0
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
19
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
20 vsect
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
21 nega rmb 1
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
22 endsect
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
23
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
24 DEC_BIN:
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
25 clra set result to 0
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
26 clrb
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
27 pshs a,b,x
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
28 leas -1,s temp variable
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
29
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
30 clr nega,u
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
31 ldb ,x+
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
32 cmpb #'-
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
33 bne decbn15
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
34 stb nega,u
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
35 decbn1
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
36 LDB ,X+ get a digit
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
37 decbn15
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
38 LBSR IS_DIGIT
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
39 bne decbn3 end of string...
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
40 INCA bump string len
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
41 BRA decbn1 loop for whole string
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
42
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
43 decbn3
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
44 lbsr IS_TERMIN valid terminator?
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
45 bne error
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
46
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
47 ok
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
48 TSTA length = 0?
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
49 BEQ error yes, error
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
50 CMPA #6 more than 6 chars?
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
51 BHI error yes, error
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
52
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
53 ldx 3,s get start of string again
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
54
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 ,x
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
57 cmpa #'-
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
58 bne decbn35
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
59 leax 1,x
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
60 decbn35
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
61 LDA #5 max length
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
62 SUBA ,S+ adjust for offset
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
63 ASLA 2 bytes per table entry
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
64 LEAY DECTAB$,PCR addr of conversion table
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
65 LEAY A,Y add in offset for actual len
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
66
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
67 decbn4
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
68 LDA ,X+ get a digit
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
69 SUBA #$30 strip off ASCII
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
70 BEQ decbn6 zero, skip
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
71 sta ,s save digit=# of adds
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
72 LDD 1,S get binary data
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
73
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
74 decbn5
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
75 ADDD ,Y add in table value
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
76 BCS error past 0, too big
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
77 DEC ,S count down digit size
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
78 BNE decbn5 loop til 0
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
79 STD 1,S save binary data
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
80
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 decbn6
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
83 LEAY 2,Y next entry
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
84 tst 1,y end of table?
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
85 BNE decbn4 loop til done
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
86 clr ,s+ clean up and clear carry
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
87 bra exit
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
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
90 error
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
91 clr 0,s force data = 0
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
92 clr 1,s
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
93 com ,s+ clean up and set carry
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
94
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
95 exit
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
96 tfr x,y end of string/error char
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
97 puls a,b,x
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
98 bcs leave
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
99 tst nega,u
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
100 beq leave
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
101 subd #$0001
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
102 coma
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
103 comb
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
104 andcc #$FE
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
105 leave
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
106 rts
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
107
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
108
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
109 endsect
7d70b7e1cb21 Moved net and alib files into here
boisy
parents:
diff changeset
110