Inline Assembly Intro - Float Point Register Usage
来源:互联网 发布:盘搜搜引擎源码 编辑:程序博客网 时间:2024/05/16 01:33
/* areatest.c - An example of using floating point regs */
#include <stdio.h>
int main()
{
int radius = 10;
float area;
asm(“fild %1\n\t”
“fimul %1\n\t”
“fldpi\n\t”
“fmul %%st(1), %%st(0)”
: “=t”(area)
:”m”(radius)
: “%st(1)”);
printf(“The result is %f\n”, area);
return 0;
}
The areatest.c program places the radius value into
a memory location, and then loads that value into
the top of the FPU stack with the FILD instruction.
That value is multiplied by itself, with the result
still in the ST(0) register. The pi value is then
placed on top of the FPU stack, shifting the squared
radius value down to the ST(1) position. The FMUL
instruction is then used to multiply the two values
within the FPU.
The output value is taken from the top of the FPU
stack and assigned to the area C variable. Because
the ST(1) register was used, but not assigned as an
output value, it must be listed in the changed
registers list so the compiler knows to clean it up
afterward.
- Inline Assembly Intro - Float Point Register Usage
- Inline Assembly Intro - Float Point Register
- Assembly x64 Intro - Register Usage
- Inline Assembly Intro - Register Mismatch
- Assembly Intro - Inline Assembly Versus Non-Inline Assembly
- Assembly x64 Intro - Floating Point Operate
- Fixed Point Float Intro - Q (number format)
- Assembly x64 Intro - Register Macro Define from OpenH264
- Inline Assemble Code - A problem relevant to register usage
- Inline Assembly
- Assembly Intro - Call Convention
- Assembly x64 Intro - Arrays
- Register Usage Conventions
- Assembly x64 Intro - GAS Assembly Issue
- Windows Dev Intro - Register Dll
- register、volatile、inline
- Assembly x64 Intro - Nasm Example
- Assembly x64 Intro - Nasm Syntax
- jsp知识点总结
- 事务
- The kth great number(优先队列)
- 1035. Password (20)
- C#实现两个数据库之间的数据上报
- Inline Assembly Intro - Float Point Register Usage
- 跨平台的.NET集成开发环境:MonoDevelop
- 九度 OJ 之 题目1538:GrassLand密码
- shell对比文件内容脚本分享
- Java 8 中的ConcurrentHashMap源码分析
- 【动态规划】[USACO2011 OPEN]修剪草坪
- 【Java】单例模式
- android中string.xml中%1$s、%1$d等的用法
- c++类的特性探究(一)