3 ; 2002-10-22, Greg King
5 ; This signed-division function returns both the quotient and the remainder,
12 ; div_t __fastcall__ div (int numer, int denom);
17 .import tosdivax, negax
18 .importzp sreg, ptr1, tmp1
20 _div: jsr tosdivax ; Division-operator does most of the work
21 sta sreg ; Quotient is in sreg
23 lda ptr1 ; Unsigned remainder is in ptr1
26 ; Adjust the sign of the remainder.
27 ; It must be the same as the sign of the dividend.
29 bit tmp1 ; Load high-byte of left argument
30 bpl Pos ; Jump if sign-of-result is positive
31 jmp negax ; Result is negative, adjust the sign