Assume the following register contents: $t0 = 0xAAAAAAAA, $t1 = 0x12345678 For t
ID: 3790138 • Letter: A
Question
Assume the following register contents:
$t0 = 0xAAAAAAAA, $t1 = 0x12345678
For the register values shown above, what is the value of $t2 for the following sequence of instructions? sll $t2, $t0, 24 or $t2, $t2, $t1
For the register values shown above, what is the value of $t2 for the following sequence of instructions? sll $t2, $t0, 4 andi $t2, $t2, 1
For the register values shown above, what is the value of $t2 for the following sequence of instructions? srl $t2, $t0, 3 andi $t2, $t2, 0xFFEF
Explanation / Answer
Assuming the register size to be 32 bit,
1)
sll means "Shift left logical", so, $t2 will contain value in $t0 left shifted by 24 bits.
sll $t2, $t0, 24
So, $t2 = 0xAAAAAAAA << 24 = 0xAA000000
And then $t2 will contain "value in $t2 logical or with $t1".
or $t2, $t2, $t1
So, $t2 = 0xAA000000 OR 0x12345678 = 0xBA345678
2)
sll means "Shift left logical", so, $t2 will contain value in $t0 left shifted by 4 bits.
sll $t2, $t0, 4
Sp $t2 = 0x12345678 << 4 = 0x23456780
andi is "bitwise and immediate".So $t2 will contain "value in $t2 logical and -1".
andi $t2, $t2, 1
$t2 = 0x23456780 and -1 = 0x23456780
3)
srl means "Shift right logical", so, $t2 will contain value in $t0 right shifted by 3 bits.
srl $t2, $t0, 3
$t2 = 0x12345678 >> 3 = 0x2468ACF
andi is "bitwise and immediate".So $t2 will contain "value in $t2 logical and 0xFFEF".
andi $t2, $t2, 0xFFEF
$t2 = 0x2468ACF and 0xFFEF = 0x8ACF
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.