How do I interpet this x86_64 assembly opcode?

前端 未结 2 1490
小鲜肉
小鲜肉 2021-02-19 05:27

Looking at some assembly code for x86_64 on my Mac, I see the following instruction:

48 c7 c0 01 00 00 00  movq    $0x1,%rax

But nowhere can I

2条回答
  •  孤街浪徒
    2021-02-19 05:53

    Actually, mov is 0xc7 there; 0x48 is, in this case, a long mode REX.W prefix.

    Answering also the question in comments: 0xc0 is b11000000. Here you can find out that with REX.B = 0 (as REX prefix is 0x48, the .B bit is unset), 0xc0 means "RAX is first operand" (in Intel syntax; mov rax, 1, RAX is first, or, in case of mov, output operand). You can find out how to read ModR/M here.

提交回复
热议问题