osx - error in backend: 32-bit absolute addressing is not supported in 64-bit mode -
hi i'm working on asm intel_syntax noprefix on mac using gcc, reason keep getting error in backend: 32-bit absolute addressing not supported in 64-bit mode has variables, @ moment been use on asm inline?
here's code:
#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 -> 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 case "fin: mov byte ptr [b], al;" // save res in b ".att_syntax"); printf("case changed : %c\n", b); }
yes, error says, on osx not allowed use absolute references byte ptr [c]
assembles to. workaround try byte ptr c[rip]
.
note bad practice switch syntax in inline assembly block, should use -masm=intel
compiler switch. also, gcc inline asm not supposed used that, use constraint mechanism reference arguments.
Comments
Post a Comment