2 ; Ullrich von Bassewitz, 07.08.1998
4 ; CC65 runtime: modulo operation for long signed ints
7 ; When negating values, we will ignore the possibility here, that one of the
8 ; values if $8000, in which case the negate will fail.
11 .import poplsargs, udiv32, negeax
12 .importzp sreg, ptr1, ptr2, tmp1, tmp3, tmp4
15 jsr poplsargs ; Get arguments from stack, adjust sign
16 jsr udiv32 ; Do the division, remainder is in (ptr2:tmp3:tmp4)
27 ; Check the sign of the result. It is the sign of the left operand.
29 bit tmp1 ; Check sign of left operand
30 bpl Pos ; Jump if result is positive
34 jmp negeax ; Negate result