# # prog2.s # # program to demonstrate RiSC-16 core # (uses all opcodes) # 0 a411 lw r1, r0, arg1 1 ac10 lw r3, r0, count 2 1000 add r4, r0, r0 3 aa12 loop: lw r2, r4, arg2 4 7c00 movi r7, sub 5 3f8c 6 ff80 jalr r7, r7 7 2dff addi r3, r3, -1 8 3201 addi r4, r4, 1 9 cc79 bne r3, 0, loop A 8417 exit: sw r1, r0, diff B e071 halt # # subtract function # C 4902 sub: nand r2, r2, r2 D 2901 addi r2, r2, 1 E 482 add r1, r1, r2 F e380 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 # 10 3 count: .fill 3 11 211c arg1: .fill 8476 12 2 arg2: .fill 2 13 3 .fill 3 14 4 .fill 4 15 1 .fill 1 16 159 .fill 345 17 0 diff: .fill 0 18 0 .space 8 0 0 0 0 0 0
Maintained by John Loomis, last updated 14 April 2010