.file "_xtoll.s"
#include <SYS.h>
.set cw,0
.set cw_old,2
.set two_words,4
.set four_words,8
/ This function truncates the top of the 387 stack into a signed long.
ENTRY(__xtol)
subl $8,%esp
fstcw cw_old(%esp)
movw cw_old(%esp),%ax
movw %ax,%cx
andw $0x0c00,%cx
orw $0x0c00,%ax
movw %ax,cw(%esp)
fldcw cw(%esp)
fistpl two_words(%esp)
fstcw cw(%esp)
movw cw(%esp),%ax
andw $0xf3ff,%ax
orw %cx,%ax
movw %ax,cw(%esp)
fldcw cw(%esp)
movl two_words(%esp),%eax
addl $8,%esp
ret
SET_SIZE(__xtol)
/ This function truncates the top of the 387 stack into a signed long long.
ENTRY(__xtoll)
subl $12,%esp
fstcw cw_old(%esp)
movw cw_old(%esp),%ax
movw %ax,%cx
andw $0x0c00,%cx
orw $0x0c00,%ax
movw %ax,cw(%esp)
fldcw cw(%esp)
fistpll two_words(%esp)
fstcw cw(%esp)
movw cw(%esp),%ax
andw $0xf3ff,%ax
orw %cx,%ax
movw %ax,cw(%esp)
fldcw cw(%esp)
movl two_words(%esp),%eax
movl four_words(%esp),%edx
addl $12,%esp
ret
SET_SIZE(__xtoll)
/ This function truncates the top of the 387 stack into a unsigned long.
.align 4
two_to_31: .long 0x4f000000
ENTRY(__xtoul)
subl $8,%esp
fstcw cw_old(%esp)
movw cw_old(%esp),%ax
movw %ax,%cx
andw $0x0c00,%cx
orw $0x0c00,%ax
movw %ax,cw(%esp)
fldcw cw(%esp)
_prologue_
fcoms _sref_(two_to_31)
_epilogue_
fstsw %ax
sahf
jb .donotsub
_prologue_
fsubs _sref_(two_to_31)
_epilogue_
.donotsub:
fistpl two_words(%esp)
fwait
movl two_words(%esp),%eax
jb .donotadd
add $0x80000000,%eax
.donotadd:
fstcw cw(%esp)
movw cw(%esp),%dx
andw $0xf3ff,%dx
orw %cx,%dx
movw %dx,cw(%esp)
fldcw cw(%esp)
addl $8,%esp
ret
SET_SIZE(__xtoul)