please dont rip this site

SX Microcontroller Math Method

24x24 multiplication

from Nikolai Golovchenko

Product         DS      6
Multipland      DS      3
BitCount        DS      1

Multiplier      equ     Product+3       ;3 bytes shared with Product's
                                        ;less significant bytes (+3...5)

        ; 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
; Multiplier - 3 bytes (shared with Product)
; Multiplicand - 3 bytes (not modified)
; Bitcount
; 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


        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

        ; 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

file: /Techref/scenix/lib/math/mul/24x24ng_sx.htm, 5KB, , updated: 2004/6/10 14:40, local time: 2024/7/18 03:38, owner: NG--944,

 ©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!

<A HREF=""> SX Microcontroller Math Method </A>

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?

  PICList 2024 contributors:
o List host: MIT, Site host, 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!