Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the CPU know its instruction set?

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?

like image 539
johnny Avatar asked Dec 13 '10 19:12

johnny


People also ask

How does a CPU understand instructions?

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.

Where does the CPU get its instructions from?

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.

How does the CPU tell the difference between instructions and data?

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.

How does the computer know what order to run instructions in?

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.


1 Answers

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. :-)

like image 144
In silico Avatar answered Jan 01 '23 10:01

In silico