Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I interpet this x86_64 assembly opcode?

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 find a reference that breaks down the opcode. It seems like 48c7 is a move instruction, c0 defines the %rax register, etc.

So, where can I find a reference that tells me all that?

I am aware of http://ref.x86asm.net/, but looking at 48 opcodes, I don't see anything that resembles a move.

like image 588
Christoph Avatar asked Jun 24 '12 19:06

Christoph


People also ask

What is x86 opcode?

The x86 opcode bytes are 8-bit equivalents of iii field that we discussed in simplified encoding. This provides for up to 512 different instruction classes, although the x86 does not yet use them all.

How many x86_64 instructions are there?

states that the current x86-64 design “contains 981 unique mnemonics and a total of 3,684 instruction variants” [2]. However they do not specify which features are included in their count.

Is x86 assembly machine code?

It is used to produce object code for the x86 class of processors. Regarded as a programming language, assembly is machine-specific and low-level. Like all assembly languages, x86 assembly uses mnemonics to represent fundamental CPU instructions, or machine code.

What is x86 assembly instructions?

The x86 instruction set refers to the set of instructions that x86-compatible microprocessors support. The instructions are usually part of an executable program, often stored as a computer file and executed on the processor.


1 Answers

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.

like image 133
Griwes Avatar answered Sep 20 '22 14:09

Griwes