]> git.sur5r.net Git - cc65/blob - libsrc/runtime/imul16x16r32.s
Fixed _textcolor definition.
[cc65] / libsrc / runtime / imul16x16r32.s
1 ;
2 ; Ullrich von Bassewitz, 2010-11-03
3 ;
4 ; CC65 runtime: 16x16 => 32 signed multiplication
5 ;
6
7         .export         imul16x16r32
8         .import         negax, umul16x16r32m, negeax
9
10         .include        "zeropage.inc"
11
12
13 ;---------------------------------------------------------------------------
14 ; 16x16 => 32 signed multiplication routine.
15 ;
16 ;   LHS         RHS           result          result also in
17 ; -------------------------------------------------------------
18 ;   ax          ptr1          ax:sreg
19 ;
20 ; There is probably a faster way to do this.
21 ;
22
23 imul16x16r32:
24         stx     tmp1
25         cpx     #0
26         bpl     @L1
27         jsr     negax
28 @L1:    sta     ptr3
29         stx     ptr3+1
30
31         lda     ptr1+1
32         eor     tmp1
33         sta     tmp1
34         lda     ptr1
35         ldx     ptr1+1
36         bpl     @L2
37         jsr     negax
38         sta     ptr1
39         stx     ptr1+1
40 @L2:    jsr     umul16x16r32m
41         ldy     tmp1
42         bpl     @L3
43         jmp     negeax
44 @L3:    rts
45