2 ; Ullrich von Bassewitz, 07.08.1998
4 ; CC65 runtime: division for 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.
10 .export tosdiva0, tosdivax
11 .import popsargs, udiv16, adjsres
17 jsr popsargs ; Get arguments from stack, adjust sign
18 jsr udiv16 ; Do the division
19 lda sreg ; Result is in sreg, remainder in ptr1
21 jmp adjsres ; Adjust the sign of the result if needed