gpt4 book ai didi

macos - 后端错误 : 32-bit absolute addressing is not supported in 64-bit mode

转载 作者:行者123 更新时间:2023-12-01 12:29:25 24 4
gpt4 key购买 nike

嗨,我正在使用 gcc 在 mac 上处理 ASM intel_syntax noprefix,出于某种原因,我不断收到此信息 后端错误:64 位模式不支持 32 位绝对寻址
这是否与变量有关,目前已在 ASM 内联上使用?

这是我的代码:

#include <stdio.h>

char c, b;

int main() {

printf("Give me letter: ");
scanf(" %c", &c);

_

_asm( ".intel_syntax noprefix;"
"xor eax, eax;" // clear eax
"mov al, byte ptr [c];" // save c in eax
"cmp eax, 65;" // eax ? "A"
"jl Fin;" // eax < "A" -> Fin
"cmp eax, 90;" // eax ? "Z"
"jg UpC;" // eax >= Z -> Up Case
"add eax, 32;" // make low case
"jmp Fin;" // -> Fin
"UpC: cmp eax, 97;" // eax ? "a"
"jl Fin;" // eax < "a" -> Fin
"cmp eax, 122;" // eax ? "z"
"jg Fin;" // eax > "z" -> Fin
"sub eax, 32;" // make Up Case
"Fin: mov byte ptr [b], al;" // save res in b
".att_syntax");

printf("Case changed : %c\n", b);
}

最佳答案

是的,正如错误所说,在 osx 上不允许使用绝对引用,其中 byte ptr [c]组装到。作为解决方法,您可以尝试 byte ptr c[rip] .

请注意,在内联汇编块中切换语法是非常糟糕的做法,您应该使用 -masm=intel编译器开关。此外,gcc inline asm 不应该这样使用,通常您使用约束机制来引用参数。

关于macos - 后端错误 : 32-bit absolute addressing is not supported in 64-bit mode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35834937/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com