Basic computer operation question but I'm not sure how to ask it. When we say that a computer has an instruction set, how does the computer know what that set is? Is it stored in a ROM chip? Is it stored in the CPU somewhere? Where did the manufacturer put it so that it can read a disk and start processing machine code?
First, it fetches instructions from your computer's memory. Next, it decodes or translates these instructions into binary instructions (or a series of 1s and 0s) so the computer can understand the instructions. Finally, it executes these instructions and stores the output in its memory.
The CPU is designed to understand a set of instructions - the instruction set. It fetches the instructions from the main memory and executes them. This is done repeatedly from when the computer is booted up to when it is shut down. The CPU fetches the instructions one at a time from the main memory into the registers.
Each opcode will consist of an instruction of N bytes, which then expects the subsequent M bytes to be data (memory pointers etc.). So the CPU uses each opcode to determine how manyof the following bytes are data.
The CPU, or central processing unit, is a large chip inside the computer. This is the brains of the computer: it controls everything. It works by reading instructions and data from the random access memory (RAM), performing an instruction, and then writing the data back to RAM.
Short answer: The actual circuitry in the processor of the computer is what "determines" the instruction set.
Relatively short answer: The software that runs on the processor is physically just patterns of electrical signals. The transistors in the computer switch on and off many, many, many times a second, modifying these patterns of signals based on other signals. For example, consider the mov
instruction found on just about every processor out there:
mov dest, src
This is encoded by a certain electrical signal pattern "stored" in memory. That signal pattern activates certain transistors on and off in such a way that the signals stored at dest
matches that at src
, because of how the circuitry is wired.
Long answer: Take a class in computer architecture. :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With