# Useless program to illustrate some logical instructions
#
.text
.globl main
main:
addi $t0, $zero, -0xff # Put -255 into t0
addi $t1, $zero, 255 # Put 255 into t1
add $t2, $zero, $t0 # Make an extra copy of t0
add $t3, $zero, $t1 # and a copy of t1
srl $t2, $t0, 4 # Shift -255 to the right 4 bits
srl $t3, $t0, 4 # Shift 255 to the right 4 bits
addu $t2, $zero, $t0 # Restore t2 to -255
addu $t3, $zero, $t1 # and t3 to 255
sll $t2, $t0, 3 # Shift -255 to the left 3 bits
sll $t3, $t1, 3 # Shift 255 to the left 3 bits
# Illustrate isolating bits 5 through 10
addi $t4, $zero, -1 # Put all 1's in $t4
sll $t4, $t4, 21 # Shift 31-10 to the left
srl $t4, $t4, 26 # Shift 31-10+5 to right
sll $t4, $t4, 5 # Shift 5 left (if you want them in original spot)