; ELEC 5200 - MIPS CPU TEST PROGRAM org 00000000h main: jal arith_test ; logic/shift test end: j end ; effectively halt machine ; arith_test - arithmetic operation: D = A + B - C ; all numbers are 32-bit 2's complement integers arith_test: ori $2, $0, 1 ; loop counter = 2 in r2 lui $29, 1000h ; point to data segment ori $29, $29, 60h ; point to A a_loop: lw $5, 0($29) ; load A lw $6, 8($29) ; load B add $5, $6, $5 ; A+B lw $7, 16($29) ; load C sub $5, $5, $7 ; A+B-C sw $5, 24($29) ; store result at D or $5, $29, $6 ; test logical OR and $5, $5, $7 ; test logical AND slt $4, $5, $29 ; test slt sw $5, 32($29) ; store logical result at E addi $2, $2, -1 ; loop counter slti $20, $2, 0 ; check loop counter addi $29, $29, 4 ; next data elements beq $20, $0, a_loop ; branch jr $31 ; return ; Test Data: Keep on word boundaries (all 32-bit words) ; NOTE: Given 1K-word memory ignores address bits A31-A13 org 10000060h A: dd 5, -65 B: dd -34, 3 C: dd 3, -70 D: dd 0, 0 E: dd 0, 0 end