使用十六进制在汇编代码中编写指令

问题描述 投票:1回答:1

我知道以下语法是x86中的普通汇编代码:

.text
   .globl _strat
_start:
   push %rbp
...

但是我遇到了以下代码片段,并没有真正理解它。这些说明是否以十六进制表示?

.text
   .globl _start
start:
.QWORD 0xc874b6f63392f085,0x3beac554c8f10c52,0x848,0x8600000004c,0x8c00000004c,0x920000001f4
...

每个,代表什么?这是一个组合在一行的指令列表吗?

assembly
1个回答
2
投票

我有一个我写的反汇编程序,允许将内存转储粘贴到其中。但是您可以使用objdump来反汇编代码。这是我用objdump来反汇编的方法。

首先,我通过运行以下程序创建了包含这些内容的二进制文件。 (可能更简单的方法;这是我选择的。)

$ cat b.c
#include <stdint.h>
#include <stdio.h>

int main()
{
    static const uint64_t s[] = { 0xc874b6f63392f085,0x3beac554c8f10c52,0x848,0x8600000004c,0x8c00000004c,0x920000001f4 };
    fwrite(s, 1, sizeof s, stdout);
    return 0;
}

$ cc b.c
$ a.out > bin
$ objdump -D -b binary -m i386 -M intel bin
bin:     file format binary
Disassembly of section .data:

00000000 <.data>:
   0:   85 f0                   test   eax,esi
   2:   92                      xchg   edx,eax
   3:   33 f6                   xor    esi,esi
   5:   b6 74                   mov    dh,0x74
   7:   c8 52 0c f1             enter  0xc52,0xf1
   b:   c8 54 c5 ea             enter  0xc554,0xea
   f:   3b 48 08                cmp    ecx,DWORD PTR [eax+0x8]
  12:   00 00                   add    BYTE PTR [eax],al
  14:   00 00                   add    BYTE PTR [eax],al
  16:   00 00                   add    BYTE PTR [eax],al
  18:   4c                      dec    esp
  19:   00 00                   add    BYTE PTR [eax],al
  1b:   00 60 08                add    BYTE PTR [eax+0x8],ah
  1e:   00 00                   add    BYTE PTR [eax],al
  20:   4c                      dec    esp
  21:   00 00                   add    BYTE PTR [eax],al
  23:   00 c0                   add    al,al
  25:   08 00                   or     BYTE PTR [eax],al
  27:   00 f4                   add    ah,dh
  29:   01 00                   add    DWORD PTR [eax],eax
  2b:   00 20                   add    BYTE PTR [eax],ah
  2d:   09 00                   or     DWORD PTR [eax],eax
        ...
© www.soinside.com 2019 - 2024. All rights reserved.