What is an instruction set?

Thread Starter

mike _Jacobs

Joined Jun 9, 2021
223
So i have tried to understand this but every video i watch tells me something different.

I understand that a program or process has program instructions.
For example a program that adds two numbers together.
Instruction #1 - Get first number
instruction #2 - Get second number
instruction #3 - add one and two together

And so many youtube videos say this is the instruction set. I dont think that is true.

When i think of an instruction set, i think of the set of binary codes, that corelates to some hardware configuration in a CPU.
For example, an instruction X sets certain transistors on or off inside of a CPU to allow a hardware configuration to move push data onto a data bus or something similar in a CPU. That to me is what the CPU instruction set is.

These guys on youtube keep calling program instructions the "instruction set" and i dont think that is correct

Am i totally off base?
 

Papabravo

Joined Feb 24, 2006
22,081
Yes and no. An instruction set is an abstraction that defines the operation of a computational machine. Alan Turing (1912-1954) was an early pioneer in this field and defined an abstract machine (ca. 1936) that could compute the value of a function. At the time there were few if any machines that could perform this task. This would not continue to be the case, however. Starting with the ENIAC the concept of an instruction set took on more tangible incarnations. Fast forward to the present and instruction set refers to an abstract definition of what the machine is doing. This is the model a programmer would use as he is putting together programs for accomplishing particular tasks. It also provides a roadmap for the hardware engineer as he puts together subcircuits to implement the instruction set specification.
 
Last edited:

xox

Joined Sep 8, 2017
936
Right, the instruction set is the actual "catalogue" of bit patterns which trigger the CPU to perform some action. A specific sequence of instructions (including any embedded data) is the program itself.
 

MrChips

Joined Oct 2, 2009
34,767
The instruction set is a set of primitive commands to instruct a machine to perform a given task.

For example, a mobile robot might be given a task to move from point-A to point-B.
The set of primitives might be of the form:

Move one step in a forward direction
Rotate clockwise 45°
Move two steps in a reverse direction
Move five steps in a forward direction
Test for obstacle
If obstacle detected, move one step in reverse direction
etc.

The instruction set on a microprocessor might have instructions of the form:

Move data from memory address addr2 to register R1
Move data from memory address addr3 to register R4
Add contents of register R4 to register R1
Test if contents of register R1 is zero
If contents of register R1 is zero, then proceed to instruction at address addr6.
 

Thread Starter

mike _Jacobs

Joined Jun 9, 2021
223
Appreciate the info.

To be more direct, the instruction set is what i thought of it then. Its the hardware definition to enable certain command or data flow in hardware to reach certain parts of the CPU. Yes?

Through some more magic of course program instructions eventually get converted to CPU instructions to make the CPU do what its suppose to do.
 

Thread Starter

mike _Jacobs

Joined Jun 9, 2021
223
The instruction set is a set of primitive commands to instruct a machine to perform a given task.

For example, a mobile robot might be given a task to move from point-A to point-B.
The set of primitives might be of the form:

Move one step in a forward direction
Rotate clockwise 45°
Move two steps in a reverse direction
Move five steps in a forward direction
Test for obstacle
If obstacle detected, move one step in reverse direction
etc.

The instruction set on a microprocessor might have instructions of the form:

Move data from memory address addr2 to register R1
Move data from memory address addr3 to register R4
Add contents of register R4 to register R1
Test if contents of register R1 is zero
If contents of register R1 is zero, then proceed to instruction at address addr6.
This is the part i don't understand and I'm not sure you are correct.

The instruction set to me as i understand is the hardware definition in the CPU to make certain things happens such as a control or data flow operation. You sound like you are talking about program instructions in assembly. That is the part i want to clarify
 

MrChips

Joined Oct 2, 2009
34,767
There is something else called microcode. This may be what you have in mind.

Microcode is used by the designers of the microprocessor in order to control the data flow within the chip.
Ordinary mortals like us do not get to see the microcode. We see the instruction set.

Read "Soul of a New Machine" by Tracy Kidder if you want to read a fascinating story of how they used microcode to create a new computer.

https://en.wikipedia.org/wiki/The_Soul_of_a_New_Machine
 

WBahn

Joined Mar 31, 2012
32,796
"Instruction Set" is just the set of instructions that can be executed by some system.

You are thinking pretty narrowly in terms of a particular CPU's instruction set. That's fine.

But it's also perfectly reasonable to talk about a robot's instruction set. Or a virtual machine's instruction set.

What is in the instruction set depends on whose instruction set it is.

Within most more complex CPUs there's yet another instruction set -- the microinstructions -- that are used to implement the CPU's instruction set.
 

Papabravo

Joined Feb 24, 2006
22,081
There are also virtual machines, often created by compilers, to translate code from a human readable form and level of abstraction into a machine executable or interpretable form. In some cases, these virtual machines are designed around a single LIFO (Last In, First Out) pushdown stack. All operands a pushed onto the stack, then all operations take one or more items from the stack and push the result onto the stack. This model covers virtually all computations involving the basic arithmetic operations and functions that can be decomposed into elementary arithmetic operations. There is no actual hardware for the virtual machine anywhere. This is the power of abstraction.

One advantage of this translation is that there are no ambiguous constructions when it comes to the order of operations in the postfix notation for arithmetic operations.

https://en.wikipedia.org/wiki/Stack_machine
 
Last edited:

WBahn

Joined Mar 31, 2012
32,796
There are also virtual machines, often created by compilers, to translate code from a human readable form and level of abstraction into a machine executable or interpretable form. In some cases, these virtual machines are designed around a single FIFO (First In, First Out) pushdown stack. All operands a pushed onto the stack, then all operations take one or more items from the stack and push the result onto the stack. This model covers virtually all computations involving the basic arithmetic operations and functions that can be decomposed into elementary arithmetic operations. There is no actual hardware for the virtual machine anywhere. This is the power of abstraction.

One advantage of this translation is that there are no ambiguous constructions when it comes to the order of operations.
A FIFO is NOT a stack! It is a queue. A stack is a LIFO (last-in, first-out) data structure.

A virtual machine does not solve the problem of ambiguousness with regards to order of operations -- that is an issue that occurs at (and must be resolved at) the grammar level of the higher language.
 

Papabravo

Joined Feb 24, 2006
22,081
A FIFO is NOT a stack! It is a queue. A stack is a LIFO (last-in, first-out) data structure.

A virtual machine does not solve the problem of ambiguousness with regards to order of operations -- that is an issue that occurs at (and must be resolved at) the grammar level of the higher language.
You're right it is LIFO. What I meant was that the intermediate language of the stack machine which is extant after the translation removes the ambiguity of infix notation by using postfix notation as a representation of what the machine is doing.
 

nsaspook

Joined Aug 27, 2009
16,298
There is Virtualization for a software processes abstraction and Virtual Machines as a hardware instruction execution environment abstraction.

A true virtual machine (virtualizing a full set of hardware resources) must have hardware instruction support.
The MC68000 and MC68010 had the same basic instruction set but the MC68010 also added VM support by making one instruction a privileged instruction and adding additional VM related registers and a additional instruction for them.
https://en.wikipedia.org/wiki/Popek_and_Goldberg_virtualization_requirements
 

nsaspook

Joined Aug 27, 2009
16,298
In fact, we can use machines we have today to emulate the behavior and operation of any machine we had in the past.
+1

For example the PIC32MK has the MIPS32 instruction set for VM hardware assistance (full virtualization). It could easily emulate most 8-bit controller systems faster than real 8-bit hardware.

https://www.aurel32.net/info/debian_mips_qemu.php
QEMU is a generic and open source processor emulator which can emulate i386, x86_64, MIPS, MIPSEL, PowerPC and SPARC systems. In case of MIPS or MIPSEL, it can emulate a platform with an IDE controller, and IDE hard disk, an Ethernet card and a serial port. It still lacks a graphic card and screen support, so the installation is done through the emulated serial port.

The Debian Etch distribution provides kernel support this emulated platform. That makes a cheap development platform. The emulated system running on an Athlon 64 X2 3800+ is around 10% faster than an SGI Indy with and R4400SC 200MHz, and possibly with much more RAM (my emulated system has 512MiB of RAM).
You could, in theory, emulate any possible classical digital computer device if you had unlimited VM resouces like memory and processor speed as you could VM trap any instruction and/or memory access.
 

Papabravo

Joined Feb 24, 2006
22,081
Out of curiosity, did you mean "any machine" we have today, or just that there is "some machine" that we have today?
I meant we can choose from an available set of machines that we have today. I'm making absolutely no value judgement on the efficacy of such an enterprise.
 

WBahn

Joined Mar 31, 2012
32,796
I meant we can choose from an available set of machines that we have today. I'm making absolutely no value judgement on the efficacy of such an enterprise.
So "some" machine. I agree with you. If it had been "any" machine, I don't think that would be a valid claim.
 
Top