I am having difficulty debugging or understanding the following error from gas
:
movq $0x4461766964, -8(%rbp) # "David" in hex
mov $SYS_STDOUT, %edi
lea -8(%rbp), %rsi
mov $5, %edx
mov $SYS_WRITE, %eax
syscall
Yet I get the following error:
file.s:33: Error: operand size mismatch for `movq'
I thought the movq
command would move 8 bytes, from -8(%rbp) to -0(%rbp) so the resulting memory would look like:
%rbp-8 -7 -6 -5 -4 -3 -2 -1
D a v i d
What do I seem to be missing or misunderstanding here? Note, doing movl
seems to work here, it just truncates the number to 4-bytes, movl $0x4461766964, -8(%rbp)
:
$ ./file
# file.s: Assembler messages:
# file.s:33: Warning: 293692926308 shortened to 1635150180
# diva
And of course this works when adding it byte-by-byte:
movb $0x44, -8(%rbp)
movb $0x61, -7(%rbp)
movb $0x76, -6(%rbp)
movb $0x69, -5(%rbp)
movb $0x64, -4(%rbp)
Or this:
movl $0x44617669, -8(%rbp)
movl $0x64, -4(%rbp)
So why does the movq
act so differently here?