汇编语言乘法溢出

时间:2015-02-19 02:12:49

标签: assembly pic multiplication pic18

这是我的第一篇文章,所以请保持温柔。我想得到一个最终答案 0hD16BC7A,甚至无法在第一步验证我在地址0x10中有内容0h2A。我想知道它是否与下面评论的溢出有关。任何帮助都会很棒我是新手。谢谢!

   #include <p18f8722.inc>
   Num1H  set  0x11  ;value in 0x11 is 0hB7
   Num1L  set  0x10  ;value in 0x10 is 0hA1
   Num2H  set  0x21  ;value in 0x21 is 0h86
   Num2L  set  0x20  ;value in 0x20 is 0h88
   PR     set  0x30
          org  0
          goto start
   start:
          bcf  STATUS,C,0

         ;Num1L*Num2L
         movf  Num1L,W,0   ;[WREG] <- [0hA1] right?
         mulwf Num2L,0     ;0hA1 right?
                     ;(0hA1)*(0h88) = (oh5588) right?
         movff PRODH,PR+1  ;(0h55)->[PR+1]
         movff PRODL,PR    ;(0h88)->[PR]

         ;Num1H*Num2L
         movf  Num1H,W,0  
         mulwf Num2L,0   
         movff PRODH,PR+2  
         movf  PRODL,W,0 
         addwf PR+1,F,A  

         ;Num1L*Num2H
         movf   Num1L,W,0  
         mulwf  Num2H,0   
         movf   PRODL,W,0 
         addwfc PR+1,F,A 
         movf   PRODH,W,0 
         addwfc PR+2,F,A

         ;Num1H*Num2H
         movf   Num1L,W,0  
         mulwf  Num2H,0   
         movf   PRODL,w,0 
         addwfc PR+2,F,A  ;Is the problem because I have 0h13D here?
         movlw  0         ;How do I handle the overflow?
         addwfc PRODH,W,A 
         movwf  PR+3,0 

0 个答案:

没有答案