Table of Contents

CPU

Instructions

In the end, all computers have a CPU (Central Processing Unit) that execute a sequence of simple instructions stored in the RAM (Random Access Memory) that fall into three categories:

  • Arithmetic-Logic instructions
  • Control flow instrucions (branches and jumps)
  • I/O and Memory access instructions

Most CPUs have a small set of registers (normally something between 4 and 32) that store numeric values, like the RAM, but these are much faster. The instructions that the CPU executes, usually perform the operations using those registers.

Arithmetic-Logic instructions

In this category we can find instructions to perform logic operations like: AND, OR, XOR and NOT.

And arithmetic operations like: additions, subtractions, multiplications etc.

Control flow

CPUs make decisions by executing one code or another depending on the values stored in the registers and the RAM.

At the CPU level, we have unconditional and conditional jumps. For example telling the CPU to start executing instructions stored in other area of memory when a register is 0, or continue executing the current sequence of instructions otherwise.

I/O and Memory access instructions

Since there are only a few registers, most of the information is stored in the RAM. And there are operations to move values from/into the RAM into/from the registers.

Also computers have devices connected to the CPU, like keyboards, mice, screens, or graphic cards, and the CPUs have instructions to read and write from/to those devices.