Register value - MIPS

0

The language is MIPS.

$s2 = 0x00000046   ;   $s1 = 0x000038c

What will be the $s2 value in Hex after the following code ? :

add $s2, $s1, $s2
srl $s1, $s1, 4
or  $s2, $s1, $s2

Can some one show me the way ?

thnx !

programming-languages
mips
asked on Stack Overflow Mar 25, 2011 by Batman

1 Answer

1

It might help to describe what each instruction does, e.g. in pseudo code, or here in C:

add $s2, $s1, $s2  # s2 = s1 + s2;
srl $s1, $s1, 4    # s1 = s1 >> 4;
or  $s2, $s1, $s2  # s2 = s1 | s2;
answered on Stack Overflow Mar 25, 2011 by Paul R

User contributions licensed under CC BY-SA 3.0