Assume that $s1 = 0x87654321. Determine the content of registers $s2 to $s4 after executing
the following instructions:
sll $s2,$s1, 16 # $s2 =
srl $s3,$s1, 8 # $s3 =
sra $s4,$s1, 12 # $s4 =
Write a mips assembly language program to execute these
instructions and verify the content of registers $s2 to $s4.
1)
sll $s2, $s1, 16 => $s2 = $s1 << 16 => $s2 = 0x87654321 << 16 => $s2 = 0x4321
srl $s3, $s1, 8 => $s2 = $s1 >> 8 => $s2 = 0x87654321 >> 8 => $s2 = 0x00876543
sra $s4, $s1, 12 => $s2 = $s1 >> 12 => $s2 = 0x87654321 >> 12 => $s2 = 0xFFF87654
2)
MIPS PROGRAM :-
.data
.text
.globl main
main:
sll $s2, $s1, 16
addi $v0, $0, 1
add $a0, $0, $s2 #printing $s2
syscall
srl $s3, $s1, 8
addi $v0, $0, 1
add $a0, $0, $s3 #printing $s3
syscall
sra $s4, $s1, 12
addi $v0, $0, 1
add $a0, $0, $s4 #printing $s4
syscall
#system exit
addi $v0, $0, 10
syscall
Get Answers For Free
Most questions answered within 1 hours.