I code simple assembly hello_word.asm below:
global _start
section .text
_start:
mov rax, 1
mov rdi, 1
mov rsi, hello_word
mov rdx, len_hw
syscall
mov rax, 60
mov rdi, 1
syscall
section .data
hello_word: db 'Hello word ! I am ctnguyenvn', 0xa
len_hw: equ $-hello_word
after i compile using nasm and ld (x64 bit)
nasm -f elf64 hello_word.asm -o hello_word.o
ld hello_word.o -o hello_word
when i using gdb to check
(gdb) set disassembly-flavor intel
(gdb) break _start
Breakpoint 1 at 0x4000b0
(gdb) run
Starting program: /data/MEGA/Self_Learning/ASM/HelloWord
Breakpoint 1, 0x00000000004000b0 in _start ()
(gdb) disassemble
Dump of assembler code for function _start:
=> 0x00000000004000b0 <+0>: mov eax,0x1
0x00000000004000b5 <+5>: mov edi,0x1
0x00000000004000ba <+10>: movabs rsi,0x6000d8
0x00000000004000c4 <+20>: mov edx,0x1d
0x00000000004000c9 <+25>: syscall
0x00000000004000cb <+27>: mov eax,0x3c
0x00000000004000d0 <+32>: mov edi,0x1
0x00000000004000d5 <+37>: syscall
End of assembler dump.
(gdb)
My question: why when i code using rax (64bit) but then when using gdb i get the result is eax (32bit).
=> 0x00000000004000b0 <+0>: mov eax,0x1
0x00000000004000b5 <+5>: mov edi,0x1
...
How can I not change that result? (did i have compile wrong ?)
My info:
nasm: version 2.13.03
gdb : 8.1
Linux: 4.16.8