top of page

The CPU Instruction Set

​

The instruction set of a given CPU, also called Instruction Set Architecture (ISA), is the  collection of instructions which that specific CPU can recognize and execute. Each instruction is a command to instruct the CPU to perform a certain elementary operation. It can be specified as Machine code (Binary/Hex) or Assembly code (Mnemonic equivalent of binary instructions).

 

Here are some examples from the simulator: 

The digits or text in blue represent the Operation Code (opcode): a binary number which represents the operation to perform. A binary number is naturally interpreted by a CPU, yet it is difficult to remember for a human. Hence, programmers can use its mnemonic (assembly) equivalent code to identify the desired operation, such as "LOD", "ADD", and "STO".

​

The digits or text in red represent the operand(s) of the instruction. The operand has different interpretations according to the so-called addressing mode (which is also specified in the opcode). In the case of the simulator, the available addressing modes are:

  • Immediate (or numeric) addressing, as in ADD #8:  in this case the operand is a number (add the number 8)

  • Direct addressing, as in ADD 8: in this case the operand represents a memory address (add the number stored at the memory address 8). Rather than using directly numeric memory addresses, it is more convenient for humans to associate them with meaningful labels, such as Y or COUNTER. Hence a memory address can be more easily identified by a label, as in ADD Y. Important notice: the labels do not physically exist in the CPU or in memory, because they are  translated to the corresponding numerical addresses by the assembler, which can parse the whole assembly program offline. Yet, as the simulator translates the instructions one by one "on the fly", it is necessary first to define the labels by entering them in the grayed column, before they can be used in any instruction. 

binary.gif

Try it yourself: run the simulator and write some instructions. You can swap from Mnemonic (Assembly) to Binary code just by clicking the Symbolic/Binary button.

​

The instructions supported by a CPU can be organized in a few fundamental categories. The most important ones are:

​

  • Data flow operations: instructions used to  transfer (store) the contents of a CPU register, or the result of a computation to the primary memory, or to transfer (load) data stored in the primary memory to the CPU, in order to perform a computation on it later.

​

  • Control flow operations: instructions that modify the order in which individual instructions are executed (instruction are otherwise executed in sequential order, one after the other). 

​

  • Arithmetic-logic operations: instructions that perform arithmetic (addition, subtraction...) and logic operations (and, not...).

The following table reports the full set of instructions supported by the simulator, organized according to the above mentioned categories. For each instruction are reported: the opcode binary code in machine language, its assembly (mnemonic) equivalent, and a short informal description.

links
References & Helpful Links: 
​

                                                            CC BY-NC-SA 4.0                                                                                              Credits

bottom of page