nasm将mov rax 1组装为mov eax 1?

时间:2018-09-13 13:07:34

标签: assembly gdb nasm x86-64

我在下面编写简单的汇编hello_word.asm:

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

在我使用nasm和ld(x64位)进行编译之后

nasm -f elf64 hello_word.asm -o hello_word.o
ld hello_word.o -o hello_word

当我使用gdb进行检查

 (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) 

我的问题: 为什么当我使用rax(64位)进行编码,但是随后使用gdb时,我得到的结果是eax(32位)。

  => 0x00000000004000b0 <+0>:   mov    eax,0x1
     0x00000000004000b5 <+5>:   mov    edi,0x1
     ...

我如何不能更改该结果? (我编译错了吗?)

我的信息:

  • nasm:版本2.13.03

  • gdb:8.1

  • Linux:4.16.8

0 个答案:

没有答案