I have written a small piece of assembly with AT&T syntax and have currently declared three variables in the .data
section. However, when I attempt to move any of those variables to a register, such as %eax
, an error from gcc
is raised. The code and error message is below:
.data
x:.int 14
y:.int 4
str: .string "some string\n"
.globl _main
_main:
pushq %rbp
movq %rsp, %rbp
subq $16, %rsp
movl x, %eax; #attempting to move the value of x to %eax;
leave
ret
The error raised is:
call_function.s:14:3: error: 32-bit absolute addressing is not supported in 64-bit mode
movl x, %eax;
^
I have also tried moving the value by first adding the $
character in front of x
, however, a clang
error is raised:
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Does anyone know how the value stored in x
can be successfully moved to %eax
? I am using x86 assembly on Mac OSX and compiling with gcc
.