深入理解FPU栈操作与浮点运算
1. FPU栈的基本操作
在进行浮点运算时,理解FPU栈上的数据操作至关重要,因为所有的FPU数学运算都在栈上进行。以下是一个示例程序 stacktest.s ,展示了如何将各种数据类型加载到FPU栈上,以及一些常见的栈操作函数:
# stacktest.s - An example of working with the FPU stack
.section .data
value1:
.int 40
value2:
.float 92.4405
value3:
.double 221.440321
.section .bss
.lcomm int1, 4
.lcomm control, 2
.lcomm status, 2
.lcomm result, 4
.section .text
.globl _start
_start:
nop
finit
fstcw control
fstsw status
filds value1
fists int1
flds value2
fldl value3
fst %st(4)
fxch %st(1)
fstps result
movl $1, %eax
movl $0, %ebx
int $0x80
操作步骤如下:
1. 初始化FPU :使用 FINIT 指令初始化FPU,将控制和状态寄存器
超级会员免费看
订阅专栏 解锁全文
2408

被折叠的 条评论
为什么被折叠?



