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 13:40, local time: 2024/12/1 20:05,
owner: NG--944,
3.136.25.249: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? <A HREF="http://ecomorder.com/Techref/scenix/lib/math/mul/24x24ng_sx.htm"> SX Microcontroller Math Method </A> |
Did you find what you needed? |
Welcome to ecomorder.com! |
Welcome to ecomorder.com! |
.