Translate the following MIPS assembly language snippet into


Translate the following MIPS assembly language snippet into machine code. Write the machine code instructions in hexadecimal. Write assembly code that begins at address 0x00400000 that allows you to jump to the

Solution

1) add $a0,$a1,$0 -> add $d, $s, $t

0000 00ss ssst tttt dddd d000 0010 0000

$d = $a0 = 4 = 00100

$s = $a1 = 5 = 00101

$t = $0 = 0 = 00000

0000 00ss ssst tttt dddd d000 0010 0000 -> 0000 0000 1010 0000 0010 0000 0010 0000(00a02020)

so, add $a0,$a1,$0 -> 00a02020

2) jal f2 -> jal target

0000 11ii iiii iiii iiii iiii iiii iiii

ii iiii iiii iiii iiii iiii iiii = f2 >> 2 = 00400034 >> 2 = (0000 0000 0100 0000 0000 0000 0011 0100) >> 2

= (0000 0000 0001 0000 0000 0000 0000 1101) = (00 0001 0000 0000 0000 0000 1101)

0000 11ii iiii iiii iiii iiii iiii iiii -> 0000 1100 0001 0000 0000 0000 0000 1101 = (0c0010000d)

jal f2 => 0c0010000d

3) jr $ra -> jr $s

0000 00ss sss0 0000 0000 0000 0000 1000

$s = $ra = 31 = 11111

0000 0011 1110 0000 0000 0000 0000 1000 => (03e00008)

so, jr $ra => 03e00008

4) f2: sw $s0, 0($s2) -> sw $t, offset($s)

1010 11ss ssst tttt iiii iiii iiii iiii

$t = $s0 = 16 = 10000

$s = $s2 = 18 = 10010

offset = 0000 0000 0000 0000

1010 11ss ssst tttt iiii iiii iiii iiii -> 1010 1110 0101 0000 0000 0000 0000 0000 (ae500000)

sw $s0, 0($s2) -> ae500000

 Translate the following MIPS assembly language snippet into machine code. Write the machine code instructions in hexadecimal. Write assembly code that begins a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site