Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

difference between code and microcode

Not open for further replies.


Full Member level 5
Feb 28, 2014
Reaction score
Trophy points
Activity points
What the different between a code an a microcode? Because a microprocesor is a sequential machine which combine sequential (flip-flops as registers) with combinational circuit (logic gates which made operation between register).

When a microprocesor made the fetch of an instruction, the µP decode it an allows some combinational circuit and some register as input and output for that combinational circuit. The code is the instruction readed and the nexts data binary word necesary for that instruction. And the microcode? where is it?

microcode is in the control unit of the microprocessor.

But, how can someone program microcode? for me it can not be programed because it is how the decode and the timmer works

you cannot program the microcode.

only the designer of the microprocessor can do it.
not the user of the processor.
Conceptually, code and microcode can be though of as being the same. It just that there is a hierarchy of state machines to program. The higher level instruction set that is publicly available gets decoded to select a lower instruction set that is very specific to the hardware running the code.

There used to be some machines that allowed you to program the microcode, but processors have become too complex for anyone outside of the team developing the processor to invest the time to learn how to program it, plus most companies keep the design of their processors proprietary, so it's no longer an option.
Modern micrprocessors use pipeline stages and have a lot of often complex instructions. There are two ways to implement these instructions one is to hard code them and the other is to micrcode them. What does that mean?

For each instruction there is a set of tasks that the processor must carry out and they will depend on the category of the instruction e.g all instructions like read memory, write memory, move memory e.t.c will require similar steps then instructions like add, substract, multiply fall into another category, then instructions like AND, OR, XOR fall into another. It is possible to physically (on silicon) design seperate "circuit paths" to execute each of these instructions. This will give us a fast design, but it will be challenging to do its physical layout and if we want to add new instructions to the ISA we have to do the physical layout again! This means that if we "hard code" the instructions and we want to upgrade our processor we shall have to rethink how to do the layout for fabrication which is going to be an expensive task.

The other alternative that engineers have come up with is to use microcodes. Thus, the processor pipeline is designed to carry out only very simple tasks and these tasks are given to it as "microcode instructions" from within the hardware itself. Now each instructions in the ISA of the processor is basically going to equal multiple "microcode" instructions in the processor. Now instead of having different physical path for the different type of instructions in the processor, we store different "microcode programs" >inside< the processor for different insturctions. A complex instruction like "mov" or "div" is thus decoded internally to determine which "microcode program" in the processor needs to be executed. The advantage here is that we think when we want to expand the instruction set, we maybe often by able to leave the physical layout of the processor the same and merely create new "microcode programs" for the new insturctions. This saves time and money when we want to upgrade out processor design. So the point is, the microcode is not known by us. We just write our program, which is compiled into machine code of say 32 bit instructions. When we pass an instruction to the processor it decodes it to multiple microcode instructions. Yes that is correct, a 32 bit instruction is further decoded into multiple even lower level "microcode" instructions inside the hardware which are invisible to us.
When we pass an instruction to the processor it decodes it to multiple microcode instructions. Yes that is correct, a 32 bit instruction is further decoded into multiple even lower level "microcode" instructions inside the hardware which are invisible to us.

So, this is risk? For example, in intel 8086 there was not an multiply instruction, you had to do it whit ADD in a loop. The microcode are basic intructions likes ADD or SUB. The datasheet for a intel core i3 says it have MUL instruction, it's like this

MUL BL (multiply EB low with acumulator)

That's a code, and the ADD is the microcode, so the microcode program will be


That code is implemented by the unit control when the program code is


that's right?

The microcode program does not have to be the same as the ISA itself. It does not need to be known by us. Unfortunately, I am not aware of an actual implementation of a microcode so I cannot comment any further. All I know is that our instructions that are actually part of ISA are internally decoded and "microinstructions" from a "microprogram" are fetched which determine the steps of how the actual instruction we wrote into our program would be executed. What this microprogram looks like, I don't know. I would expect it to be hidden detail though.

The whole point as I stated earlier is to make processor design and modification simpler for the design engineer.

A fairly good example of the use of microcode techniques can be found in processor design employing bit-slice processor units. Although, admittedly the use of bit-slice technology is getting a bit long in the tooth, the basic fundamentals employed by these designs is still sound. There have been a few textbooks published on the topic and while most are out-of-print, they are still readily available in used book venues, like Amazon Marketplace. One text that is particular noteworthy is John Mick's:

Bit-slice Microprocessor Design

Mick's text in based on the Advanced Logic Devices AM2900 family of bit-slice devices and consists of the course materials for a nine part course covering microprogramming (microcode development) and design of processor cores employing the AM2900 family of bit-slice devices.

The Circuit Cellar magazine published a series of articles on the synthesis of the AM2900 family of bit-slice devices for FPGA implementation, the associated development of the required microcode and eventual programming of the resulting design using a customized assembler. The three part series of articles, Getting Started with Microprogramming by Thomas Mitchell were published in the April, May and June of 2011 issues of Circuit Cellar magazine and were quite informative.

I also came across the attached PDF some time ago which written for a course at the Florida Institute of Technology, covering the development of microcode for a processor core design employing the AM2900 family of bit-slice devices in it's design.



  • BitSlice.pdf
    695.7 KB · Views: 54
@tggzzz, I tried my best. I am not an expert in this field but answers to the best of my abilities. Thanks for the correction. it seems to me that the older devices have had user -accessible microcode. However, the new ones do not have it,

Not open for further replies.

Part and Inventory Search

Welcome to