Intel汇编-三角函数fsin

# An example of using the FSIN and FCOS instructions
#
# 三角函数
#
# radians = (degrees * pi) / 180
#
# fsts degree1        # load the degrees value stored in memory into ST0
# fidivs val180        # divide by the 180 value stored in memory
# fldpi            # load pi into ST0, degree/180 now in ST1
# fmul %st(1), %st(0)    # multiply degree/180 and pi, saving in ST0
# fsin            # perform trig function on value in ST0
#
# 在产品型的程序中,预先计算pi/180的值并且把它存储在FPU中显然要快得多,而不是每次都计算这个值
#

    .section .data
degree1:
    .float 90.0
val180:
    .int 180

    .section .bss
.lcomm radian1, 4
.lcomm result1, 4
.lcomm result2, 4

    .section .text
    .globl main
main:
    nop
    finit
    flds degree1
    fidivs val180
    fldpi
    fmul %st(1), %st(0)
    fsts radian1
    fsin
    fsts result1
    flds radian1
    flds radian1
    fcos
    fsts result2

    movl $1, %eax
    movl $0, %ebx
    int $0x80

# gcc -g -o 08 08-fsin-fcos.s -m32
#
# st0            -4.37113900018644366547e-08 (raw 0xbfe6bbbd2e7b967fef2c)
#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值