Mips 32 Answer the following questions showing your work Question 1: (10 points)
ID: 3870489 • Letter: M
Question
Mips 32
Answer the following questions showing your work Question 1: (10 points) Convert the following MIPS assembly code into machine language. Write the instructions in hexadecimal and show the steps you followed to get the solution. . addi $s0, $0, 73 sw $t1,-7(St2) sub $t1, $s7, $s2 Question 2: (10 points) Translate the following machine language code into assembly language: 0x22550005 Question 3: (10 points) What will be the hexadecimal value in register $s5 after running the following MIPS assembly program if the computer is: big-endian little-endian Assembly program is: li $tO, OxABBC97A5 sw $t0, 100(so) lb $s5, 102($0) Question 4: (10 points) Write a MIPS assembly code to swap the contents of the two registers, $tO and $t1. nitially, register $t0 has the value Ox10 and register $t1 has the value Ox99. Question 5: (10 points) Write a MIPS assembly code to Calculate the expression X+4y)2 where the values of x and y are in $S0 and $S1 respectivelyExplanation / Answer
1
a . ADDI $S0,$0,73
The instruction of MIPS is 32 bit long.
First 16 (0-15) bits specify the immediate value i.e., 7310 =0000 0000 0100 10012 = 4916
Next 5 (16-20) bits denotes Rd i.e.,$s0 which is 10000
Next 5 (21-25) bits denotes Rt i.e., $0 which is 00000
Remaining bits (26-31) is for opcode (ADDI) which is 001000
Therefore the machine code is 0010 0000 0001 0000 0000 0000 0100 1001 = 0x20100049
sw $t2, 8($t0) = 0xAD0A0008
b. sw $t1,-7($t2)
First 16 (0-15) bits specify the offset address(-7) in converting to binary the 1000 0000 0000 01112 = 800716
Next 5 (16-20) bits denotes Rt i.e., $t1 which is 01001
Next 5 (21-25) bits denotes base i.e.,$t0 which is 01000
Remaining bits (26-31) is for opcode (sw) which is 101011
Therefore the machine code is 1010 1101 0000 1001 1000 0000 0000 0111 = 0xAD098007
c. sub $t1,$s7, $s2
First 6 bits(0-5) denotes Opcode (SUB) which is 100010
Next 5 bits (6-10) is for the special instruction like subb, subc here it is 00000
Next 5 bits(11-15) denotes rd i.e., $t1 which is 01001
Next 5 bits (16-20) denotes rt i.e., $s2 which is 10010
Next 5 bits(21-25) denotes rs i.e., $s7 which is 10111
Remaining bits (26-31) is for special operands like asl,rsl etc which is 000000
Therefore sub $t1,$s7, $s2 machine code is 0000 0010 1111 0010 0100 1000 0010 0010 = 0x02F24822
Please Rate it if you find the answer is helpful...Thanks..:)