# NOTE - THIS IS NOT A THOROUGH TEST. YOURS SHOULD BE MORE THOROUGH THAN THIS. # THE FACT THAT WE WERE ABLE TO CATCH ERRORS WITH THIS PROGRAM IMPLIES THAT # MANY OF YOU DIDN'T TEST ENOUGH. # It would be wise to have one partner think of crazy test cases if s/he # is ever sitting idly while the other partner works. This is the code: 0x00000000 addiu $1, $0, 1 # $1 <- 1 0x00000004 addiu $2, $0, 2 # $2 <- 2 0x00000008 beq $1, $2, L1 # Shouldn't branch (not equal) 0x0000000c addiu $1, $0, 3 # $1 <- 3 0x00000010 addiu $2, $0, 3 # $1 <- 3 0x00000014 beq $1, $2, L2 # Should branch (equal) (forward) L1: 0x00000018 addiu $5, $0, 42 # Should never reach here. L2: 0x0000001c addiu $1, $0, 1 # $1 <- 1 0x00000020 addiu $2, $0, 1 # $2 <- 1 0x00000024 bne $1, $2, L3 # Shouldn't branch (equal) 0x00000028 addiu $1, $0, 2 # $1 <- 2 0x0000002c addiu $2, $0, 3 # $1 <- 3 0x00000030 bne $1, $2, L4 # Should branch (not equal) (forward) L3: 0x00000034 addiu $5, $0, 43 # Should never reach here L4: 0x00000038 jal L5 # Jump. $31 <- 0x0000003c 0x0000003c addiu $5, $0, 44 # Should never reach here 0x00000040 beq $0, $0, L8 # 0 == 0 so branch to L8 L5: 0x00000044 addiu $4, $31, 0 # $4 <- 0x0000003c 0x00000048 addiu $31, $31, 4 # $31 <- 0x00000040 0x0000004c jr $31 # Jump back to 0x00000040 0x00000050 addiu $5, $0, 45 # Should never reach here L6: 0x00000054 beq $0, $0, L6 # 0 == 0 so branch to L6 (infinite) L7: 0x00000058 bne $0, $1, L6 # 0 != 3 so branch to L6 (backward) 0x0000005c addiu $5, $0, 47 # Should never reach here L8: 0x00000060 beq $0, $0, L7 # 0 == 0 so branch to L7 (backward) 0x00000064 addiu $5, $0, 46 # Should never reach here What to watch for: $5 should *never* change. If it does, there was a problem. The following sequence should occur. PC = 0x00000000 PC = 0x00000004 $1 <- 1 PC = 0x00000008 $2 <- 2 PC = 0x0000000c PC = 0x00000010 $1 <- 3 PC = 0x00000014 $2 <- 3 PC = 0x0000001c PC = 0x00000020 $1 <- 1 PC = 0x00000024 $2 <- 1 PC = 0x00000028 PC = 0x0000002c $1 <- 2 PC = 0x00000030 $2 <- 3 PC = 0x00000038 PC = 0x00000044 PC = 0x00000048 $4 <- 0x0000003c PC = 0x0000004c PC = 0x00000040 PC = 0x00000060 PC = 0x00000058 PC = 0x00000054 (repeat on 0x00000054 forever)