Hardware Reference
In-Depth Information
Das Unterprogramm „bin_to_bcd“ wandelt eine 16 Bit lange Binärzahl, die in den
Registern decimalxH und decimalxL steht, in eine gepackte BCD (binary coded
decimal) -Zahl um.
; the response formatter section
; converts binary to BCD
; binary is fetched from decimalxH and decimalxL
; BCD is stored in decimalbU, decimalbH and decimalbL
bin_to_bcd
movlw 0x08
movwf scratchL ;this is a counter
movwf scratchH ;this is another counter
movlw UPPER bcd_table
movwf TBLPTRU
movlw HIGH bcd_table
movwf TBLPTRH
movlw LOW bcd_table
movwf TBLPTRL
movlw 0x00
movwf decimalbL
movwf decimalbH
movwf decimalbU
;this is the result in BCD
bcd_lowloop
btfsc decimalxL,0
bra
bcd_addl
bra
bcd_skipl
bcd_addl
call
bcd_add
bra
bcd_nextl
bcd_skipl
call
bcd_skip
bra
bcd_nextl
bcd_nextl
dcfsnz scratchL
bra bcd_highloop
rrncf decimalxL
bra
bcd_lowloop
bcd_highloop
btfsc decimalxH,0
bra
bcd_addl
bra
bcd_skiph
bcd_addh
call
bcd_add
bra
bcd_nexth
bcd_skiph
call
bcd_skip
bra
bcd_nexth
bcd_nexth
dcfsnz scratchH
Search WWH ::




Custom Search