2 ; Ullrich von Bassewitz, 2010-11-03
4 ; CC65 runtime: 16x16 => 32 unsigned multiplication
7 .export umul16x16r32, umul16x16r32m
8 .export umul16x16r16, umul16x16r16m
10 .include "zeropage.inc"
13 ;---------------------------------------------------------------------------
14 ; 16x16 => 32 unsigned multiplication routine. Because the overhead for a
15 ; 16x16 => 16 unsigned multiplication routine is small, we will tag it with
16 ; the matching labels as well.
18 ; routine lhs rhs result result also in
19 ; -----------------------------------------------------------------------
20 ; umul16x16r32 ptr1 ax ax:sreg ptr1:sreg
21 ; umul16x16r32m ptr1 ptr3 ax:sreg ptr1:sreg
22 ; umul16x16r16 ptr1 ax ax ptr1
23 ; umul16x16r16m ptr1 ptr3 ax ptr1
25 ; ptr3 is left intact by the routine.
37 ldy #16 ; Number of bits
40 ror ptr1 ; Get first bit into carry
58 sta sreg ; Save byte 3
59 lda ptr1 ; Load the result