| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 835 人关注过本帖
标题:fpu寄存器堆栈加载浮点数出现值错误
只看楼主 加入收藏
xuzejia_love
Rank: 2
等 级:论坛游民
帖 子:41
专家分:49
注 册:2010-12-5
结帖率:100%
收藏
 问题点数:0 回复次数:1 
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 编辑 ]
搜索更多相关主题的帖子: 寄存器 
2011-05-02 01:07
xuzejia_love
Rank: 2
等 级:论坛游民
帖 子:41
专家分:49
注 册:2010-12-5
收藏
得分:0 
各位哥们,帮菜鸟救救火呀!

学的是语法,要的是算法。
2011-05-02 21:55
快速回复:fpu寄存器堆栈加载浮点数出现值错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035697 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved