Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Assume that the variables a, b, c, d, e, and f are stored in consecutive memory locations, and that a register, say $20, has

1. Assume that the variables a, b, c, d, e, and f are stored in consecutive memory locations, and that a register, say $20, has the address for variable a.

(a) For the C language expression f = a + b + c + d;, what is the corresponding

EMU8086 assembly code?

(b) Do the same for the C language expression e = a + (f - 7);

2. Write equivalent C code for the following EMU8086 assembler fragments:

(a) add f, g, h ; (f g+h)

(b) addi h, i, 1 ;(hi+1) sub f, g, h ;(fg-h)

3. Assume that variables f, g, h, i, and j are already stored in general purpose registers, say $s0 to $s4 respectively, and the addresses of the first element of arrays A and B are stored in index registers, say $s6 and $s7 respectively. Provide EMU8086 code.

(a) f=g+h+B[4]; (b) f = g - A[B[4]];

4. 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);

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions