Question

In: Computer Science

Convert in machine code for MIPS LW S5, 33(S2); Add R1, T3, S5; Sub T4, S3,...

Convert in machine code for MIPS

LW S5, 33(S2);

Add R1, T3, S5;

Sub T4, S3, R3;

SW T4, 124(T7);

Solutions

Expert Solution

Mips machine code conversion of

LW S5, 33(S2)

Syntax:

lw $t, offset($s)

Encoding:

1000 11ss ssst tttt iiii iiii iiii iiii

So here S5 is register r21 and S2 is r18

So source = S2 = 10010

Target S5 = 10101

Off set = 33 = 0000000000100001

Machine code = 10001110010101010000000000100001 = 0x8E550021

Add R1, T3, S5;

Syntax:

and $d, $s, $t

Encoding:

0000 00ss ssst tttt dddd d000 0010 0100

source = t3 = r11 = 01011

Target =S5 =r21 = 10101

Destination = r1 = 00001

Machine code = 00000001011101010000100000100100 = 0x01750824

Sub T4, S3, R3;

Syntax:

sub $d, $s, $t

Encoding:

0000 00ss ssst tttt dddd d000 0010 0010

source = s3 = r19 = 10011

Target =r3 = 00011

Destination = t4 = r12 = 01100

Machine code = 00000010011000110110000000100010 = 0x02636022

SW T4, 124(T7);

Syntax:

sw $t, offset($s)

Encoding:

1010 11ss ssst tttt iiii iiii iiii iiii

Source = t7 = r15 = 01111

Target = t4 = r12 = 01100

Offset = 124 = 0000000001111100

Machine code = 10101101111011000000000001111100 = 0xADEC007C


Related Solutions

Find the data hazards in the following code segment lw $t1,0($t1) addi $t1,$t1,100 or $t2,$t3,$t1 add...
Find the data hazards in the following code segment lw $t1,0($t1) addi $t1,$t1,100 or $t2,$t3,$t1 add $a0,$a1,$t2 ori $a0,$a0,42 add $t5,$a0,$t2 Reorder the following code segment to remove the data hazards. Assume that data forwarding takes place: lw $t0,24($a0) sub $t4,$t4,$t0 sub $t8,$t8,$t3 add $t6,$t6,$t5 mul $t7,$t7,$t1 What is the CPI for the reordered sequence of instructions in the preceding problem?
make multiply function with ‘add’ command, Convert to mips code Don’t use ‘mult’ Use 'add' multiple...
make multiply function with ‘add’ command, Convert to mips code Don’t use ‘mult’ Use 'add' multiple times Get input from key-board and display the result in the console window
Convert the following to machine code and then back to MIPS instructions: 1) a. addi $s0,...
Convert the following to machine code and then back to MIPS instructions: 1) a. addi $s0, $zero, -15 b. slt $t0, $s0, $s1 c. beq $t0, $zero, LEEQ d. j GRT
I have this MIPS code and I need to find: add f,g,h add f,f,i sub f,f,j...
I have this MIPS code and I need to find: add f,g,h add f,f,i sub f,f,j a. How many bits does it take to encode ? b. How many bits needed in register file to store the data?
Convert the following MIPS instructions into machine code. Directly write down the answer without justifying steps...
Convert the following MIPS instructions into machine code. Directly write down the answer without justifying steps will result 0 credit. All steps must be typed in Word. 1. add $s0, $s1, $s2 2. lw $s0, 15($s1) 3. beq $s0, $s1, LABEL   #consider LABEL represents the 16-bit value 0x00FF
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT