; Simple program to add two numbers
@in1: .value 2
@in2: .value 3
@out: .value 0
LDA @in1
LDB @in2
ADD @out
OUT @out
HLT
; Simple program to subtract two numbers
@in1: .value 5
@in2: .value 3
@out: .value 0
LDA @in1
LDB @in2
SUB @out
OUT @out
HLT
; Simple program to multiply two numbers
@in1: .value 3
@in2: .value 4
@out: .value 0
@loop:
LDA @in1
LDB @in1
ADD @out
LDA @in2
LIB 1
SUB @in2
JZ @done
JMP @loop
@done:
OUT @out
HLT
; Simple program to divide two numbers
@in1: .value 12
@in2: .value 3
@out: .value 0
@loop:
LDA @out
LIB 1
ADD @out
LDA @in1
LDB @in2
SUB @in1
JZ @done
JMP @loop
@done:
OUT @out
HLT
; Program that finds the nth triangle number
@in: .value 5
@out: .value 0
@loop:
LDA @in
LDB @out
ADD @out
LIB 1
SUB @in
JZ @done
JMP @loop
@done:
OUT @out
HLT