?? 8位二進(jìn)制轉(zhuǎn)化為2位bcd的pic子程序.txt
字號:
; 8位BIN數(shù)轉(zhuǎn)化為2位BCD數(shù)
;********************************************************************
; 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 10
MSD equ 11
;
;其它的寄存器自己定義
;
BinBCD
clrf MSD
movwf LSD
gtenth
movlw D'10'
subwf LSD,W
BTFSS STATUS,C
goto over
movwf LSD
incf MSD
goto gtenth
over
retlw 0
;**********************************
;測試程序(注意用法,BIN數(shù)放在W里,結(jié)果放在MSD,LSD里)
;----------------------------------
main
movlw 63 ; W reg = 63 Hex
call BinBCD ; after conversion, MSD = 9 & LSD = 9
; ( 63 Hex = 99 Decimal )
self goto self ; 如不是測試程序,本句無用
;
org 1FF
goto main
;
END
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -