Mercurial > hg > Members > kono > nitros9-code
comparison lib/alib/bin_asc.as @ 2783:03f26e88b809 lwtools-port
Renamed files and setup for lwasm/lwlink work
author | Boisy Pitre <boisy.pitre@nuance.com> |
---|---|
date | Sat, 26 Jan 2013 17:18:24 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
2782:aaba193af04f | 2783:03f26e88b809 |
---|---|
1 ****************************************** | |
2 | |
3 * Binary word to ASCII string conversion | |
4 | |
5 * OTHER MODULES NEEDED: none | |
6 | |
7 * ENTRY: D = binary value | |
8 * X = buffer for 16 bit number | |
9 | |
10 * EXIT: all registers (except cc) preserved | |
11 | |
12 nam Convert # to Ascii String | |
13 ttl Assembler Library Module | |
14 | |
15 | |
16 section .text | |
17 | |
18 BIN_ASC: | |
19 pshs a,b,x save registers | |
20 pshs a,b save data again | |
21 ldb #16 total bits to convert | |
22 andcc #%11111110 clear CARRY to start | |
23 | |
24 binas1 | |
25 lda #'0 get ASCII 0 | |
26 rol 1,S get hi bit in LSB to carry | |
27 rol ,S and into MSB; is it 1 or 0? | |
28 bcc binas2 0, skip | |
29 inca get ASCII 1 | |
30 | |
31 binas2 | |
32 sta ,x+ put it in the buffer | |
33 decb done all bits? | |
34 bne binas1 no, loop | |
35 clr ,x mark end of string | |
36 leas 2,s clean up | |
37 puls a,b,x,pc restore & return | |
38 | |
39 endsect | |
40 |