Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Instruction Reference

This chapter is the compact reference. Come here when you know what you want to do and just need the exact instruction.

Data movement

MnemonicBytesMeaningEffect
LDA1Load from memoryA = mem[DP]
STA1Store to memorymem[DP] = A
LDI imm82Load immediate into AA = imm
LDP imm16/label3Load immediate into DPDP = addr
LDL1Set low byte of DP from ADP[7:0] = A
LDH1Set high byte of DP from ADP[15:8] = A
SDL1Read low byte of DP into AA = DP[7:0]
SDH1Read high byte of DP into AA = DP[15:8]
IDP1Increment DPDP = DP + 1
DDP1Decrement DPDP = DP - 1

Arithmetic and comparison

MnemonicBytesMeaningEffect
ADD1Add memory to AA = A + mem[DP]
SUB1Subtract memory from AA = A - mem[DP]
CMP1Compare A with memoryflags from A - mem[DP]
ADI imm82Add immediateA = A + imm
SBI imm82Subtract immediateA = A - imm
CMI imm82Compare immediateflags from A - imm

These instructions update flags except for store-like operations.

Logic and shifts

MnemonicBytesMeaningEffect
AND1Bitwise ANDA = A & mem[DP]
ORR1Bitwise ORA = A | mem[DP]
XOR1Bitwise XORA = A ^ mem[DP]
SHL1Shift leftA = A << 1
SHR1Shift rightA = A >> 1

Stack and subroutines

MnemonicBytesMeaningEffect
PSH1Push Apush(A)
POP1Pop into AA = pop()
JSR addr3Jump to subroutinepush(PC); PC = addr
RET1ReturnPC = pop()

Control flow

MnemonicBytesMeaningEffect
JMP addr3Unconditional jumpPC = addr
JEQ addr3Jump if zeroif Z, jump
JNG addr3Jump if negativeif N, jump
NOP1Do nothingno state change
HLT1Halt executionstop VM

Input and output

MnemonicBytesMeaningEffect
PRT1Print byte in Aoutput A
RTR1Read byte into AA = read()

Notes on flags

T32 maintains:

  • Z for zero results
  • N for negative results

In practice, this means you often compute or compare first, then branch.