;for c-like coding style

SET PC , main

;This is an implementation

;of the common GCD algorithm (Euclid's)

;A and B are assumed to be the original inputs

;so when using this load the arguments into those

;function gcd(a, b)

; while b ≠ 0

; t := b

; b := a mod b

; a := t

; return a

;the output of this algorithm is stored in A

: gcd IFE B , 0

SET PC , gcdend

SET C , B

MOD A , B

SET B , A

SET A , C

SET PC , gcd

: gcdend

;I'll read the output from the register directly

;for the moment

SET PC , crash

;some example input (test run)

: main SET A , 50

SET B , 10

SET PC , gcd