fpu寄存器堆栈加载浮点数出现值错误
程序代码:
#floattest.s - An example of using float point numbers /*一个使用浮点数的例子*/ .section .data values1: .float 12.34 values2: .float 2353.631 .section .bss .lcomm data,8 .section .text .globl _start _start: nop flds values1 /*加载单精度浮点数到fpu register stack*/ fldl values2 /*加载双精度浮点数到fpu register stack*/ fstl data /*获取fpu register stack中顶部的浮点值*/ movl $1,%eax movl $0,%ebx int $0x80
文件保存为:floattest.s,然后执行了:as -gstabs -o floattest.o floattest.s,接着执行:ld -o floattest floattest.o,一切都正常,然后用gdb调试,就发现了一个很奇怪的问题了:
user@user:~/as$ gdb floattest
GNU gdb (GDB) 7.2-ubuntu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://www.
Reading symbols from /home/xuzejia/as/floattest...done.
(gdb) b *_start+1
Breakpoint 1 at 0x8048075: file floattest.s, line 13.
(gdb) r
Starting program: /home/xuzejia/as/floattest
Breakpoint 1, _start () at floattest.s:13
13 flds values1 /*加载单精度浮点数到fpu register stack*/
(gdb) n
14 fldl values2 /*加载双精度浮点数到fpu register stack*/
(gdb) n
15 fstl data /*获取fpu register stack中顶部的浮点值*/
(gdb) print $st0
$1 = 5.7256268152333960578739033789173323e-315
(gdb) print $st1
$2 = 12.340000152587890625
(gdb)
fpu寄存器堆栈中,st0寄存器数值出现了错误,而st1数值并没有错,这个是怎么回事呢?望赐教。
[ 本帖最后由 xuzejia_love 于 2011-5-1 17:08 编辑 ]