2 ; Ullrich von Bassewitz, 07.08.1998
4 ; CC65 runtime: division for unsigned ints
6 ; Don't use tmp1 here, the signed division tunnels data with it!
8 .export tosudiva0, tosudivax, udiv16
10 .importzp sreg, ptr1, ptr4
14 ldx #$00 ; Clear high byte
17 stx ptr4+1 ; Save right operand
18 jsr popptr1 ; Get left operand
24 ; Result is in ptr1, remainder in sreg
30 ;---------------------------------------------------------------------------
31 ; 16by16 division. Divide ptr1 by ptr4. Result is in ptr1, remainder in sreg
32 ; (see mult-div.s from "The Fridge").
33 ; This is also the entry point for the signed division
65 ;---------------------------------------------------------------------------