Skip to content
Hideaki Takahashi edited this page Apr 18, 2024 · 37 revisions

Welcome to the MyDisassembler wiki!

x86-64の命令は一般的に以下のような構成となっている。

|prefix | REX prefix  |     opecode      |   ModR/M    |   SIB       |     address offset     |      immediate         |
------------------------------------------------------------------------------------------------------------------------
|       | 0 or 1 byte | 1, 2, or 3 bytes | 0 or 1 byte | 0 or 1 byte | 0, 1, 2, 3, or 4 bytes | 0, 1, 2, 3, or 4 bytes |

転送命令では、転送元が右側、転送先の左側に来る。

    mov   rax, 1234567890          ; rax = 1234567890
    mov   rax, [rsi + rdi * 4]     ; rax = Memory[rsi + rdi * 4]
    mov   rax, rbx                 ; rax = rbx
    mov   [rsi + rdi * 4], rax     ; Memory[rsi + rdi * 4] = rax

演算命令では、左側に結果が格納される。

    add   rax, 1234567890          ; rax = rax + 1234567890
    add   rax, [rsi + rdi * 4]     ; rax = rax + Memory[rsi + rdi * 4]
    add   rax, rbx                 ; rax = rax + rbx
    add   [rsi + rdi * 4], rax     ; Memory[rsi + rdi * 4] = Memory[rsi + rdi * 4] + rax

メモリアドレスは、ベースレジスタ + インデックスレジスタ * スケール + 定数という形式で指定することができる。

REX Prefix

bit   |3|2|1|0|
------|-|-|-|-|
field |W|R|X|B|
フィールド名 | ビット位置 | 定義
------------|-----------|-----------------------------------------------------------------
         B  |         0 | ModRM の r/m、SIB の base、またはオペコードのregの各フィールドの拡張
         X  |         1 | SIB のindex フィールドの拡張
         R  |         2 | ModRM のreg フィールドの拡張
         W  |         3 | 0 = デフォルトのオペランドサイズ、1 = 64 ビットのオペランド・サイズ

ModR/M (Mode Register Memory)

ModR/Mはオペコードの直後においてレジスタとアドレッシングモードを指定するための1バイトのデータ。

bit   |7|6|5|4|3|2|1|0 
------|-|-|-|-|-|-|-|-
field |mod| reg | r/m 
-----------------------
rex   |   | r   | b

Useful Resources

Clone this wiki locally