]> git.sur5r.net Git - cc65/blob - libsrc/common/idiv32by16r16.s
Code review adaptations, removed "cc65_" prefix from functions
[cc65] / libsrc / common / idiv32by16r16.s
1 ;
2 ; Ullrich von Bassewitz, 2009-11-04
3 ;
4 ; CC65 library: 32by16 => 16 signed division
5 ;
6
7         .export         _idiv32by16r16
8         .import         idiv32by16r16, incsp4
9
10         .include        "zeropage.inc"
11
12
13 ;---------------------------------------------------------------------------
14 ; 32by16 division.
15
16 .proc   _idiv32by16r16
17
18         pha                     ; Save rhs
19
20 ; Copy from stack to zeropage. This assumes ptr1 and ptr2 are adjacent.
21
22         ldy     #3
23 @L1:    lda     (sp),y
24         sta     ptr1,y
25         dey
26         bpl     @L1
27
28         lda     #4
29         clc
30         adc     sp
31         sta     sp
32         bcc     @L2
33         inc     sp+1
34
35 @L2:    pla                     ; Old rhs
36         jmp     idiv32by16r16
37
38 .endproc
39