12

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?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
johnny
  • 19,272
  • 52
  • 157
  • 259
  • Perhaps someone could explain instruction sets in relation to RISC and CISC computer architectures – Benj May 16 '19 at 11:05

7 Answers7

14

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

In silico
  • 51,091
  • 10
  • 150
  • 143
  • Great answer. 1) Is there any animated or graphical explanation for this? 2) I would like to build a circuit(with logic gates by hand or am I far away from sense?) which can "act" on my own set of instructions(don't want to be too trivial but just complex enough to understand how circuit "makes use of" / "acts on" the binary instruction written in assembly code). 3) How at the physical level this binary instruction(written in assembly code) is "read"/"acted upon" by the circuit? I mean how they come together or what other factor/hardware(if any) triggers the instructions to be fed to circuit. – user104309 Aug 16 '17 at 20:59
  • Any online course material that teaches to build a microprocessor like 8085 ( I am not sure how complex is 8085 but something very minimal to be considered as microprocessor which can act on custom-defined assembly code) with the smallest piece of hardware available(logic gates?)?I would like to have a visualization((abstract)physical) of inside of every hardware part inside a microprocessor and on every single physical movement-from powering up the device,storage of binary instructions in the appropriate part of muP as I type in the keyboard,"triggering" the "execution" of these instructions. – user104309 Aug 16 '17 at 21:41
8

The instruction set is hardwired into the CPU... It's actually a result of the way the circuit is built, there isn't an actual space where the instructions are kept.

When a computer starts, there's a small program on a ROM that knows how to initialize all the components and boot the OS. Because of the way a computer is built, this program is the first to run.

phuclv
  • 37,963
  • 15
  • 156
  • 475
Mircea Nistor
  • 3,145
  • 1
  • 26
  • 32
4

It sounds like you're conflating two different concepts:

Instruction set

An instruction set is the set of machine code instructions that the CPU is built to handle. The CPU doesn't have to load it from anywhere, it's built-in to the CPU itself. Examples of instruction sets are: Intel x86, MIPS.

Boot loader

The boot loader is a small program that tells the CPU how to get the computer started. Obviously it's written using the CPU instruction set, and usually resides in ROM or EEPROM or something. It tells the CPU how to interface with the disk to load a boot sector (which then loads more of the operating system). On a PC, the boot loader is part of the BIOS.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
2

When we say a computer has a given instruction set, it refers to the set of instructions (operation codes) the processor can understand. A machine is digitally designed to understand the instructions it will be able to receive. When you design a CPU, one of the components is the decoder, which is the part of the CPU that decodes the electrical signals; and performs computations it was instructed to compute by those signals (the instruction). If you're interested in how computers work at the core, I suggest reading CODE or The Elements of a Computing Systems

in70x
  • 1,170
  • 1
  • 10
  • 16
1

The CPU has a specific instruction set it does know how to execute. When you switch on the computer the CPU must be fed with instructions. It makes sense if the arriving instructions do the boot procedure. Where do that instructions come from? Normally a ROM (e.g. EPROM).

hol
  • 8,255
  • 5
  • 33
  • 59
0

You write code, which eventually compiles down to assembly instructions, which compile down ultimately into "machine code." When the CPU gets an instruction out of memory it decodes it. The decode process ends up setting various control bits within the processor pipeline that determine what the CPU does (loads/stores data, does math on operands, etc.). The instruction set determines how the hardware is implemented. It is effectively the essential set of operations that the processor is able to perform "in hardware."

vicatcu
  • 5,407
  • 7
  • 41
  • 65
0

When a processor is described as having e.g. the 6502 instruction set, what that means is that if the processor outputs signals to fetch an instruction from some address and receives certain data in return (e.g. the byte value $A9), the processor's subsequent actions will be as described in the documentation. The 6502, for example, would fetch a byte from the next address, and then copy that byte to the accumulator while it outputs an instruction fetch for the succeeding instruction.

In most cases, a processor doesn't acquire an instruction set any more than a light bulb acquires the ability to convert electricity into light. A processor is built to do certain things when it receives certain inputs; while today's processors are sufficiently complex that very sophisticated tools are required for their design (unlike 'ancient' times, where they were often designed using pens, pencils, and paper, and implemented using hand-cut ruby film), fundamentally processors do what they are built to do.

supercat
  • 77,689
  • 9
  • 166
  • 211