Skip to content

Instruction Categories

Not all of these instructions will be present in an ISA, in the exact given format. This is to give a general idea as to what kinds of instructions you will run into.

Arithmetic Operations

  • add
  • sub
  • mul
  • div
  • mod
Operation Formats

Operations can be performed between two registers, or a register and an immediate. This result will be stored in a destination register.

Logical Operations

  • and
  • or
  • not
Operation Formats

and and or are typically performed only between two registers. This result is stored in a destination register. not accepts only one source, and stores its negation in the destination register.

Branching Operations

  • bz (RS) (addr) - branches to address (addr) if register (RS) is storing value 0.
  • bnz (RS) (addr) - branches to address (addr) if register (RS) is not storing value 0.
Alternative Branching Approaches
  • be, blt, bgt - compare the value of two registers, and branch depending on them.
  • cmp - sets the value of flags, and depending on these flags the next instruction may branch somewhere.

An ISA will typically use one of these approaches to branch

Function Operations

  • call (lbl) - calls the function referred to with label.
  • ret - returns from the current function

Data Transfer / Persistence

  • ld (RD) (addr) - loads value from memory address (addr) to register (RD)
  • st (RS) (addr) - stores value in register (RS) to memory address (addr)
  • mov (RD) (RS / imm) - stores value from either a source register (RS) or an immediate (imm) to a destination register (RD)

Stack Operations

  • push (RS) - pushes value of (RS) on the stack
  • pop (RD) - pops the value at the top of stack into (RD)

IO Instructions

  • input (RD) - inputs a value into a register (RD)
  • output (RS) - outputs the value of register (RS)