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, adjlsres
12 .importzp sreg, ptr1, ptr2, tmp3, tmp4
15 jsr poplsargs ; Get arguments from stack, adjust sign
16 jsr udiv32 ; Do the division
17 lda ptr1 ; Remainder is in (ptr2:tmp3:tmp4)
24 jmp adjlsres ; Adjust the sign of the result if needed