LOADMEM # test 1 zero r1 lui r1 1 CHECKMEM r0: 0 r1: 64 r2: 0 r3: 0 r4: 0 r5: 0 r6: 0 r7: 0 END LOADMEM # test 2 zero r1 ori r1 1 CHECKMEM r0: 0 r1: 1 r2: 0 r3: 0 r4: 0 r5: 0 r6: 0 r7: 0 END LOADMEM # test 3 zero r1 lui r1 1 ori r1 1 CHECKMEM r0: 0 r1: 65 r2: 0 r3: 0 r4: 0 r5: 0 r6: 0 r7: 0 END LOADMEM # test 4 zero r1 ori r1 1 lui r1 1 CHECKMEM r0: 0 r1: 64 r2: 0 r3: 0 r4: 0 r5: 0 r6: 0 r7: 0 END LOADMEM # test 5 zero r1 brnz r1 4 # should not branch CHECKMEM r0: 0 r1: 0 r2: 0 r3: 0 r4: 0 r5: 0 r6: 0 r7: 0 pc: 2 END LOADMEM # test 6 zero r1 ori r1 1 brnz r1 3 # should branch (pc+1+3=6) CHECKMEM r0: 0 r1: 1 r2: 0 r3: 0 r4: 0 r5: 0 r6: 0 r7: 0 pc: 6 END LOADMEM # test 7 zero r1 ori r1 20 jr r1 5 CHECKMEM r0: 0 r1: 20 r2: 0 r3: 0 r4: 0 r5: 0 r6: 0 r7: 0 pc: 25 END LOADMEM # test 8 zero r1 ori r1 20 jr r1 -5 CHECKMEM r0: 0 r1: 20 r2: 0 r3: 0 r4: 0 r5: 0 r6: 0 r7: 0 pc: 15 END LOADMEM # test 9 zero r1 j 25 CHECKMEM r0: 0 r1: 0 r2: 0 r3: 0 r4: 0 r5: 0 r6: 0 r7: 0 pc: 25 END LOADMEM # test 10 zero r1 jal 25 CHECKMEM r0: 0 r1: 0 r2: 0 r3: 0 r4: 0 r5: 0 r6: 0 r7: 2 pc: 25 END LOADMEM # test 11 zero r1 ori r1 8 sw r1 r0 6 lw r2 r0 6 ori r2 1 CHECKMEM r0: 0 r1: 8 r2: 9 r3: 0 r4: 0 r5: 0 r6: 0 r7: 0 END LOADMEM # test 12 zero r1 # 0 ori r2 1 # 1 jal 6 # 2 ori r3 2 # 3 eq r1 r2 r3 # 4 brnz r1 2 # 5 add r2 r2 r2 # 6 jr r7 0 # 7 jal 25 # 8 CHECKMEM pc: 25 r0: 0 r1: 1 r2: 2 r3: 2 r4: 0 r5: 0 r6: 0 r7: 9 END LOADMEM # test 13 zero r1 ori r1 1 ori r2 4 sub r2 r2 r1 brnz r2 -2 j 25 CHECKMEM pc: 25 r0: 0 r1: 1 r2: 0 r3: 0 r4: 0 r5: 0 r6: 0 r7: 0 END LOADMEM # test 14 zero r1 # 0 ori r1 16 # 1 cp r3 r1 # 2 jal 5 # 3 jump to 4, skip one instruction cp r2 r1 # 4 should not be executed ori r2 1 # 5 jr r2 7 # 6 jump to 1+7, skip one instruction add r2 r1 r2 # 7 should not be executed ori r4 4 # 8 sub r4 r4 r2 # 9 r4 -= 1 brnz r4 -2 # 10 branch to 9 as long as r4!=0 sw r3 r1 5 # 11 store 16 in DATA[16+5] lw r5 r1 5 # 12 load DATA[16+5] (16) in r5 lw r3 r1 4 # 13 load DATA[16+4] (0) in r3 j 20 # 14 CHECKMEM r0: 0 r1: 16 r2: 1 r3: 0 r4: 0 r5: 16 r6: 0 r7: 4 pc: 20 END LOADMEM # test 15 zero r1 ori r1 16 # use r1 as array pointer (AP) ori r2 1 # use r2 as data ori r3 1 # use r3 for increment (1) ori r4 6 # use r4 as boundary condition (6) sw r2 r1 0 # store data in MEM[AP] add r1 r1 r3 # AP++ add r2 r2 r3 # data++ neq r5 r4 r2 # while data (r2) != boundary (r4) brnz r5 -5 # repeat: MEM[AP]= data, AP++, data++ zero r1 # reset AP ori r1 16 lw r6 r1 0 # Load array [1-5] back to regs in reverse order lw r5 r1 1 lw r4 r1 2 lw r3 r1 3 lw r2 r1 4 CHECKMEM r0: 0 r1: 16 r2: 5 r3: 4 r4: 3 r5: 2 r6: 1 r7: 0 END