2. Instruction sets and assembly language
In order to understand how registers relate to one another we need to first understand a little bit about instruction sets and assembly language
Instruction Set
This is the complete set of instructions that the CPU is capable of carrying out.
Each make of CPU will have its own unique instruction set which will contain hundreds of complex instructions.
For example, an instruction might look like: 'ADD ACC, 3'. This instruction is an 'Add to the accumulator' command.
Behind that command in assembly language, lies machine code, which is in binary form. Usually machine code is shown in hexadecimal format such as '04D3'.
Assembly Language
Programming in machine code is very difficult because it just looks like a set of numbers making it hard for a person to read and understand.
To make things easier for programmers, the chip makers provide an 'Assembly Language' for their CPU which means that programming code can be written in a readable form. For example:
Machine Code | Assembly Language |
---|---|
04D3 | ADD #3 |
The command ADD #3 tells the CPU to add 3 to the current value in the accumulator. This is clearly easier to understand compared to '04D3'.
The programmer writes their code in assembly language and this file is then applied through a linker and translator to create the machine code which is loaded into the CPU.
Each command in assembly language is called a 'mnemonic'.
Challenge see if you can find out one extra fact on this topic that we haven't already told you Click on this link: Machine code assembly language