Given to 0x55555555 and t1 0x12345678 what is the value of
Given $to = 0x55555555 and $t1= 0x12345678, what is the value of $t2 for the following sequence of instructions: sll $t2, $t0, 4. or $t2, $t2, $t1
Solution
Ans is
The value of n << s is n left-shifted s bit positions; this is equivalent (even if overflow occurs) to multiplication by two to the power s.
And it\'s true: this is exactly the result you\'d get if you multiplied -0x55555555 by two to the power of s, due to overflow. In particular, 0x55555555 has alternating 0s and 1s, so you\'re shifting alternating 0s and 1s into the sign bit, so the sign is flipping every time.
This exercise is playing with bits. Visually we are dropping the left most hex digit and sweeping in a zero, in binary, its a bit different, no pun intended.
t2 = (t0 << 4) ||t1
then ans is
0x57755778
