While learning assembly language from a book there is a listing showing some basic operations:
segment .data
a dq 176
b dq 4097
segment .text
global _start
_start:
mov rax, [a] ; Move a into rax.
add rax, [b] ; add b o rax.
xor rax, rax
ret
After assembling with "$yasm -f elf64 -g dwarf2 -l listing.lst listing.asm"
command and linking with "$ld -o listing listing.o"
I ran the program in gdb. There whenever I tried to print the value of a variable, gdb showed this error message:
(gdb) p a
'a' has unknown type; cast it to its declared type
Same for the other variable 'b'. However casting 'a' or 'b' for int worked:
(gdb) p (int)a
$11 = 176
(gdb) p (int)b
$12 = 4097
But isn't this supposed to work without casting? Why do I need to cast? What mistake I've made in my source file?