diff --git a/tests/blt.s b/tests/blt.s new file mode 100644 index 0000000..94ed4af --- /dev/null +++ b/tests/blt.s @@ -0,0 +1,31 @@ +.global _start +_start: + # Set base value of a0 to 'test failed' + addi a0, zero, 1 + + # Set A, B values of t0/t1, to test less than + addi t0, zero, 1 + addi t1, zero, 2 + blt t1, t0, lt0 + + # Inequality passed, now test with jump + blt t0, t1, lt1 + + # On failure, return + ebreak + +ltNeg: + # All passed + addi a0, zero, 0 + ebreak + +lt0: + # Inequality failed + ebreak + +lt1: + # Inequality passed ; now try with negative numbers + addi t0, zero, -1 + addi t1, zero, -2 + blt t1, t0, ltNeg + ebreak diff --git a/tests/test.sh b/tests/test.sh index 0ef6c91..9c999ac 100644 --- a/tests/test.sh +++ b/tests/test.sh @@ -25,6 +25,7 @@ test() { test "ADDI : Add Immediate " "../build/tests/addi " 186 test "MV : Move registers " "../build/tests/mv " 186 test "BEQ : Branch EQual " "../build/tests/beq " 0 +test "BLT : Branch Less Than " "../build/tests/blt " 0 test "JAL : Jump And Link " "../build/tests/jal " 0 test "SWLW : Store Word Load Word " "../build/tests/swlw " 0 test "JALR : Jump And Link Register " "../build/tests/jalr " 0