bin8bcd.txt
来自「实用子程序.rar本子程序库对《单片机应用程序设计技术》一书附录中的子程序库作了」· 文本 代码 · 共 48 行
TXT
48 行
;
;********************************************************************
; Binary To BCD Conversion Routine
;
; This routine converts the 8 bit binary number in the W Register
; to a 2 digit BCD number.
; The least significant digit is returned in location LSD and
; the most significant digit is returned in location MSD.
;
; Performance :
; Program Memory : 10
; Clock Cycles : 81 (worst case when W = 63 Hex )
; ( i.e max Decimal number 99 )
;*******************************************************************
;
LSD equ 20h
MSD equ 21h
;
INCLUDE p16f877.inc
;
org 00
goto main
BinBCD clrf MSD
movwf LSD
gtenth movlw .10
subwf LSD,W
BTFSS STATUS,C
goto over
movwf LSD
incf MSD
goto gtenth
over retlw 0
;*******************************************************************
;
main movlw 5fh ; W reg = 63 Hex
call BinBCD ; after conversion, MSD = 9 & LSD = 9
self goto self ; ( 63 Hex = 99 Decimal )
;
;
END
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?