Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For the following, assume that variables a, b, and i are kept in general purpose

ID: 3918315 • Letter: F

Question

For the following, assume that variables a, b, and i are kept in general purpose registers and that a base register holds the base address of array D.

Write EMU8086 assembly code for the following C code fragments, try to minimize the number of assembly instructions:

(a) A simple for loop: for (i = 0; i < 10, i++) a += b;

(b) do the same thing for the following C code.

for (i = 0; i < 10, i+=2) {

D[i] = D[i] + 1;   D[i+1] = D[i+1] + 1;

                  }

(c) A while loop with an array:

while (a < 10) {

           D[a] = a + b; a += 1; // could also be a++; }

(d) An example of recursion:

int fib (int a, int b, int i)

{

if (i == 0) return b; else return fib(a+b, a, i-1);

}  

Explanation / Answer

a) Loop:-

c)Array:-

d) Recursion :-

This will produce the result of factorial.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote