view lib/alib/asc_bin.a @ 2765:0bd16cca86b7

Updated rules.mak for all the os9 format's to format the entire disk. People were having some issues with the disk images not being formatted to their full capacity and preventing some functions from working.
author drencor-xeen
date Thu, 17 Jan 2013 11:03:26 -0600
parents 7d70b7e1cb21
children aaba193af04f
line wrap: on
line source

******************************************
*
* ASCII String to binary byte conversion

* OTHER MODULES NEEDED: IS_TERMIN

* ENTRY: X = start of string of binary digits (001101)
*            terminated by space, comma, CR or null.

*  EXIT: D = value
*        CC carry set if error (string too long, not binary digits)
*        Y = terminator or error pos.


 nam ASCII String to Binary Conversion
 ttl Assembler Library Module


 psect ASC_BIN,0,0,0,0,0

ASC_BIN:
 clra msb/lsb=0
 clrb 
 pshs a,b,x

ascbn1
 ldb ,x+ get a digit
 lbsr IS_TERMIN see if space/comma/null/cr
 beq ascbn2
 subb #$30 strip off ASCII
 bmi error less than "0"..
 cmpb #1
 BHI error geater than "1"
 rorb get bit into carry
 ROL 1,S into LSB
 ROL ,S into MSB
 inca bump string length
 cmpa #16
 BLS ascbn1 length ok, loop
 BRA error

ascbn2
 clrb = no errors
 tsta len = 0?
 bne done no, skip

* error -- too long or null

error
 CLR ,S force data to 0
 CLR 1,S
 ORCC #1 set carry flag

done
 leay -1,x end of string/error char
 PULS A,B,X,PC get data; restore & return

 endsect