GOGOGO高清完整国语,GOGOGO在线观看免费观看完整版高清,GOGOGO免费高清完整,GOGOGO高清在线观看免费视频,GOGOGO日本高清国语完整,GOGOGO免费高清完整版

技術熱線: 4007-888-234
設計開發

專注差異化嵌入式產品解決方案 給智能產品定制注入靈魂給予生命

開發工具

提供開發工具、應用測試 完善的開發代碼案例庫分享

技術支持

從全面的產品導入到強大技術支援服務 全程貼心伴隨服務,創造無限潛能!

新品推廣

提供新的芯片及解決方案,提升客戶產品競爭力

新聞中心

提供最新的單片機資訊,行業消息以及公司新聞動態

PIC單片機無符號 BCD 減法

更新時間: 2019-03-22
閱讀量:3345

單片機開發商深圳英銳恩分享PIC單片機無符號 BCD 減法。

;******************* 無符號 BCD 加法  ***************
;
;       This routine performs a 2 Digit Unsigned BCD Addition
; It is assumed that the two BCD numbers to be added are in
; locations Num_1 & Num_2. The result is the sum of Num_1+Num_2
; and is stored in location Num_2 and the overflow carry is returned
; in location Num_1
;
;   Performance :
;               Program Memory  :       25
;               Clock Cycles    :       17   ( worst case )
;

;*******************************************************************;
;
Num_1   equ     8       ; 加數寄存器,加法和的高位寄存器。
result  equ     8
;
Num_2   equ     9       ; 加數寄存器,加法和的低位寄存器。
O_flow  equ     9
; 其它的寄存器自己定義   
;
BCDAdd
movf    Num_1,W
clrf    Num_1           ;clear num_1
addwf   Num_2,1         ; do binary addition
btfsc   STATUS,C        ;< 256 then skip
goto    inc_n1n2        ;else inc all
movlw   66              ;add 66
addwf   Num_2,1         ;/
btfss   STATUS,DC       ;half carry?
goto    sub_06          ;no then subtract
btfss   STATUS,C        ;full carry?
goto    sub_60          ;yes then subtract
inc_n1 
incf    Num_1,1         ;inc it
  retlw   0               ;clr w
sub_06

 btfss   STATUS,C        ;full carry
  goto    sub_66          ;yes subtract 66
  movlw   6               ;else subtract 6
  goto    sub_com         ;do common
sub_66

  movlw   66             
sub_com
subwf   Num_2,1                  
  retlw   0
sub_60
      movlw   60
  goto    sub_com
inc_n1n2
  movlw   66
  addwf   Num_2,1
  goto    inc_n1
;
;********************************************************************
;               測試程序(注意它怎樣使用該子程序)
;*********************************************************************

main  
movlw   99
movwf   Num_1      ; Set Num_1 = 99 ( max BCD digit )
movlw   99
movwf   Num_2      ; Set Num_2 = 99
;
call    BCDAdd     ; After addition, Num_2 = 98
;                          ;  and Num_1 = 01 ( 99+99 = 198 -> max number )
;
self    goto    self     ;如不是測試程序,這句無用
;
;
org     1FF
goto    main
;
END

欢迎光临: 友谊县| 东丽区| 修水县| 青神县| 牟定县| 资中县| 三穗县| 勐海县| 平顶山市| 中山市| 松滋市| 东乡县| 邻水| 泰州市| 抚顺县| 永济市| 外汇| 安阳市| 厦门市| 泰顺县| 崇信县| 河池市| 丰城市| 长海县| 武隆县| 建德市| 罗平县| 江陵县| 新竹市| 富顺县| 泗洪县| 宜良县| 盐边县| 柏乡县| 遵义县| 涟水县| 墨江| 原阳县| 靖宇县| 富民县| 井陉县|