please dont rip this site

PIC Microcontoller Math Method

24x8 multiplication from Byron A Jeff

posted to PICList

Something like this:
--------------------
mult24x8:
        clrf    prod0           ; Clear the product
        clrf    prod1
        clrf    prod2
        clrf    prod3
        clrf    twofour3        ; Clear the top byte of the multiplicand
multloop:
        movf    eight,W         ; Check to see if eight bit is empty
        btfsc   STATUS,Z        ; Done if zero
        return
        bcf     STATUS,C        ; clear carry
        rrl     eight,F         ; Get the next bit
        btfss   STATUS,C        ; Add if carry is set
        goto    multshift       ; shift only if 0
        movf    twofour0,W      ; Add the 32 bits of multiplicand to product
        addwf   prod0,F         ; each addwf sets the carry
        btfsc   STATUS,C        ; Don't increment if no carry
        call    carryprop1 	; Propigate carry to next byte(s)
        movf    twofour1,W      ;
        addwf   prod1,F         ;
        btfsc   STATUS,C        ; Don't increment if no carry
        call    carryprop2 	; Propigate carry to next byte(s)
        movf    twofour2,W      ;
        addwf   prod2,F         ;
        btfsc   STATUS,C        ; Don't increment if no carry
        incf    prod3,F         ; Add one to next byte if carry occured
        movf    twofour3,W      ;
        addwf   prod3,F         ;
multshift:
        bcf     STATUS,C        ; clear carry
        rlf     twofour0,F      ; Shift the 24 bits one bit to the left
        rlf     twofour1,F
        rlf     twofour2,F
        rlf     twofour3,F
        goto    multloop

carryprop1:
        incfsz  prod1,F
        return
carryprop2:
        incfsz  prod2,F
        return
carryprop3:
        incf    prod3,F
        return
------------------------------------------------------------

I wrote this off the top of my head and I haven't tested it, but it should be
in the ballpark.

Not speedy, but should work.

Code:


file: /Techref/microchip/math/mul/23x8bbaj.htm, 5KB, , updated: 2003/9/27 05:14, local time: 2024/3/28 13:27, owner: size111-hotmail-,
TOP NEW HELP FIND: 
18.209.209.28:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://www.piclist.com/techref/microchip/math/mul/23x8bbaj.htm"> PIC Microcontoller Math Method </A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

  PICList 2024 contributors:
o List host: MIT, Site host massmind.org, Top posters @none found
- Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
 

Welcome to www.piclist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .