Question

In: Computer Science

Write assembly code for the following machine code. Assume that the segment is placed starting at...

Write assembly code for the following machine code. Assume that the segment is placed starting at location 80000. Create labels for jump and branch instructions. Indicate the actual memory addresses represented by such labels.

0010 1010 0000 1000 0000 0000 0000 1010
0001 0001 0000 0000 0000 0000 0000 0010
0000 0010 0001 0001 1000 0000 0010 0000
0000 1000 0000 0000 0100 1110 0010 0101
0000 0010 0001 0010 1000 0000 0010 0000

Solutions

Expert Solution

(1)0x2a08000a

SLTI          $s0        $t0            immediate
001010   10000   01000   0000000000001010

SLTI $t0, $s0, 10


(2)0x11000002
BEQ      $t0      $zero      offset
000100   01000   00000   0000000000000010

BEQ $t0 $zero 0x0002

(3)0x02118020

opcode       $s0       $s1        $s0       shamt   ADD
000000   10000   10001   10000   00000   100000

ADD $s0 $s0 $s1

(4)0x08004e25
J   target
000010   00000000000100111000100101


(5)0x02128020

opcode      $s0         $s2         $s0   shamt      ADD
000000   10000   10010   10000   00000   100000

ADD $s0 $s0 $s2

Assembly Program
Loop:
   SLTI $t0, $s0, 10
   BEQ $t0, $zero, Exit
   ADD $s0, $s0, $s1
   J   Loop
Exit:
   ADD $s0 $s0 $s2


Related Solutions

a. Write machine code for the following assembly code. Assume that the segment is placed starting...
a. Write machine code for the following assembly code. Assume that the segment is placed starting at location 80000. Use decimal numbers to represent each instruction. loop:         beq $s3, $s1, endwhile                  add $t0, $s3, $s4                  lw $t1, 0($t0)                  add $s0, $s0, $t1                  addi $s3, $s3, 4                  j loop endwhile: b. Write assembly code for the following machine code. Assume that the segment is placed starting at location 80000. Create labels for jump and branch instructions. Indicate the actual...
Represent following LEGv8 machine code into assembly instruction. 0x784302CD
Represent following LEGv8 machine code into assembly instruction. 0x784302CD
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: …
2. Translate the following C/Java code to MIPS assembly code. Assume that the values of a,...
2. Translate the following C/Java code to MIPS assembly code. Assume that the values of a, i, and j are in registers $s0, $t0, and $t1, respectively. Assume that register $s2 holds the base address of the array A (add comments to your MIPS code). j = 0; for(i=0 ; i<a ; i++) A[i]=i+j++;
4.Translate the following C code to MIPS assembly code. Assume that the value of i is...
4.Translate the following C code to MIPS assembly code. Assume that the value of i is in register $t0, and $s0 holds the base address of the integer MemArray if (i > 10) MemArray[i] = 0; else MemArray[i] = -MemArray[i]; 6.Translate the following C code to MIPS assembly code. Use a minimum number of instructions. Assume that the values of a, b, i, and j are in registers $s0, $s1, $t0, and $t1, respectively. Also, assume that register $s2 holds...
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; }
1.) Translate the following C code to MIPS assembly code. Assume that the variables f, g,...
1.) Translate the following C code to MIPS assembly code. Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3, and $s4, respectively. Assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively   B[8] = A[i-j]; 2.Translate the following C code to MIPS assembly code. Assume that the values of v in $a0, k in $a1, temp in $t0.    // leaf procedure that...
How to write fill.asm code (hack assembly)
How to write fill.asm code (hack assembly)
Compile the following C code to MIPS assembly. a. Assume that i and j are stored...
Compile the following C code to MIPS assembly. a. Assume that i and j are stored in register $s1 and $s2, respectively. i = i – 2 + j; b. Assume base address of Array B and the variable i are stored in registers $s3 and $s1, respectively. B[1] = (B[0] x 4) - I; Explain each step in detail! my professor has the following answer: 1) addi $t0, $s1, -2 add $s1, $$t0, $s2 2) lw $t0, 0 ($s3)...
6.) Write the assembly code for the following piece of code. Note: r,g,y,z correlate with the...
6.) Write the assembly code for the following piece of code. Note: r,g,y,z correlate with the w4, w8, w11, and w15. if (g * y > 25) || (y == z / 8) && (y * 4 < z - g)) y = r / 32; else g = 8 * (r - z);
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT