f6a1e08218
My i386 code from 893df4b
gave the wrong sign to some 8-byte
remainders. Fix by splitting .dvi8 and .rmi8 so each has its own code
to pick the sign. They and .dvu8 and .rmu8 share a private sub
.divrem8 for unsigned division.
Improve the i386 code by using instructions like _bsr_ and _shrd_.
Change the helpers to yield a quotient in ebx:eax or a remainder in
ecx:edx; this seems more convenient, because _div_ puts its quotient
in eax and remainder in edx.
21 lines
351 B
ArmAsm
21 lines
351 B
ArmAsm
.sect .text; .sect .rom; .sect .data; .sect .bss
|
|
.sect .text
|
|
.define .dvu8, .rmu8
|
|
|
|
yl=4
|
|
yh=8
|
|
xl=12
|
|
xh=16
|
|
! .dvu8 yields ebx:eax = quotient from x / y
|
|
! .rmu8 yields ecx:edx = remainder from x / y
|
|
|
|
.dvu8:
|
|
.rmu8:
|
|
mov edx,yh(esp)
|
|
test edx,edx
|
|
mov eax,xh(esp) ! prepare for .divrem8
|
|
push ebp ! move esp
|
|
call .divrem8
|
|
pop ebp ! move esp
|
|
ret 16
|