radians = (degrees * pi) / 180
fsts degree1 # 装角度值到 ST0
fidivs val180 # 除以 180,结果存在 ST0 中
fldpi # 装 pi 到 ST0,上面的除法结果被移到 ST1 中
fmul %st(1), %st(0) #计算弧度值
.section .data
degree1:
.float 90.0
val180:
.int 180
.section .bss
.lcomm radian1, 4
.lcomm result1, 4
.lcomm result2, 4
.section .text
.global _start
_start:
nop
finit
flds degree1
fidivs val180
fldpi
fmul %st(1), %st(0)
fsts radian1
fsin
fsts result1
flds radian1
fcos
fsts result2
movl $1, %eax
movl $0, %ebx
int $0x80
(gdb) x/f &result1
0x80490bc <result1>: 1 # sin(90)
(gdb) x/f &result2
0x80490c0 <result2>: -4.37113883e-08 #cos(90)
.section .data
degree1:
.float 90.0
val180:
.int 180
.section .bss
.lcomm sinresult, 4
.lcomm cosresult, 4
.section .text
.global _start
_start:
nop
finit
flds degree1
fidivs val180
fldpi
fmul %st(1), %st(0)
fsincos
fstps cosresult #存完后弹出 ST0
fsts sinresult
movl $1, %eax
movl $0, %ebx
int $0x80
(gdb) x/f &cosresult
0x80490b0 <cosresult>: -2.71050543e-20
(gdb) x/f &sinresult
0x80490ac <sinresult>: 1
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |