Assembly Language
Assembly language is an easier understand way to write instructions. There is a tight matching between a assembly language its corresponding machine code, which is processor specific.
An assembler converts assembly language to machine code. That way we can write:
MUL(r0, r1, r0)
instead of a 32 bit instruction.
An assembly offers many conveniences for the human programmer:
- You can replace instructions with macros, as above
- You can label constants with a symbol
- You can label lines of the code with a symbol, which can be referenced when you use a branching instruction, e.g. BNE or BEQ
Labelling allows us to reserve locations in memory for use later. For example, the macro LONG(x)
stores its argument in 4 consecutive byte locations. Labelling this location can allow us to reference the location in later ST
or LD
instructions.
As the assembler reads the code, it keeps a symbol table where it stores this information.