Question

In: Computer Science

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

Solutions

Expert Solution

  • addi $s0, $zero, -15

          Format:

                 Opcode(6-bit)        rs(5-bit)       rt(5-bit)      immediate(16-bit)

                    addi                    $zero       $s0 -15

                 001000                  00000          10000            1111111111110001

Hex: 0x2010fff1

---------------------------------------------------------------------------------------------------------------------

  • slt $t0, $s0, $s1

        Format:

           opcode(6-bit)       rs(5-bit)        rt(5-bit)      rd(5-bit)      shamt(5-bit)       func(6-bit)

           slt                        $s0               $s1             $t0   

            000000               10000           10001         01000      00000                101010

Hex: 0x02114020

-----------------------------------------------------------------------------------------------------------------------------------------

  • beq $t0, $zero, LEEQ

                 Here i assume LEEQ label after 'j' instruction

               Format:

                 Opcode(6-bit)        rs(5-bit)       rt(5-bit)      offset(16-bit)

                    beq                     $t0    $zero    1(After 1 instruction)

                 000100                  01000       00000           0000000000000001

Hex: 0x11000001

--------------------------------------------------------------------------------------------------------------------

  • j GRT

          Here i assume GRT label is the start label

        Format:

                 opcode(6-bit)             Target(26-bit)

                000010                     ox00003000(I assume )

              000010                  00000000000011000000000000>>2(shift 2)

           000010                    00000000000000110000000000

Hex: 0x08000c00

----------------------------------------------------------------------------------------------------------------------

Note:

GRT:
addi $s0,$0,-15
slt $t0,$s0,$s1
beq $t0,$0,LEEQ
j GRT
LEEQ:


Related Solutions

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: …
Translate the following C code into MIPS Assembly code, assuming Loop Variable k is in $s0...
Translate the following C code into MIPS Assembly code, assuming Loop Variable k is in $s0 and initially containing 0 . Also assume base of array Arr is in $s3 while ( k < = 10 ) { Arr[k] = k ; k = k + 1; }
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:" <<...
Consider the following C code: (10 marks) // write a MIPS instruction to initialize s0 to...
Consider the following C code: // write a MIPS instruction to initialize s0 to 6 t0 = ((s03 - 93)2 + s0 ) << 2 t1 = t0 / 4 Q2.1: Write a MIPS program that performs the operation of the above C program. Q2.2: What is the value of $t0 and $t1 after running your MIPS program (write your answer in a comment at the end of the code). Submit your answer to Q2 in a file named A2_Q2.asm
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;...
MIPS assembly code: procedure:                   addi $s0,$zero,0 loop:                   slt
MIPS assembly code: procedure:                   addi $s0,$zero,0 loop:                   slti $t1, $s0, 7                   beq $t1, $zero, exit                   addi $s0,$s0,1                   j loop exit:                   add $v0, $zero, $s0                   jr $ra       What is the corresponding high-level programming language code? Write a code in your preferred language. What is the result? (5 pts) Code: int add(int a, int b) {       return a+b; } int sub(int a, int b) {      ...
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"; } }
1. Convert the machine language instructions into assembly language instructions: 7976C1 06
1. Convert the machine language instructions into assembly language instructions: 7976C1 06
Translate following pseudo-code to MIPS assembly language cout << “\n Please input a number for $s0”;...
Translate following pseudo-code to MIPS assembly language cout << “\n Please input a number for $s0”; cin >> $s0; cout << “\n Please input a number for $s1”; cin >> $s1; cout << “\n Please input a number for $s2”; cin >> $s2; $t0 = $s0 / 8 - 2 * $s1 + $s2; cout << “\n the Value of the expression “$s0 / 8 - 2 * $s1 + $s2” is ”; cout >> $t0; return;
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT