Skip to content

Instruction Encoding

Encoding is the process by which the assembler converts human-readable assembly code to machine-readable machine code. Machine Code exists in binary formatting, and is interpreted directly by the electronics in the processor.

Encoding Formats

Each instruction is encoded in some format, which gives the processor all the info needed. This encoding can contain:

  • Opcode (mandatory) - tells the processor which instruction to run on this line.
  • Source / Destination Registers - may be read from or written into.
  • Source / Destination Memory Addresses - as used by load / store instructions. Memory addresses can also be used to specify where to branch.
  • Modifiers - apply certain changes to the instruction's execution.

The number of bits allocated for each address decides the size of each address space (i.e. the range of possible immediates, memory addresses that can be accessed, and registers that can be accessed.)

Features

  • We want all instruction encodings to be equal in size for a certain ISA. For this, we add padding bits to the end if needed.
  • All encoded instructions are read from the memory during program execution.

Impact of Encoding Width

Fixed Width ISAs occupy more space in the memory (and thus cache), but are decoded faster.

Variable Width ISAs occupy less space in the memory (and thus cache), but are decoded slower.

A difference of execution speed between the two is indeterminate unless other factors are provided.