	; test comments in weird places
	PRINTS "this should never execute"
main:				; test main beginning at 1, not 0
	MOVECL    0x0, q1
	MOVECL    0x2, q1
	SIC       @q1, q0
	FLUSHQ    q0
	FLUSHQ    q1
	FLUSHQ    q2
	ALLOCATEC 0x4, q90
	SIC       @q90, q0
	FLUSHQ    q0
	MMS       q91, q92
	MOVE      @q90, q91
	MOVECL    0x0, q91
	MOVECL    0x5, q92
	MOVECL    0x1, q91
	MOVECL    0xA, q92
	MML       q93, q94
	MOVE      @q90, q93
	MOVECL    0x0, q93
	MOVECL    0x1, q93
	PRINTSNNL "readback from allocate test, loc 0: "
	PRINTQX   q94
	PRINTSNNL "loc 1: "
	PRINTQX   q94
	PRINTS    "\nAbove test should have yielded 0 to have 0x5, 1 to have 0xA"
	;;  that's it...
	MOVECL    0x10, q110	; spawn threads!
	NOP			; test the NOP instruction
spawn:	
	SPAWNC    begin, q111
	MAPQC     q112, q0, q111 ; map q112 to q0 in target context
	PROCID    q112		;  forward my data...
	EEQ       q112		;  ensure it gets sent...
	UNMAPQ    q112		;  unmap for next cycle
	SUBC      q110, 1, q110
	SLEC      @q110, 0, q111
	BRZ	  q111, spawn
	PRINTSNNL "number of threads completing their code: "
	MOVECL    0x0, q1
waitfinish:	
	ADD       q0, q1, q1	; add the return code to q1
	PRINTQNNL @q1
	PRINTSNNL " "
	SEQC      @q1, 0x10, q2
	BRZ       q2, waitfinish
	CYCLES			; print cycle count
	HALT      0,0
	
begin:
	MAPQC     q127, q0, q0  ; q127 in this context maps to q0 in original calling context
	MOVECL    0x4, q1	;  test multiple queueing and adds
	MOVECL    0x3, q1
	MOVECL    0x2, q0
	MOVECL    0x2, q2
	PRINTSNNL "q1 should be 4: "
	PRINTQ    q1
	ADD       q1, q2, q3
	PRINTSNNL "q3 should be 5: "
	PRINTQ    @q3              ;  copy of this value
	SUBC      q3, 0x6, q3
	PRINTS    "q4 should be -1: "
	PRINTQ    @q3

	;;  test word operations
	MOVECL    0x3, q42
	MOVECL    0x2, q78
	MUL       @q42, q78, q20
	PRINTSNNL "mul test, should be 6: "
	PRINTQ    @q20
	DIV       q20, q42, q20
	PRINTSNNL "div test, should be 2: "
	PRINTQ    q20		;  all queues from above should be emptied now
	;; load q10 with 0xF0F0F0F0F0F0F0F0
	MOVECL    0xF0F0F0F0, q10
	SHLC      q10, 32, q10
	MOVECL    0xF0F0F0F0, q11
	SHLC      q11, 32, q11	;  get rid of sign
	SHRC      q11, 32, q11
	OR        q10, q11, q10
	;; load q11 with 0x123456789ABCDEF
	MOVECL    0x12345678, q11
	SHLC      q11, 32, q11
	MOVECL    0x9ABCDEFF, q12
	SHLC      q12, 32, q12
	SHRC      q12, 32, q12
	OR        q11, q12, q11
	AND       @q10, @q11, q12
	PRINTSNNL "and test, should be 0x1030507090B0D0F0: "
	PRINTQX   q12
	OR        @q10, @q11, q12
	PRINTSNNL "or test, should be 0xF2F4F6F8FAFCFEFF: "
	PRINTQX   q12
	XOR       @q10, @q11, q12
	PRINTSNNL "xor test, should be 0xE2C4A6886A4C2E0F: "
	PRINTQX   @q12		; save q12 for next test
	MOVECL    16, q13
	SRA       q12, q13, q12
	PRINTSNNL "sra test, should be 0xFFFFE2C4A6886A4C: "
	PRINTQX   q12

	;; coverage so far: MOVECL, ADD, SUB, MUL, DIV, OR, AND, XOR
	;; ADDC, SUBC, MULC, DIVC, ORC, ANDC, XORC, SHL, SHLC, SHR, SHRC
	;; SRA, SRAC
	;; only tested long-word types (type test later)
	;; (c-type instructions by glass-box test association)
	
	;; now test branch operations, set and test
	PRINTS   "count from 5 to -1, using queue storage"
	MOVECL   5,q14		; setup a counter
test1:	
	MOVE     @q14, q16
	SUBC     q14,1,q14
	SLEC     @q14, -2, q15
	BRZ      q15, test1

test2:	
	PRINTQNNL q16           ; print queue contents post-test
	PRINTSNNL " "
	BRNE      q16, test2
	PRINTS   "."		; put a periond and newline at the end

	;; test coverage is  BRZ, SLEC, SLE, MOVE

	PRINTS   "Test threads and inter-thread comms..."
	SPAWNC   thread1, q30
	MAPQC    q31, q0, @q30  ; q31 here maps to q0 in my new thread
	MAPQC    q32, q1, @q30  ; q32 here maps to q1 in my new thread
	MAPQC    q33, q2, @q30  ; q33 here maps to q2 in my new thread
	PROCID   q31		; send my procID into q0 of the new thread
	MOVECS   0x00030004, q32
	MOVECS   0x00050002, q33
	PRINTSNNL "value should be 0x80006: "
	PRINTQX  q34
	MOVECS   0x42, q32	; send something to other thread q1
waitsend:	
	SEMPTY   q32, q34
	BRZ	 q34, waitsend
	NOP
	MOVECS   0x88, q32
	EEQ      q32
	UNMAPQ   q31
	UNMAPQ   q32
	UNMAPQ   q33
	MOVECF   3.2, q31
	MOVECF   2.4, q32
	FADD     q31, q32, q33
	PRINTSNNL "value should be 5.6:	"
	PRINTQ   q33

	;; test coverage is SPAWNC, MAPQC, PROCID, MOVECS, SEMPTY
	;; NOP, UNMAPQ, MOVECF, FADD, MAPSQ and basic multithreading/synchro
	
	MOVECL 0x1, q127	; send my return code so I can be counted....
	HALT   0,0
	
	PRINTS "now entering infinite loop"
loop:	
	SUBC   q3, -2, q3
	PRINTQ @q3
	BR     loop

	;; test coverage is BR
	HALT   0,0

thread1:
	PRINTS "new thread started okay"
	MAPQC  q3, q34, q0	; first thing: wait for q0 to get return context ID
	ADD    q1, q2, q3
	MAPSQ  q1, q4		; record our source queue for q1
	PRINTSNNL "waiting for data on q1..."
	PRINTQX q1
	PRINTSNNL "source queue for q1:	"
	PRINTQ  q4
	PRINTS "test thread terminating"
	HALT   0,0
	