anurag2700
Newbie level 6
how do u multiply decimals
please help me in multiply or dividing two decimal numbers in PIC.
EXAMPLE--43.2 x 23.6
please help me in multiply or dividing two decimal numbers in PIC.
EXAMPLE--43.2 x 23.6
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Mul
clrf resL ; clear resL
clrf resH ; clear resH
movlw 8 ; set number ..
movwf cnt_art ; .. of bits in intB
movfw intA ; intA > W
bcf STATUS, C ; clear carry
Rotation
rrf intB, f ; intB >> 1
btfsc STATUS, C ; if last bit in intB was 1
addwf resH, f ; do this
rrf resH, f ; resH >> 1
rrf resL, f ; resL >> 1
decfsz cnt_art,F ; decrement counter
goto Rotation ; if this isn't go back to Rotation
movfw resL ; resL -> PORTB
movwf output ; W -> PORTB
entr ; macro entr
movfw resH ; resH -> PORTB
movwf output ; W -> PORTB
entr ; macro entr
return ; return
Since you provided very little information about your real application, I'll solve your example by simply representing the numbers with fixed (as opposed to floating) decimal point and further operate on them using integer multiplication/division.anurag2700 said:please help me in multiply or dividing two decimal numbers in PIC.
EXAMPLE--43.2 x 23.6