blt
Branch if less than
Branches to label if t1 is less than t2, comparing as signed.
Used in
- Asking a question with a branchRISC-V assembly
- if, else and jump tablesRISC-V assembly
- Arrays and stringsRISC-V assembly
- The stack and spRISC-V assembly
- jal, ret and the calling conventionRISC-V assembly
- The bigger of two numbersRISC-V assembly
- The largest elementRISC-V assembly
- A subroutine with its arguments in registersRISC-V assembly
- Recursion: factorial and FibonacciRISC-V assembly
- Print a nonnegative number in bases 2–36RISC-V assembly
Forms
blt , ,
Operands
t1- Any integer register,
x0tox31, or its named alias, such aszero,t0ort6. t2- An integer register. It may be the same register as
t1. label- A named address in the program, such as the start of a loop or a variable in
.data.
# First blt case is taken; second is not. t2 ends at 11 (10 + 1).
.text
li t2, 0
li t0, 3
li t1, 7
blt t0, t1, taken
addi t2, t2, 1
j first_done # Skip the other marker unconditionally.
taken:
addi t2, t2, 10
first_done:
li t0, 7
li t1, 3
blt t0, t1, missed
addi t2, t2, 1
j second_done # Skip the other marker unconditionally.
missed:
addi t2, t2, 10
second_done:
# t2=11 proves one taken and one untaken path.