I would like to know, what values should I use to change FPU rounding mode.
.data
nearest:
??
down:
??
up:
??
zero:
??
.text
.global round
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %ecx
cmpl $1, %ecx
je
fldcw nearest
cmpl $2, %ecx
je
fldcw down
cmpl $3, %ecx
je
fldcw up
cmpl $4, %ecx
je
fldcw zero
leave
ret
I found something like this:
down:
.byte 0x7f, 0x07
up:
.byte 0x7f, 0x0b
but I don't know why somebody used it. I know I should change 8 and 9 bits, like this: 00 — round to nearest 01 — round down (toward negative infinity) 10 — round up (toward positive infinity) 11 — round toward zero