2 ; Ullrich von Bassewitz, 07.08.1998
4 ; CC65 runtime: helper stuff for mod/div with signed ints
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.
10 .export popsargsudiv16
11 .import negax, popax, udiv16
12 .importzp tmp1, tmp2, ptr1, ptr4
15 stx tmp2 ; Remember sign
18 jsr negax ; Negate accumulator
20 stx ptr4+1 ; Save right operand
23 stx tmp1 ; Remember sign
29 jmp udiv16 ; Call the division