microcode and asm the same thing ?

Status
Not open for further replies.
I'm not an EE guy, but this is what I think I know:

ASM is a programming language. It translates nearly directly into machine code. The machine code is loaded into the processor. The microcode is a program in the core of the processor that tells the processor what to do with each machine code.

I think there have been processors where the machine code didn't need to be translated, each bit in the machine code directly affected certain transistors on the chip. But I'm betting there hasn't been one of those in a long time.
 

wb

Ars Legatus Legionis
25,208
Subscriptor
No, they are not the same.

The machine code is loaded into the processor. The microcode is a program in the core of the processor that tells the processor what to do with each machine code.

Uh...not...exactly.


Microcode is basically a bitwise mapping or "translator" from one set of bits to another, implemented in hardware.

You can implement a microcode with a ROM; each address in the ROM represents the "source" instruction code, and the contents of that memory location would represent the "translated" instruction.

There are a couple of applications for this. First and foremost, you can use this idea to create what's called a "microcoded state machine." Each "source" code represents the current state, and the "translated" code represents the next state. Although nowadays most things use microcontrollers (which are just microprocessors bundled on-chip with other stuff like RAM, timers, I/O, etc.), simple state machines like this are very good for certain applications, like controllers for vending machines, or traffic lights.

Another, cooler thing you can do with a microcoded ROM is to quickly translate between two different processor's instruction sets in hardware. What you do is take the source instruction as the address to look up in the ROM, and the contents of the ROM at that address will be the target instruction for the other processor.

Now, there are of course a lot of caveats with that kind of direct translation, and generally speaking that doesn't work on modern processors for a variety of reasons, but back in the day it was a clever way to create a device that was compatible with another processor's instruction set.

I know I left a lot of stuff out, but I was trying to keep my explanation really short, and only cover the highlights.
 
Status
Not open for further replies.