<<< Integer logic and arithmetic | Index | Integer Multiplication >>> |
Using immediate operand -- the second operand which is a constant
Note: the constant is 16-bits, sign-extended to 32-bits
# add/subtract/and immediate: # Instruction # Meaning in pseudocode addi $t1, $t2, 4 # $t1 = $t2 + 4 subi $t1, $t2, 15 # $t1 = $t2 - 15 andi $t1, $t2, 0x00FF # $t1 = $t2 & 0x00FF # set if less than immediate: slti $t1, $t2, 42 # $t1 = $t2 < 42 ? 1 : 0
Other other immediate instructions: ori and xori
<<< Integer logic and arithmetic | Index | Integer Multiplication >>> |