Swap in MIPS
SWAP: addi $29,$29,-4 #adjust stack pointer for $16
sw $16, 0($29) #save $16 on stack (push)
add $16,$0,$5 #temp = x (assume in $5)
add $5,$0,$6 #x = y (assume in $6)
#restore stack as follows:
lw $16,0($29) #$16 gets its old value back
addi $29,$29,4 #restore stack pointer (pop)
jr $31 #continue from (1) above