]> git.sur5r.net Git - cc65/blob - libsrc/runtime/umul8x8r16.s
Rename the 8x8 multiplication using the same scheme as for the 16x16
[cc65] / libsrc / runtime / umul8x8r16.s
1 ;
2 ; Ullrich von Bassewitz, 2010-11-02
3 ;
4 ; CC65 runtime: 8x8 => 16 multiplication
5 ;
6
7         .export         umul8x8r16, umul8x8r16m
8         .importzp       ptr1, ptr3
9
10
11 ;---------------------------------------------------------------------------
12 ; 8x8 => 16 multiplication routine.
13 ;
14 ;   lhs         rhs           result          result also in
15 ; -------------------------------------------------------------
16 ;   ptr1-lo     ptr3-lo         ax              ptr1
17 ;
18
19 umul8x8r16:
20         sta     ptr3
21 umul8x8r16m:
22         lda     #0              ; Clear byte 1
23         ldy     #8              ; Number of bits
24         lsr     ptr1            ; Get first bit of lhs into carry
25 @L0:    bcc     @L1
26         clc
27         adc     ptr3
28 @L1:    ror
29         ror     ptr1
30         dey
31         bne     @L0
32         tax
33         stx     ptr1+1          ; Result in a/x and ptr1
34         lda     ptr1            ; Load the result
35         rts                     ; Done
36
37