|This article does not have any sources. (September 2013)|
Microcode is the name for a number of instructions or data structures which are involved in implementing higher-level machine language in many processors, especially microprogrammed ones. Microcode is on memory that is very fast to access. When a machine level instruction needs to be executed, microcode tells the processor what electronic circuits should be used. When a new processor is designed, an engineer also writes the microcode for the instructions of machine language. This is called Microprogramming, the resulting code is called a microprogram.
In early processors, each instruction was hard-wired. This has several drawbacks, the most obvious is that correcting an error in processor design means that the processor needs to be replaced.
Example[change | change source]
A processor should add two values, which are in registers A and B.
- Configure the ALU for addition
- Put the value of register A on one input of the ALU
- Put the value of register B on one input of the ALU
- After waiting a short time, to allow for the addition, the result needs to be copied into a register, which has not been used yet
- The value of that register needs to be copied to register A
- The next instruction needs to be fetched from memory
Items 1-3, as well as 5-6 can be coded as one instruction. It is also possible to hard-wire the logic needed for this operation. This has the benefit of being faster, but the drawback that it no longer allows changes that might be needed later on.
The concept of microprogramming was developed by Maurice Wilkes in 1951, using diode matrices for the memory element.