DLX provides two instructions for comparing numbers:
- seq (set if equal)
- sne (set if not equal).
Seq instruction example:
Seq result register,compare1 register,compare2 register
Result register will be 1 if the registers are equal otherwise 0
Result register will be 1 if the registers are equal otherwise 0
Use branch true (bt) or branch false (bf) to compare result register
1: seq r1,r2,r4 ;Checks if r2=r4
2: bt r1,L1 ; if true (Branch true ) Jump to L1
3: <OtherStatements> ;If false execute this
4: jr r31 ;end program
5: L1 ;Jump to here if condition fails
6: jr r31 ;end program
Sne instruction example:
Sne result register,compare1 register,compare2 register
Result register will be 1 if the registers are not equal otherwise 0
Use branch true (bt) or branch false (bf) to compare result register
1: sne r1,r2,r4 ;Checks if r2=!r4
2: bt r1,L1 ; if true (Branch true ) Jump to L1
3: <OtherStatements> ;If false execute this
4: jr r31 ;end program
5: L1 ;Jump to here if condition fails
6: jr r31 ;end program