Question

In: Computer Science

Convert the following MIPS instructions into machine code. Directly write down the answer without justifying steps...

  1. 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
    1. 2. lw $s0, 15($s1)

3. beq $s0, $s1, LABEL   #consider LABEL represents the 16-bit value 0x00FF

Solutions

Expert Solution

Solution :

MIPS to machine code :

a) add $s0, $s1, $s2 :
For add instruction, Initial special bits are : 000000
The register $s1 can be written as : 10001
The register $s2 can be written as : 10010
The register $s0 can be written as : 10000
The OPCODE for ADD is : 00000 100000
Hence the instruction in binary can be written as : 00000010001100101000000000100000
The instruction in hex can be written as : 0x02328020


b) lw $s0, 15($s1) :
The load word instruction has opcode of : 100011
The register $s1 can be written as : 10001
The register $s0 can be written as : 10000
The offset here is 0x15 : 0000000000010101
So the instruction in binary can be written as : 10001110001100000000000000010101
The instruction in hexadecimal can be written as : 0x8E300015


c) beq $s0, $s1, LABEL :
The beq instruction has opcode as : 000100
The register $s0 can be written as : 10000
The register $s1 can be written as : 10001
The 16 bit offset here is : 0000000011111111
The instruction in binary can be written as : 00010010000100010000000011111111
The instruction in hexadecimal can be written as : 0x121100FF

If you have any doubts, then you can ask in comment section. Thank you.


Related Solutions

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
Convert these machine codes to MIPS instructions: Ox29210003, and Ox8e460002
Convert these machine codes to MIPS instructions: Ox29210003, and Ox8e460002
Question: In the following MIPS assembly code, translate all the instructions to their corresponding machine code...
Question: In the following MIPS assembly code, translate all the instructions to their corresponding machine code in hexadecimal format. This code is stored in the memory from address 0x2fff0004. Loop: lw $t0, 4($s0)             addi $t1, $t1, -15             sll $t1, $t1, 2             beq $t1, $s1, Exit             addi $s0, $s0, 4             j Loop Exit: …
convert following C++ code into MIPS assembly: int main() {                                 &
convert following C++ code into MIPS assembly: int main() {                                         int x[10], occur, count = 0;                                                              cout << "Type in array numbers:" << endl; for (int i=0; i<10; i++) // reading in integers                               { cin >> x[i];        } cout << "Type in occurrence value:" << endl;                                 cin >> occur;                                                 // Finding and printing out occurrence indexes in the array                                  cout << "Occurrences indices are:" <<...
Translate the C function code below to the MIPS True Assembler Language code (machine instructions only)....
Translate the C function code below to the MIPS True Assembler Language code (machine instructions only). The function code should follow the conventions for MIPS function calls including passing parameters and returning results. Your function code must be written with the minimum number of machine instructions to be executed and without any use of MIPS pseudo-instructions. Myfunction(unsigned int a, unsigned int b, unsigned int c) { int i=0; while (a > c) { a /= b; i++; } return i;...
Convert the following C++ code into MIPS assembely. For testing I will be change the values...
Convert the following C++ code into MIPS assembely. For testing I will be change the values for q,y,x with few different values. //q -> $s0 //y -> $s1 //x -> $s2 int main(){ int q = 5; int y = 17; int x = 77; if ( q < 10){ cout << "inside if"; } elseif ( x > 0 || y < 10) { cout << "inside elseif"; } else { cout << "inside else"; } }
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);
This is to be done with MIPS assembly language. Write MIPS code which is equivalent to...
This is to be done with MIPS assembly language. Write MIPS code which is equivalent to the follow java program: int day = (int)(Math.random() * 7); switch (day) { case 1: System.out.println(“Monday”); break case 2: System.out.println(“Tuesday”); break case 3: System.out.println(“Wednesday”); break case 4: System.out.println(“Thursday”); break case 5: System.out.println(“Friday”); break case 6: System.out.println(“Saturday”); break case 0: System.out.println(“Sunday”); break }
1. Convert the machine language instructions into assembly language instructions: 7976C1 06
1. Convert the machine language instructions into assembly language instructions: 7976C1 06
Write MIPS assembly code for the following C code. for (i = 10; i < 30;...
Write MIPS assembly code for the following C code. for (i = 10; i < 30; i ++) { if ((ar[i] > b) || (ar[i] <= c)) ar[i] = 0; else ar[i] = a; }
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT