FPU 状态寄存器:fstsw 可以把状态寄存器读取到一个双字节内存位置或者AX寄存器中。
.section .data
output:
.asciz "The is %d\n"
.section .bss
.lcomm status ,2
.section .text
.globl _start
_start:
nop
fstsw %ax
fstsw status
#pushw %ax #65536
pushw status
push $output
call printf
addl $8,%esp
movl $1,%eax
movl $0,%ebx
int $0x80
运行结果
FPU 控制寄存器
例程:
.section .data
output:
.asciz "The is %d\n"
newvalue:
.byte 0x7f,0x00
.section .bss
.lcomm control,2
.section .text
.globl _start
_start:
nop
fstcw control #fstcw 指令获取当前控制寄存器的值
fldcw newvalue #fldcw 指令把newvalue 的值加载到控制寄存器
fstcw control #fstcw 指令检查当前控制寄存器的值
pushl control
push $output
call printf
addl $8,%esp
pushl $0
movl $1,%eax
movl $0,%ebx
int $0x80
运行结果:
fstcw control #fstcw 指令获取当前控制寄存器的值
fldcw newvalue #fldcw 指令把newvalue 的值加载到控制寄存器
fstcw control #fstcw 指令检查当前控制寄存器的值