;******************************************************************
;
; 8-bit Binary to 3 digit half-packed BCD (isochronous)
;
; input: WREG, 0x00..0xFF, 0..255
; output: tens, 0x00..0x25, packed bcd hundreds and tens
; ones, 0x00..0x09
;
; 26 words/cycles (isochronous), not including call and return
;
radix dec
Bin2Bcd
clrf tens ;
addlw -200 ; W = W - 200
rlf tens,F ; pick up Carry result
btfss tens,0 ; borrow? no, skip, else
addlw 200 ; add 200 back
addlw -100 ; subtract 100
rlf tens,F ; pick up Carry result
btfss tens,0 ; borrow? no, skip, else
addlw 100 ; add 100 back
addlw -80 ;
rlf tens,F ;
btfss tens,0 ;
addlw 80 ;
addlw -40 ;
rlf tens,F ;
btfss tens,0 ;
addlw 40 ;
addlw -20 ;
rlf tens,F ;
btfss tens,0 ;
addlw 20 ;
addlw -10 ;
rlf tens,F ;
btfss tens,0 ;
addlw 10 ;
movwf ones ;
return ;