]> git.sur5r.net Git - cc65/blob - libsrc/runtime/shelp.s
Made the code that logs indirect-goto referals be a little more efficient.
[cc65] / libsrc / runtime / shelp.s
1 ;
2 ; Ullrich von Bassewitz, 07.08.1998
3 ;
4 ; CC65 runtime: helper stuff for mod/div with signed ints
5 ;
6
7 ; When negating values, we will ignore the possibility here, that one of the
8 ; values is $8000, in which case the negate will fail.
9
10         .export         popsargsudiv16
11         .import         negax, popax, udiv16
12         .importzp       tmp1, tmp2, ptr1, ptr4
13
14 popsargsudiv16:
15         stx     tmp2            ; Remember sign
16         cpx     #0
17         bpl     L1
18         jsr     negax           ; Negate accumulator
19 L1:     sta     ptr4
20         stx     ptr4+1          ; Save right operand
21
22         jsr     popax
23         stx     tmp1            ; Remember sign
24         cpx     #0
25         bpl     L2
26         jsr     negax
27 L2:     sta     ptr1
28         stx     ptr1+1
29         jmp     udiv16            ; Call the division