view 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
line wrap: on
line source

******************************************

* Binary word to ASCII string conversion

* OTHER MODULES NEEDED: none

* ENTRY: D = binary value
*        X = buffer for 16 bit number

* EXIT: all registers (except cc) preserved

 nam Convert # to Ascii String
 ttl Assembler Library Module


 section .text

BIN_ASC:
 pshs a,b,x save registers
 pshs a,b save data again
 ldb #16 total bits to convert
 andcc #%11111110 clear CARRY to start

binas1
 lda #'0 get ASCII 0
 rol 1,S get hi bit in LSB to carry
 rol ,S and into MSB; is it 1 or 0?
 bcc binas2 0, skip
 inca get ASCII 1

binas2
 sta ,x+ put it in the buffer
 decb done all bits?
 bne binas1 no, loop
 clr ,x mark end of string
 leas 2,s clean up
 puls a,b,x,pc restore & return

 endsect