The values of $t0 and $t1 are 0xAAFFFFFF and 0x000EF000 respectively. Write a MIPS code that swaps bits 26 to 31 of $t0 with bits 11 to 16 of $t1.
# MARS/MIPS
###############################################################
.data
# code segment
.text
.globl main
main:
li $t0, 0xaaffffff
li $t1, 0x000ef000
move $t2,$t0
move $t3,$t1
srl $t2,$t2,26
sll $t2,$t2,11 #mask1 for #t1
sll $t3,$t3,15 #mask for $t0
andi $t0,0x03ffffff
andi $t1, 0xffff07ff
or $t0, $t0, $t3
or $t1, $t1, $t2
li $v0, 10 # finished .. stop .. return
syscall # make the syscall
1010 1010 1111 1111 1111 1111 1111 1111 -> 0111 1010 1111 1111 1111 1111 1111 1111
0xAAFFFFFF -> 0x7AFFFFFF
0000 0000 0000 1110 1111 0000 0000 0000 -> 0000 0000 0000 1111 0101 0000 0000 0000
0x000EF000 -> 0x000F5000
Comments
Leave a comment