MIPS pseudo instructions - MIPT-ILab/mipt-mips GitHub Wiki
In MIPS, some operations can be performed with help of other instructions. The most common operations are unified in pseudo-instructions — they can be coded in assembly language, and assembler will expand them to real instructions. The exact expansion is compiler-defined, but the result should be similar to ours:
| Name | Assembly syntax | Expansion | Operation in C | 
|---|---|---|---|
| move | move $t, $s | or $t, $s, $zero | t = s | 
| clear | clear $t | or $t, $zero, $zero | t = 0 | 
| load 16-bit immediate | li $t, C | ori $t, $zero, C_lo | t = C | 
| load 32-bit immediate | li $t, C | lui $t, C_hiori $t, $t, C_lo | t = C | 
| load label address | la $t, A | lui $t, A_hiori $t, $t, A_lo | t = A | 
| Name | Assembly syntax | Expansion | 
|---|---|---|
| branch unconditionally | b C | beq $zero, $zero, C | 
| branch unconditionally and link | bal C | bgezal $zero, C | 
| branch if greater than | bgt $s, $t, C | slt $at, $t, $sbne $at, $zero, C | 
| branch if less than | blt $s, $t, C | slt $at, $s, $tbne $at, $zero, C | 
| branch if greater than or equal | bge $s, $t, C | slt $at, $s, $tbeq $at, $zero, C | 
| branch if less than or equal | ble $s, $t, C | slt $at, $t, $sbeq $at, $zero, C | 
| branch if greater than unsigned | bgtu $s, $t, C | sltu $at, $t, $sbne $at, $zero, C | 
| branch if zero | beqz $s, C | beq $s, $zero, C | 
| branch if equal to immediate | beq $t, V, C | ori $at, $zero, Vbeq $t, $at, C | 
| branch if not equal to immediate | bne $t, V, C | ori $at, $zero, Vbne $t, $at, C | 
| Name | Assembly syntax | Expansion | 
|---|---|---|
| set if less or equal then | sle $s, $t1, $t2 | bne %t1,$t2,confrontationori $s, $0, 1beq $0, $0, EXITconfrontation: slt $s, $t1,$t2 | 
| Name | Assembly syntax | Expansion | Operation in C | 
|---|---|---|---|
| multiplicate and return 32 bits | mul $d, $s, $t | mult $s, $tmflo $d | d = (s * t) & 0xFFFFFFFF | 
| quotient | div $d, $s, $t | div $s, $tmflo $d | d = s / t | 
| remainder | rem $d, $s, $t | div $s, $tmfhi $d | d = s % t | 
| Name | Assembly syntax | Expansion | Operation in C | 
|---|---|---|---|
| jump register and link to ra | jalr $s | jalr $s, $ra | ra = PC + 4; goto s; | 
| Name | Assembly syntax | Expansion | Operation in C | 
|---|---|---|---|
| not | not $t, $s | nor $t, $s, $zero | t = ~s | 
| Name | Assembly syntax | Expansion | Operation in C | 
|---|---|---|---|
| nop | nop | sll $zero, $zero, 0 | {} | 
In fact, every MIPS instruction that has $zero as its destination and doesn't touch memory, access I/O system, and/or call a trap, can be treated as a nop; but using sll $zero, $zero, 0 is the most convenient because it's byte code is all-zeroes 0x00000000.
Since 2014/2015, all instructions are printed as real MIPS instructions in MIPT-MIPS. Unexpanded pseudo-instructions are left only in testing traces source files (.s files).