# PICMicrocontollerMathMethod

## 32x16 multiplication for PIC18F

from VegiPete gmail

```;******************************************************************************
;Mult32x16
;Multiply a 32 bit number by a 16 bit number (low byte in low memory)
;FSR0 points to the 16 bit number
;FSR1 points to the 32 bit number
;FSRs are unchanged
;WREG,PRODL,PRODH changed
;Puts the 48 bit result in result
;Algorithm merely sums the 8 partial products, however, the
;order is chosen to minimize left over carry bits
;******************************************************************************
Mult32x16:
clrf	result+4
clrf	result+5

movf	POSTINC1,w
movf	POSTINC1,w
movf	POSTDEC1,w		;source32+2
mulwf	INDF0			;source16+0
movff	PRODL,result+2
movff	PRODH,result+3

movf	POSTINC1,w		;source32+1
mulwf	POSTINC0		;source16+0
movff	PRODL,result+1
movf	PRODH,w
addwf	result+2,f

movf	POSTDEC1,w		;source32+2
mulwf	INDF0			;source16+1
movf	PRODL,w
addwfc	result+3,f
movf	PRODH,w
addwfc	result+4,f		;maybe carry
btfsc	STATUS,C
incf	result+5,f

movf	POSTDEC1,w
movf	POSTINC1,w		;source32+0
mulwf	POSTDEC0		;source16+1
movf	PRODL,w
addwf	result+1,f
movf	PRODH,w
addwfc	result+2,f

movf	POSTINC1,w
movf	POSTINC1,w
movf	POSTDEC1,w		;source32+3
mulwf	INDF0			;source16+0
movf	PRODL,w
addwfc	result+3,f
movf	PRODH,w
addwfc	result+4,f		;maybe carry
btfsc	STATUS,C
incf	result+5,f

movf	POSTDEC1,w
movf	POSTDEC1,w
movf	POSTINC1,w		;source32+0
mulwf	POSTINC0		;source16+0
movff	PRODL,result+0
movf	PRODH,w
addwf	result+1,f

movf	POSTINC1,w		;source32+1
mulwf	INDF0			;source16+1
movf	PRODL,w
addwfc	result+2,f
movf	PRODH,w
addwfc	result+3,f

movf	POSTINC1,w
movf	POSTDEC1,w		;source32+3
mulwf	POSTDEC0		;source16+1
movf	PRODL,w
addwfc	result+4,f
movf	PRODH,w
addwfc	result+5,f		;should be no carry

movf	POSTDEC1,w
movf	POSTDEC1,w		;move pointer back to start
return

```

 file: /Techref/microchip/math/mul/32x16PIC18F-vp.htm, 2KB, , updated: 2012/1/6 17:52, local time: 2024/2/20 18:44, TOP NEW HELP FIND:  44.200.77.92: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! PIC Microcontoller Math Method 32x16 multiplication for PIC18F

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? "No. I'm looking for: " "No. Take me to the search page." "No. Take me to the top so I can drill down by catagory" "No. I'm willing to pay for help, please refer me to a qualified consultant"

.