//
// Constants
//
x	const 	-12
five	const 	5

//
// Variables that do no have initial values
//
START BSS SECTION
age	data
count	data
m	data
n	data

//
// Variables that have initial values.
//
START DATA SECTION

fred	array	123[10]
	data.l	13
y	const	4
sam	data.b	x
jim	data	100

//
// Code
//
START CODE SECTION
top: 	push 	5
	push	70
	push	-1
	push	-7680
	push	8191
	push	-7681
	push	8192
	push	32767
	push	-32768
	push	32768
	push	-32769
	push	0x10
	push	0xFFFFFFFF
	pop
	clear
	dup
	dup.-1
	add
	sub
	mul
	div
	and
	or
	xor
	arshift
	rshift
	lshift
	not
	neg
subroutine:
	return
// Test "Flow of Control" instructions in order.
	b.dnz	count ->top	// D0
	b.>	 	// D1
	b.=	-> top	// D2
	b.>=	n	// D3
	b.<	n -> top
	b.<>	n,m
	b.<=	n,m -> top
	b	->top
	return	// Same as "b"
	syscall
	call.>	n,m -> subroutine	// D9
	call.=	-> subroutine	// DA
	call.>=	-> subroutine	// DB
	call.<	-> subroutine
	call.<>
	call.<=
	call	-> subroutine

// Test the memory instructions
	load.b
	load
	load.l
	load.p.b
	load.p
	load.p.l

	store.b
	store
	store.l
	store.p.b
	store.p
	store.p.l

// Test operands
	clear
	push	5
	push	3
	sub

	clear
	push	5
	sub	3

	clear
	sub	5,3

// jim = jim + five;
	load	jim
	add	five
	store	jim
	clear
// jim = jim + 5;
	add	jim, 5
	store	jim
	clear
// jim += 2+3;
	dup	jim
	add	2+3
	store
	clear

	push	fred + 8
	clear

	store	count, 10	// count=10
Loop:
	syscall	1
	b.dnz	count ->Loop 	// Repeat the loop 10 times.

// Test forward branches
	b	->ahead.far
	b	->ahead.far
	b	->ahead.far.far
	b	->ahead.far.far.far
	push	->ahead.far
	push	->ahead.far
	push	->ahead.far.far
	push	->ahead.far.far.far

	dup
	dup.-1
	add
	sub
	mul
	div
	and
	or
	xor
	arshift
	rshift
	lshift
	not
	neg
ahead:
	return