如何:x86 中的 pow(real, real) [英] How to: pow(real, real) in x86

查看:17
本文介绍了如何:x86 中的 pow(real, real)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 x86 程序集中寻找 pow(real, real) 的实现.我也想了解算法的工作原理.

I'm looking for the implementation of pow(real, real) in x86 Assembly. Also I'd like to understand how the algorithm works.

推荐答案

只需将其计算为 2^(y*log2(x)).

有一个 x86 指令 FYL2X 来计算 y*log2(x) 和一个 x86 指令 F2XM1 来做幂运算.F2XM1 需要 [-1,1] 范围内的参数,因此您必须在两者之间添加一些代码来提取整数部分和余数,对余数求幂,使用 FSCALE 以适当的 2 次幂缩放结果.

There is a x86 instruction FYL2X to compute y*log2(x) and a x86 instruction F2XM1 to do exponentiation. F2XM1 requires an argument in [-1,1] range, so you'd have to add some code in between to extract the integer part and the remainder, exponentiate the remainder, use FSCALE to scale the result by an appropriate power of 2.

这篇关于如何:x86 中的 pow(real, real)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆