FFREE ST(i) 修改 x87 标记字中的哪些位?
Which bits in the x87 tag word does FFREE ST(i) modify?
这个例子写在 NASM:
section .bss
var28: resb 28
section .text
_main:
; Initialize
finit
fldpi
; Read Tag Word
fstenv [var28]
mov ax, [var28 + 8] ; move the Tag Word to ax
此时ax=0011 1111 1111 1111,表示ST7=00(有效),其余为11(空)。
其余代码:
; FFREE ST(i)
ffree ST7 ; Sets tag for ST(i) to empty.
; Read Tag Word
fstenv [var28]
mov ax, [var28 + 8] ; move the Tag Word to ax
此时ax=0011 1111 1111 1111也是。
我的问题是,不应该是 ax = 1111 1111 1111 1111?
At this point ax = 0011 1111 1111 1111, which means ST7 = 00 (valid),
and the rest is 11 (empty).
否。 Tag Word 是指寄存器 (R7..R0),而 ST(i)
是指可以更改的 "top of the stack" (TOS)。
第一个fldpi
将TOS (=ST(0)
) 设置为寄存器R7 并将PI 加载到该寄存器中。第二个 fld
将更改 TOS 以注册 R6 并填充该寄存器。 ST(0) 将指向第二个 fld
的寄存器。 ffree st0
将释放 R6(标记字中的第二个标记)并将 ST0 设置为 R7。状态字包含一个三位数字以及 TOS 当前指向的寄存器。
在您的示例程序中,fldpi
将 PI 加载到指向 R7 的 ST(0)
中。要清空 R7,您必须使用 ffree st0
.
请查看 Intel Manual Vol. 1 的第 8 章,其中有详细讨论。
这个例子写在 NASM:
section .bss
var28: resb 28
section .text
_main:
; Initialize
finit
fldpi
; Read Tag Word
fstenv [var28]
mov ax, [var28 + 8] ; move the Tag Word to ax
此时ax=0011 1111 1111 1111,表示ST7=00(有效),其余为11(空)。
其余代码:
; FFREE ST(i)
ffree ST7 ; Sets tag for ST(i) to empty.
; Read Tag Word
fstenv [var28]
mov ax, [var28 + 8] ; move the Tag Word to ax
此时ax=0011 1111 1111 1111也是。
我的问题是,不应该是 ax = 1111 1111 1111 1111?
At this point ax = 0011 1111 1111 1111, which means ST7 = 00 (valid), and the rest is 11 (empty).
否。 Tag Word 是指寄存器 (R7..R0),而 ST(i)
是指可以更改的 "top of the stack" (TOS)。
第一个fldpi
将TOS (=ST(0)
) 设置为寄存器R7 并将PI 加载到该寄存器中。第二个 fld
将更改 TOS 以注册 R6 并填充该寄存器。 ST(0) 将指向第二个 fld
的寄存器。 ffree st0
将释放 R6(标记字中的第二个标记)并将 ST0 设置为 R7。状态字包含一个三位数字以及 TOS 当前指向的寄存器。
在您的示例程序中,fldpi
将 PI 加载到指向 R7 的 ST(0)
中。要清空 R7,您必须使用 ffree st0
.
请查看 Intel Manual Vol. 1 的第 8 章,其中有详细讨论。