gcc - 如何在 gnu 汇编器中使用十进制表示形式发出浮点立即操作数

标签 gcc assembly x86 floating-point gnu-assembler

例如,0.5f 在目标平台中为 0x3F000000。我想使用类似 movl $0.5,%eax 而不是 movl $0x3F000000,%eax

汇编器来自 TDM-GCC。

最佳答案

您需要使用 .float, .single or .double directives 声明一个单独的常量

例如

.data
        half: .float 0.50
.text
.globl _start
        _start:
        movl half, %eax

https://en.wikibooks.org/wiki/X86_Assembly/AVX,_AVX2,_FMA3,_FMA4

您还可以在 inline assembly 中使用 E/F/G/H 约束

static const float half = 0.5f;
__asm__ __volatile__ ("\n\
   movl %1, %eax        %1"
   : "g" (half)
   ) ;

关于gcc - 如何在 gnu 汇编器中使用十进制表示形式发出浮点立即操作数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42048247/

相关文章:

c - 为什么 gcc 和 clang 没有将 strlen 提升到这个循环之外?

c++ - 简单构造函数的复杂编译器输出

x86 - 我可以使用 LLVM jit 生成 AVX 矢量化代码吗?

c++ - 如何保留命令行选项但向 gcc 中的某些函数添加更多优化标志

c++ -/usr/lib/libstdc++.so.6 : version `GLIBCXX_3.4.15' not found

assembly - 8085 中的辅助进位和进位标志

assembly - 汇编中的标签如何知道它的运行时地址?

c - gdb "info frame"中没有 epb/eip 寄存器

c - 为什么 `__builtin_{{s,u}{add,sub,mul}ll_overflow` 给出 `long int` 结果而不是 `long long int` 结果?

windows - 将 MASM 程序与链接导致错误加载 mspdbcore.dll(错误代码 : 193)