How does microcode convert machine code into electrical signals?.




I was trying to find out how code interacts with CPUs and after some long research I found out that after the code gets converted into machine code, it gets sent to the CPU’s microcode (from what I understood it’s kind of a hardwired? firmware or something like that) which converts it into electrical signals so that the CPU can execute the instructions… But even after hours of research I just couldn’t find out how the microcode converts machine code into electrical signals.

In: Technology


It’s all down to the hardware.
A transistor is kinda like a light switch. Depending on if you put electricity into it, it will/will not allow electricity to pass.

You’ve probably come across the term OpCode in your research.
That’s a number that tells your CPU what to do.
But remember all numbers in a computer are a bunch of ones and zeroes.
These ones and zeroes are actually the configurations for a series of transistor switches in the CPU.
This causes electricity to flow around a particular circuit in your CPU corresponding to the OpCode.

When you press the power button, you turn on a circuit that loads the first instruction (flip the first switches).

Start searching for transistor as a switch and logic gates in digital circuits, everything will start making sense afterwards.
Machine code is nothing but groups of ones and zeros(binary, what we call them), ones and zeros are nothing but availability or absence of charges(voltages if you want). These are stored in memories(which is also made of transistors) and fed to cpu’s transistor ‘s inputs. transistors (billionsof them in todays CPU) read these ones and zeros, they turn on and off accordingly (as switches do) and pass on results to further blocks e.g. memories or other output devices. Memories keep them in ones and zeros and other devices like your screens turn them in to visible light(i have ignored, for simplicity, many drivers and other analog circuits in this path).
Firmware and something like that are bit higher level(meaning not exactly machine code level) concepts.

Edit: yes cpu has some sense of hardwired structure to it, to perform various basic operations, like add, subtract, multiply and other logical operations. Carefully structured and repeted use of these operations give us sense of complex task has been performed by cpu.
Carefully structured and desiged? Thats what is done by firmware, and then OS and then Application (each one is higher level than previous).

**Your submission has been removed for the following reason(s):**

Please search before submitting.

This question has already been asked on ELI5 multiple times.

If you need help searching, please refer to the [Wiki](