[top]

Quick reference: Table of Hmmm Instructions

By convention, R15 is the stack pointer. When a function is called, R1-Rn are conventionally used to hold its arguments, R14 holds the return address, and R13 receives the function's return value.

Instruction    Description Aliases
System instructions
halt Stop! None
read rX Place user input in register rX None
write rX Print contents of register rX None
nop Do nothing None
Setting register data
setn rX N Set register rX equal to the integer N (-128 to +127) None
addn rX N Add integer N (-128 to 127) to register rX None
copy rX rY Set rX = rY mov
Arithmetic
add rX rY rZ Set rX = rY + rZ None
sub rX rY rZ Set rX = rY - rZ None
neg rX rY Set rX = -rY None
mul rX rY rZ Set rX = rY * rZ None
div rX rY rZ Set rX = rY // rZ (integer division; rounds down; no remainder) None
mod rX rY rZ Set rX = rY % rZ (returns the remainder of integer division) None
Jumps!
jumpn N Set program counter to address N None
jumpr rX Set program counter to address in rX jump
jeqzn rX N If rX == 0, then jump to line N jeqz
jnezn rX N If rX != 0, then jump to line N jnez
jgtzn rX N If rX > 0, then jump to line N jgtz
jltzn rX N If rX < 0, then jump to line N jltz
calln rX N Copy addr. of next instr. into rX and then jump to mem. addr. N call
Interacting with memory (RAM)
pushr rX rY Store contents of register rX onto stack pointed to by reg. rY None
popr rX rY Load contents of register rX from stack pointed to by reg. rY None
loadn rX N Load register rX with the contents of memory address N None
storen rX N Store contents of register rX into memory address N None
loadr rX rY Load register rX with data from the address location held in reg. rY loadi, load
storer rX rY Store contents of register rX into memory address held in reg. rY storei, store