Product DS 6
Multipland DS 3
BitCount DS 1
Multiplier equ Product+3 ;3 bytes shared with Product's
;less significant bytes (+3...5)
MULTIPLY_24x24
; preload values to test
mov W, #$AB
mov Multipland, W
mov W, #$CD
mov Multipland+1, W
mov W, #$EF
mov Multipland+2, W
mov W, #$98
mov Multiplier, W
mov W, #$76
mov Multiplier+1, W
mov W, #$54
mov Multiplier+2, W
; these values should generate the reply = $6651AF33BC6C
;24 x 24 Multiplication
;Input:
; Multiplier - 3 bytes (shared with Product)
; Multiplicand - 3 bytes (not modified)
;Temporary:
; Bitcount
;Output:
; Product - 6 bytes
clr Product ; clear destination
clr Product+1
clr Product+2
mov W, #24
mov BitCount, W ; number of bits
rr Product+3 ;shift out to carry
rr Product+4 ;next multiplier bit
rr Product+5
ADD_LOOP_24x24
jnc SKIP_LOOP_24x24 ; if carry is set we must add
; multipland
; to the product
mov W, Multipland+2 ; get LSB of multiplicand
add Product+2, W ; add it to the lsb of the product
mov W, Multipland+1 ; middle byte
snb C ; check carry for overflow
movsz W, ++Multipland+1 ; if carry set we add one to the source
add Product+1, W ; and add it (if not zero, in
; that case mulitpland = $ff->$00 )
mov W, Multipland ; MSB byte
snb C ; check carry
movsz W, ++Multipland
add Product, W ; handle overflow
SKIP_LOOP_24x24
; note carry contains most significant bit of
; addition here
; shift in carry and shift out
; next multiplier bit, starting from less
; significant bit
rr Product
rr Product+1
rr Product+2
rr Product+3
rr Product+4
rr Product+5
decsz BitCount
jmp ADD_LOOP_24x24
ret
| file: /Techref/scenix/lib/math/mul/24x24ng_sx.htm, 5KB, , updated: 2004/6/10 14:40, local time: 2025/10/24 10:49,
owner: NG--944,
216.73.216.114,10-3-244-150:LOG IN
|
| ©2025 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? <A HREF="http://www.piclist.com/techref/scenix/lib/math/mul/24x24ng_sx.htm"> SX Microcontroller Math Method </A> |
| Did you find what you needed? |
|
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! |
.