Answer to Question #322501 in Assembler for kea

Question #322501

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.


1
Expert's answer
2022-04-02T15:47:28-0400
# 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


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS