What is the difference between operating code (opcode) and instruction set (Instruction set)

Asked

Viewed 448 times

-1

What’s the difference between them? I know they both show commands that exist in each architecture.

  • Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).

1 answer

2

Roughly speaking we can say that opcode is the instruction, and of course Instruction set is a set of them. So the relationship and what differs between them is basically this.

I think I don’t need to explain what a set is, I’m going to talk a little bit better now what it is opcode.

In fact opcode is not really an instruction, it is a part of it. And here it is necessary to better understand what is the difference between these two things.

The instruction is like the statement of high-level languages. It is the whole line that tells you to do something and has a number that defines what will be done and other information that gives more specificity and tells you what to do. We can say, just to facilitate the understanding that it would be like calling a function, where you have her name and arguments.

Opcode is the reduction of Operation code. He’s just the part that says what the operation is to be done and it’s strictly a documented number. But in Assembly people use a mnemonic named instead of a number. The number is 1 byte.

Since it can have more than 256 "commands" (instructions) different for the processor the combination of a few bytes makes the instruction. The part that comes after the main byte identifies which registers will be affected, whether it will do with memory, or operation modes. In general what defines these secondary things are opcodes which become specific used in conjunction with the main.

Only literal values or constants used in the code are not opcodes.

The statement considers the arguments and the variations can be much larger. For example

xor rax, rax
xor rax, rbx

We have the same first and second opcodes, but different instructions because changes the third.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.