1985-02-07 22:06:32 +00:00
|
|
|
.define .dvu
|
1986-07-22 13:37:16 +00:00
|
|
|
.sect .text
|
|
|
|
.sect .rom
|
|
|
|
.sect .data
|
|
|
|
.sect .bss
|
1985-02-07 22:06:32 +00:00
|
|
|
|
|
|
|
! unsigned long divide
|
|
|
|
! register usage:
|
|
|
|
! : d0 divisor
|
|
|
|
! d1 dividend
|
|
|
|
! exit : d1 quotient
|
|
|
|
! d2 remainder
|
1986-07-22 13:37:16 +00:00
|
|
|
.sect .text
|
1985-02-07 22:06:32 +00:00
|
|
|
.dvu:
|
1986-07-22 13:37:16 +00:00
|
|
|
move.l 4(sp),d0
|
|
|
|
move.l 8(sp),d1
|
|
|
|
move.l d3,-(sp)
|
1985-02-07 22:06:32 +00:00
|
|
|
tst.l d0
|
|
|
|
bne 0f
|
|
|
|
move.w #EIDIVZ,-(sp)
|
|
|
|
jsr .trp
|
|
|
|
0:
|
|
|
|
clr.l d2
|
|
|
|
move.l #31,d3
|
|
|
|
3:
|
|
|
|
lsl.l #1,d1
|
|
|
|
roxl.l #1,d2
|
|
|
|
cmp.l d0,d2
|
|
|
|
blt 4f
|
|
|
|
sub.l d0,d2
|
|
|
|
add #1,d1
|
|
|
|
4:
|
|
|
|
dbf d3,3b
|
1986-07-22 13:37:16 +00:00
|
|
|
move.l (sp)+,d3
|
|
|
|
move.l (sp)+,a0
|
|
|
|
add.l #8,sp
|
|
|
|
move.l a0,-(sp)
|
1985-02-07 22:06:32 +00:00
|
|
|
rts
|
1986-07-22 13:37:16 +00:00
|
|
|
|
1985-02-07 22:06:32 +00:00
|
|
|
.align 2
|