RiSC-16 Program 2

Download prog2.zip with program resources, including an assembler.

Contents

Code
Simulation Results
Verilog JSIM2 Project – Prog2 Simulation

Assembled Code and Source

#
# test.s
#
# program to demonstrate RiSC-16 core
# (uses all opcodes)
#
addrcodesource
00a411
	lw	r1, r0, arg1
01ac10
	lw	r3, r0, count
021000
	add	r4, r0, r0
03aa12
loop:	lw	r2, r4, arg2
047c00
	movi	r7, sub
053f8c
06ff80
	jalr	r7, r7
072dff
	addi	r3, r3, -1
083201
	addi	r4, r4, 1
09cc79
	bne	r3, 0, loop
0A8417
exit:	sw	r1, r0, diff
0Be071
	halt
#
# subtract function
#
0C4902
sub:	nand	r2, r2, r2
0D2901
	addi	r2, r2, 1
0E0482
	add	r1, r1, r2
0Fe380
	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
#
100003
count:	.fill	3
11211c
arg1:	.fill	8476
120002
arg2:	.fill	2
130003
	.fill	3
140004
	.fill	4
150001
	.fill	1
160159
	.fill	345
170000
diff:	.fill	0

Simulation Results

#pcoprdqdraqa
100LW1211C00000
201LW3000300000
302ADD4000000000
403LW2000240000
504LUI7000000000
605ADDI7000C70000
706JALR700077000c
80CNAND2FFFD20002
90DADDI2FFFE2fffd
100EADD1211A1211c
110FJALR0001070007
1207ADDI3000230003
1308ADDI4000140000
1409BNE3000100000
1503LW2000340001
1604LUI7000000000
1705ADDI7000C70000
1806JALR700077000c
190CNAND2FFFC20003
200DADDI2FFFD2fffc
210EADD121171211a
220FJALR0001070007
2307ADDI3000130002
2408ADDI4000240001
2509BNE3000100000
2603LW2000440002
2704LUI7000000000
2805ADDI7000C70000
2906JALR700077000c
300CNAND2FFFB20004
310DADDI2FFFC2fffb
320EADD1211312117
330FJALR0001070007
3407ADDI3000030001
3508ADDI4000340002
3609BNE3000000000
370ASW1211300000

Registers

formatr1r2r3r4r5r6r7
hex2113FFFC00000003555566660007
decimal8467-40321845262147

Memory

addr0123456789ABCDEF
0000A411AC101000AA127C003F8CFF802DFF 3201CC798417E071490229010482E380
00100003211C000200030004000101592113








Maintained by John Loomis, last updated 6 April 2010