DIY编程器网

标题: PIC单片机无符号BCD加法子程序 [打印本页]

作者: liyf    时间: 2012-1-27 18:22
标题: 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,Wclrf    Num_1           ;clear num_1addwf   Num_2,1         ; do binary additionbtfsc   STATUS,C        ; max number );self    goto    self     ;如不是测试程序,这句无用;;org     1FFgoto    main;END
                                




欢迎光临 DIY编程器网 (http://diybcq.com/) Powered by Discuz! X3.2