這是用PIC組合語言寫出來的16進位轉換十進位程式碼,
可以分別將百位數、十位數及個位數字取出來,適用於8位元的單晶片
輸入:w暫存器
輸出:w暫存器
程式碼內容:
;******取出百位數字******
GETHNDS
movwf t1
clrf w2
gethnds_loop
movlw .100
incf w2,f
subwf t1,f
btfsc STATUS,C
goto gethnds_loop
decf w2,w
return
;******取出十位數字******
GETTENS
movwf t1
clrf w2
gettens_loop
movlw .10
incf w2,f
subwf t1,f
btfsc STATUS,C
goto gettens_loop
decf w2,w
goto GETONES
;******取出個位數字******
GETONES
movwf w2
movlw .10
deltens_loop
subwf w2,f
btfsc STATUS,C
goto deltens_loop
addwf w2,w
return
- 5月 09 週三 200709:31
[PIC組語程式收集] 8位元-16進位轉換十進位組合語言:取出百位數、十位數及個位數字
文章標籤
全站熱搜
