8X8 bit unsigned multiplication

Status
Not open for further replies.
Got this in a lecture

; 8x8 unsigned multiply routine.
; No checks made for M1 or M2 equal to zero
Clrf R_hi ; Clear result location
clrf R_lo
movlw 0x08 ; setup loop count
movwf cntr
movf M1,W ; initialize W with M1

Umul rrf M2,F ; rotate into carry to check bits
Btfsc STATUS,C ; if carry set i.e. bit was 1
addwf R_hi,F ; ... we add
rrf R_hi,F ; shift over for the next addition
rrf R_lo,F
decf cntr,F ; check the loop count
btfss STATUS,Z
goto Umul
...


Looks good i think. Right?
 
8X8 Multiplication

Mike,

Yea mike it works fine. Thanks for this as well as the switching between ports code...Work great...You the man!
 
That simple loop multiplication is very slow though, if you start running out of processor time there are other multiplication routines out there that use more code space but take significantly less time to run.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…