.section .data
value:
.float 10.0
scale1:
.float 2.0
scale2:
.float -2.0
.section .bss
.lcomm result1, 4
.lcomm result2, 4
.section .text
.global _start
_start:
nop
finit
flds scale1
flds value
fscale
fsts result1
flds scale2
flds value
fscale
fsts result2
movl $1, %eax
movl $0, %ebx
int $0x80
(gdb) x/f &result1
0x80490b8 <result1>: 40
(gdb) x/f &result2
0x80490bc <result2>: 2.5
a^k = x --- 1
b^n = x --- 2
b^m = a --- 3
b^(mk)=x --- 4
b^(mk) = b^n
mk=n
k = n/m
k=log(a)x
n=log(b)x
m=log(b)a
log(b)X = (1/log(2) b) * log(2) X)
.section .data
value:
.float 12.0
base:
.float 10.0
.section .bss
.lcomm result, 4
.section .text
.global _start
_start:
nop
finit
fld1 #加载 1.0
flds base #加载 10.0 (ST1=1.0, ST0=10.0)
fyl2x #log(2)10.0 (先弹出ST0和ST1再计算,结果存入 ST0 中, )
fld1
fdivp #计算 1/log(2)10.0 (fdivp 是 st0/st1)
fld1
flds value
fyl2x #计算 log(2)12.0
fmul %st(1), %st(0) # log(2)12.0 / log(2)10.0 (换底操作)
fsts result #存储结果
movl $1, %eax
movl $0, %ebx
int $0x80
(gdb) x/f &result
0x80490ac <result>: 1.07918119
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |