资料介绍
PIC的BIN TO BCD子程序
;**********二进制转换成BCD码子程序,入口W*****
;********出口为R2,R1,R0寄存器
BINTOB?????movwf???buf_read??????;W->buf_read
???????????clrf????R0
???????????clrf????R1
???????????clrf????R2
???????????movlw???08h
???????????movwf???counter_pub
loopc??????bcf?????STATUS,C
???????????rlf?????buf_read,1
???????????rlf?????R0
???????????rlf?????R1
???????????decfsz??counter_pub,1
???????????goto????adjdec
???????????movlw???0fh
???????????andwf???R1,0
???????????movwf???R2
???????????swapf???R0,0
???????????movwf???R1
???????????movlw???0fh
???????????andwf???R0,1
???????????andwf???R1,1
???????????return
adjdec?????movlw???03h
???????????addwf???R0,1
???????????btfsc???R0,3
???????????goto????next_r0
???????????subwf???R0,1
next_r0????movlw???030h
???????????addwf???R0,1
???????????btfsc???R0,7
???????????goto?