;;c2b.asm
;Willard Goosey
;7/18/2011

;convert char in C to ascii string
;of bits


;$Id: c2b.asm,v 1.3 2011/09/05 21:47:46 goosey Exp goosey $
	
;c2b -8bit value in C to ascii binary
;entry conditions: C =value to convert
;                  HL->8-byte buffer
;exit conditions: A, BC destroyed
;                  HL->buffer

;derived from 8080/z80 Assembly Language
;Alan Miller, John Wiley & Sons, 1981

c2b  push h       ;save hl on stack
     mvi b,8      ;b will be a counter
c2b2 mov a,c      ;a=c
     add a        ;set carry
     mov c,a      ;put back
     mvi a,'0'/2  ;half of ascii 0 
     adc a        ;double + carry
     mov m,a      ;store in buf
     inx h        ;hl=hl+1
     dcr b        ;b=b-1
     jnz c2b2     ;jump not zero
     pop h        ;done, restore original hl
     ret

;;end of c2b.asm
	
	 