The compiled code is different from the assembly code when single-step debugging

Viewed 67

I am writing a shabby OS on Bochs, a x86 virtual machine tool, with assembly and c language. Everything was ok, but I find a bug. After debugging the code, I found that the Assembly code compiled by GCC(Actually I used objdump to get it) is different from disassembled code, which is a step-by-step debug on the CPU. Although they both have the same machine code, but the length of instruction is different.

Here is source C code. Source code:

int print(unsigned char* string)
{
    return printl(string);
}

This is the assembly code obtained by the Objdump tool. Assembly code:

assembly code;                 machine code
push %rbp;              55
mov  %rsp,%rbp;         48 89 e5
sub  $0x10,%rsp;        48 83 ec 10
mov  %rdi,-0x8(%rbp);   48 89 7d f8
mov  -0x8(%rbp),%rax;   48 8b 45 f8
mov  %rax, %rdi;        48 89 c7
callq 326 <printl>;     e8 84 ff ff ff
leaveq;                 c9
retq;                   c3

This is the disassembled code obtained on BOCHS virtual machine. disassembled code:

assembly code;                 machine code
push ebp;                      55
dec  eax;                      48
mov  ebp, esp;                 89e5
dec  eax;                      48
sub  esp;                      83ec10
dec  eax;                      48
mov  dword ptr ss:[ebp-8],edi; 897df8
dec  eax;                      48
mov  eax,dword ptr ss:[ebp-8]; 8b45f8
dec  eax;                      48
mov  edi, eax;                 89c7
call .-124;                    e884ffffff
leave;                         c9
1 Answers

You need to set the disassemble mode to 64-bit:

u size = 64

Related