Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between the various MOV opcodes?

In reference guides I see that MOV is opcodes 88, 89, 8A, ... etc.. Why are there multiple opcodes for one instruction?

like image 690
jl6 Avatar asked Apr 14 '14 07:04

jl6


People also ask

What is the opcode for mov?

"mov" is an instruction, encoded with the operation code or "opcode" 0xb8. Since mov takes an argument, the next 4 bytes are the constant to move into eax. The opcode 0xb9 moves a constant into ecx. 0xba moves a constant into edx.

How many different opcodes can be there opcodes?

a) What is the minimum number of bits required to represent the OPCODE? There are 255 OPCODES and each requires a unique pattern. Therefore, we need ceil(log2255) = 8 bits.

What is the difference between opcodes and operands?

Opcodes and operands The opcode is the instruction that is executed by the CPU and the operand is the data or memory location used to execute that instruction.

What does MOV EAX 4 mean?

; print a byte to stdout mov eax, 4 ; the system interprets 4 as "write" mov ebx, 1 ; standard output (print to terminal) mov ecx, variable ; pointer to the value being passed mov edx, 1 ; length of output (in bytes) int 0x80 ; call the kernel.


2 Answers

That is because those instructions are slightly different from the CPU point of view. Although mnemonic is the same, operands are different. For example in this reference, the instruction column clearly shows the difference between those opcodes.

like image 155
Mika Lammi Avatar answered Sep 30 '22 01:09

Mika Lammi


They are for different type of sources and destinations. To the CPU there is so much difference between moving 8 and 16/32 bit values to and from registries and memory locations that it is encoded as different opcodes.

List of opcodes.

like image 43
Anders Abel Avatar answered Sep 30 '22 01:09

Anders Abel