Convert from Java code to MIPS Assembly code
C statements |
MIPS Assembly code |
f = (g + h) + (j + 13) |
|
A[12] = h + A[8] |
|
if (f != 0) { f = f + j; j = j - 1; } |
|
if (j==h) f = g+h; f = f + A[2]; |
|
if (j !=h ) f = f + 1; f = g + h; |
a)
add t0, g, h
add f, g, h
add t1, i, j
b)lw $t0, 32($s3)
add $t0, $s2, $t0
sw $t0, 48($s3)
c)
Let $s3->f
$s2->j
bne $s3,0,Else
Else:
add $s3, $s3, $s2
sub $s2,$2,1
Exit
===========================================
d)
if (j !=h ) f = f + 1;
f = g + h;
Let $s1=j,$s2=h,$s3=f,$s4=g
bne $s1,$s2,Else
add $s3,$s3,1
Else:add $s3,$s4,$s2
Exit
=====================================================
if (j==h) f = g+h;
else f = g-h;
f = f + A[2];
Let
$s1=j,$s2=h,$s3=f,$s4=g,$s5=address of A,
lw $t0, 8($s5) # A[2] is brought into $t0
bne $s1,$s2,Else
add $s3,$s4,$s2
Else:add $s3,$s4,$s2
add $s3,$s3,$t0
Convert from Java code to MIPS Assembly code C statements MIPS Assembly code f = (g...
Convert the following c code into instructions MIPS Assembly language. Assume a associated with $s0, i with $s1, and j with $s2. if( i < 10) { if( j < 10) { a = 0; } else { a = 1;} } else { a = 2; }
B2. Convert the C code to MIPS assembly with only 2 efficient instructions: Register assignment: timer-v0 int timer = 0x0AC8 0001; B3. Write MIPS assembly code segment for the following C code snippet for (i - 0, i < 100; i++) -array Register assignment: i-) $ao Base of array -> $s0 array [ i+1] [i] / 2;
B2. Convert the C code to MIPS assembly with only 2 efficient instructions: Register assignment: timer-v0 int timer = 0x0AC8 0001; B3. Write...
6. [5 points] Translate the following c code to MIPS assembly code. f = g - A(B[h]] The value of A, B, g, and h are in registers $a0, $al, $a2, and Sa3, respectively. The value of f should be stored in the register $v0.
its
brr[8]
(40%) Convert the following C-pseudo code into MIPS assembly code as a standalone program (including main and all the required directives). You can use any register. You must comply, however, with the convention of register usage. Before writing your code perform an explicit register allocation phase. Note that the C snippet is int arr[8]; int brr[4]-{1, 2, 3, 4, 5, 6, 7, 8) int i-8; while (i>-0) arrli]-brr[i-); (40%) Convert the following C-pseudo code into MIPS assembly code...
For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables f, g, h, and i are given and could be considered 32-bit integers as declared in a C program. Use a minimal number of MIPS assembly instructions: f g(h 5);
For the following C statement, what is the corresponding MIPS assembly code? Assume that the variables f, g, h, and i are given and could be considered 32-bit integers as declared in a C...
Please answer the following questions involving MIPS assembly code: A) For the C statement below, what is the corresponding MIPS assembly code? Assume f, g are stored in S1 and S2. f = g + (-f -5) B) For the C statement below, what is the corresponding MIPS assembly code? Assume i and j are assigned in registers S1 and S2 respectively and base of address of arrays A and B are in registers S6 and S7. B[8] = A[i...
1. (15 pts) For the following C statement, what is the corresponding MIPS assembly code? Assume f, g, h correspond to $80, $s1, and $s2, respectively. f=g+(h-5) 2. (15 pts) For the following pseudo-MIPS assembly instructions, what is the corresponding C code? add f, g, h add f,i, f 3. (30 pts) Provide the instruction type, assembly language instruction, and binary representation of the instruction described by the following MIPS fields: a. op = 0, rs = 18, rt=9, rd...
4. (3 pts. each) Write the hexadecimal representation of each MIPS assembly instruction: (4.1) sub $s3, $t1, $s2 (4.2) bne $t3, $t4, 18 (4.3) sll $s0, $t5, 2 5. (20 pts.) Consider the following C (or java) code: else f=f+2; By storing the value of j in Ss0, write a sequence of MIPS assembly instructions that will execute these lines of code for the following two cases: (5.1) assuming that the values of f, g and h are stored in...
Convert the high-level code into a MIPS-assembly program. Assume a is in $s0, b is in $s1, and c is in $s2. c = 0; while (a>0) { a = a-b; c++; }
Problem 2 Points (40) The following problems deal with translating from C to MIPS. Assume that the variables g, h, j, and j are assigned to registers Ss0, Ss1, Ss2, Ss3, and Ss4, respectively. Assume that the base address of the arrays A and B are in registers Ss6 and Ss7 respectively 1. Provide the MIPS assembly code for the above C statements. Use a minimal number of MIPS assembly instructions 2. For the C statements above, how many MIPS...