In a typical instruction cycle, fetching, decoding, executing together form one cycle. My question is about the decoding step: What is the part that gets decoded, is it the instruction's opcode? If so, why it is encoded then?
In fact, I understand decoding here in similar way as what you decode a message given a key in the field of security, which is what confuses me a bit.
Answer
Decode means to parse the instruction to determine its meaning.
A typical instruction consists of an opcode and (usually) one or more arguments. These arguments may refer to specific registers or memory addresses or can be immediate values to be used directly during execution. In addition, some instructions may have prefixes (such as LOCK
in x86) or function codes (such as the funct
field for some MIPS instructions) that alter their functionality.
During decoding, the processor needs to:
- determine what instruction is represented by the opcode so that the instruction can be issued to the correct execution unit and that the correct operation is performed
- correctly interpret the arguments, prefixes, and other values attached to the instruction and pass the relevant information to the relevant circuitry
- (in most modern processor designs) break the instruction down into its corresponding micro-operations
With modern processors, this can be a complex operation that requires multiple stages in the pipeline. To speed this process up, a dedicated cache may be used to store micro-operations for frequently-executed instructions.
For more on the techniques used to deliver high performance in modern processors, you might want to read this answer.
No comments:
Post a Comment