Searching \ for 'Math Troubles continued' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page:
Search entire site for: 'Math Troubles continued'.

Truncated match.
PICList Thread
'Math Troubles continued'
2000\03\22@194559 by Lorick

I was using the 24 bit adder from

and one of my problems was there's a bug in the code.  The middle byte
references the LS byte
again instead of the middle byte.  Once I changed the 2  LS byte references
in that section to Middle byte references R1L -->  R1M    the program
finally gave me the output I calculated by hand.  Otherwise, my actual
addition problem I had was due to my error in conversion between variable
names, trying to rewrite it to fit my own program syntax, and trying to copy
the result into a separate 24 bit variable instead of destroying one of the
2 input numbers...I think I have it figured out now.

Multiplication,  where I get 2 x 1 = something way too big, I am trying to
use this program which I must have pulled from one of the sites previously
referenced in the list.  I don't know much about the theory of rotating bits
to multiply so I can't debug it, I can only see that it gives the wrong
output and then hope to find another working routine or have someone tell me
it should or shouldn't work and maybe I'm doing something wrong again.  I
assume the variables in this code are  result = Product,   input numbers 1
and 2 = Multiplier, Multiplicand:

Mul16 clrf   Product
       clrf   Product+1
       movlw  16               ;Operating on 16 Bits
       movwf  BitCount
       Loop                    ;Loop Here for Each Bit

       rrf    Multiplier+1     ;Shift the Multiplier down
       rrf    Multiplier       ;by one
       btfss  STATUS,C         ;If the bit is set, add
       goto   Skip             ;the Multiplicand to the
       movf   Multiplicand+1
       addwf  Product+1
       movf   Multiplicand
       addwf  Product
       btfsc  STATUS,C
       incf   Product+1

       Skip                    ;Shift up Multiplicand and
       bcf    STATUS,C         ;Loop Around
       rlf    Multiplicand
       rlf    Multiplicand+1

       decfsz BitCount
       goto  Loop

2000\03\23@111327 by jamesnewton

face picon face
Re: 24bit add
I've updated the page as I understand you indicated. Is this now correct:
    movfw       R1L              ;
    addwf       AD2L,F          ;LS byte

    movfw       R1M             ;middle byte
      incfsz    R1L,W
        addwf   AD2M,F          ;

    movfw       R1H             ;MS byte
      incfsz    R1H,W
        addwf   AD2H,F          ;

Re: 16x16 multiply
there are two at the math site

which might be useful even if only for comparison to the one you are using.

Please consider posting your finished (debugged) version for others.

James Newton (PICList Admin #3) 1-619-652-0593
PIC/PICList FAQ: or .org

{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 2000 , 2001 only
- Today
- New search...