#
# test.s
#
# program to demonstrate RiSC-16 core
# (uses all opcodes)
#
	lw	r1, r0, arg1
	lw	r3, r0, count
loop:	lw	r2, r4, arg2
	movi	r7, sub
	jalr	r7, r7
	addi	r3, r3, -1
	beq	r3, 0, exit
	addi	r4, r4, 1
	beq	r0, r0, loop
exit:	sw	r1, r0, diff
	nop
	nop
#	halt
        beq r0, r0, 20
#
# subtract function
#
sub:	nand	r2, r2, r2
	addi	r2, r2, 1
	add	r1, r1, r2
	jalr	r0, r7
#
# data:
#
# count is the number of items to subtract from arg1
# (in this case, 3: arg2 and two beyond it)
# diff is where the result is placed
#
count:	.fill	3
arg1:	.fill	7183
arg2:	.fill	637
	.fill	1024
	.fill	3278
diff:	.fill	0
