annotate lib/alib/bin_asc.as @ 3054:22ddd48b4ec2

level1 krn: Fix scheduler bug that only affected 6309 The original 6809 binary was correct, but it was disassembled and interpreted wrongly, so that reassembly went wrong on 6309.
author Tormod Volden <debian.tormod@gmail.com>
date Sun, 25 Jan 2015 22:36:02 +0100
parents 03f26e88b809
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2783
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
1 ******************************************
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
2
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
3 * Binary word to ASCII string conversion
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
4
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
5 * OTHER MODULES NEEDED: none
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
6
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
7 * ENTRY: D = binary value
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
8 * X = buffer for 16 bit number
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
9
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
10 * EXIT: all registers (except cc) preserved
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
11
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
12 nam Convert # to Ascii String
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
13 ttl Assembler Library Module
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
14
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
15
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
16 section .text
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
17
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
18 BIN_ASC:
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
19 pshs a,b,x save registers
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
20 pshs a,b save data again
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
21 ldb #16 total bits to convert
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
22 andcc #%11111110 clear CARRY to start
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
23
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
24 binas1
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
25 lda #'0 get ASCII 0
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
26 rol 1,S get hi bit in LSB to carry
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
27 rol ,S and into MSB; is it 1 or 0?
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
28 bcc binas2 0, skip
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
29 inca get ASCII 1
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
30
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
31 binas2
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
32 sta ,x+ put it in the buffer
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
33 decb done all bits?
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
34 bne binas1 no, loop
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
35 clr ,x mark end of string
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
36 leas 2,s clean up
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
37 puls a,b,x,pc restore & return
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
38
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
39 endsect
03f26e88b809 Renamed files and setup for lwasm/lwlink work
Boisy Pitre <boisy.pitre@nuance.com>
parents:
diff changeset
40