remquo asm: return quotient mod 8, as intended by the spec

this is a lot more efficient and also what is generally wanted.
perhaps the bit shuffling could be more efficient...
This commit is contained in:
Rich Felker
2012-03-19 23:53:52 -04:00
parent 804fbf0b8c
commit 7513d3ecab

View File

@ -2,40 +2,49 @@
.type remquof,@function .type remquof,@function
remquof: remquof:
mov 12(%esp),%ecx mov 12(%esp),%ecx
fldl 4(%esp)
fldl 8(%esp) fldl 8(%esp)
fldl 4(%esp)
mov 11(%esp),%dh
xor 7(%esp),%dh
jmp 1f jmp 1f
.global remquol .global remquol
.type remquol,@function .type remquol,@function
remquol: remquol:
mov 28(%esp),%ecx mov 28(%esp),%ecx
fldl 4(%esp)
fldl 16(%esp) fldl 16(%esp)
fldl 4(%esp)
mov 25(%esp),%dh
xor 13(%esp),%dh
jmp 1f jmp 1f
.global remquo .global remquo
.type remquo,@function .type remquo,@function
remquo: remquo:
mov 20(%esp),%ecx mov 20(%esp),%ecx
fldl 4(%esp)
fldl 12(%esp) fldl 12(%esp)
1: fld %st(1) fldl 4(%esp)
mov 19(%esp),%dh
xor 11(%esp),%dh
1: fprem1 1: fprem1
fnstsw %ax fnstsw %ax
sahf sahf
jp 1b jp 1b
fsubr %st(0),%st(2) fstp %st(1)
fxch %st(2) mov %ah,%dl
fdivp shr %dl
mov $0x4f000000,%eax and $1,%dl
mov %eax,4(%esp) mov %ah,%al
flds 4(%esp) shr $5,%al
fxch %st(1) and $2,%al
1: fprem or %al,%dl
fnstsw %ax mov %ah,%al
sahf shl $2,%al
jp 1b and $4,%al
fistpl (%ecx) or %al,%dl
fstp %st(0) test %dh,%dh
jns 1f
neg %dl
1: movsbl %dl,%edx
mov %edx,(%ecx)
ret ret