Question

Create three address code from the program snippet below. int a = 2, b = 8,...

Create three address code from the program snippet below.
int a = 2, b = 8, c = 4, d;
for (j = 0; j <= 10; j ++) (
a = a * (j * (b / c));
d = a * (j * (b / c));
}

Homework Answers

Answer #1

Three address code for the program will be as beneath. I have added remark against every announcement to clarify what some portion of code is being spoken to.

There are various ways for composing three location code, for example rather than utilizing L1 and L2 names, we can number each line and in goto proclamation use line number.

a := 2 ; initialize a
b := 8 ; initialize b
c := 4 ; initialize c
t1 := 0 ; initialize j
L1: if (t1 > 10) goto L2 ; conditional jump
t2 := b / c ; calculate b / c
t3 := t1 * t2 ; calculate j * (b/c)
t4 := a * t3 ; calculate a * (j * (b/c))
a := t4 ; store value in a
d := t4 ; store value in d
t1 := t1 + 1 ; increase j
goto L1 ; repeat loop
L2:

/*If this helps you, please let me know by giving a positive thumbs up. In case you have any queries, do let me know. I will revert back to you. Thank you!!*/

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Here is a “snippet,” a few lines, taken from a C language program. int a, b,...
Here is a “snippet,” a few lines, taken from a C language program. int a, b, c; float d, e, f; c = a + b; d = e + f; How many distinct opcodes will appear in the machine code compiled from this C snippet and why?
Given the following code snippet, what is this program calculating? for (int i = 0; i...
Given the following code snippet, what is this program calculating? for (int i = 0; i < n; i++) { sum += arr[i]; } sum /= n;
Convert each of the below C code snippet to LEGv8 assembly code. Assume variable a, b,...
Convert each of the below C code snippet to LEGv8 assembly code. Assume variable a, b, and c is stored in registers X19, X20, and X21 respectively. Base address of d is stored in register X22. Comment your assembly code. (24 Points) a. if (a > b) d[a] = b + 8; else d[a] = b - 16; b. for (i=0;i<a; i++) a = d[i] + c; c. i = 0; while ( d[i] == b) if(( a - i...
Write the C55x assembly code for each of the following C snippet code shown below. Assume...
Write the C55x assembly code for each of the following C snippet code shown below. Assume the 8-bit values a, b, c, and d are stored in locations 0x600, 0x601, 0x602, and 0x603 respectively in the memory. Store the result x in location 0x604 and y in location 0x60C. Do not use software to generate the assembly code and comment your code. x = (a - b)3 - (c*d); for (j=0;j<=200;j++)   y = y + (a * b);
Convert each of the below C code snippet to LEGv8 assembly code. Assume the variables a,...
Convert each of the below C code snippet to LEGv8 assembly code. Assume the variables a, b, and c are stored in registers X19, X20, and X21 respectively. Base address of d is stored in register X22. Comment your assembly code. a. if (a > b) d[a] = b + 8; else d[a] = b - 16; b. for (i=0;i 0) i++; a = d[i] + c; c. i = 0; while (d[i] == b) if ((a - i) >...
Module 4 Code L Write a short code snippet creating a class with three class variables...
Module 4 Code L Write a short code snippet creating a class with three class variables and one method setting all three variables. The class is called Person and the variables should be name, birth, and address. You should supply a method called setAll() that will be used to set the values of the class variables. // This is a JAVA program! I am a little confused any help would be great :)
1) Create a flowchart for the program below and Trace the program below with input of...
1) Create a flowchart for the program below and Trace the program below with input of 3 and then again with input of 5. #include <iostream> using namespace std; int Fall(int x, int m) { int Xm = 1, i=x; while(i>=x-m+1) { Xm = Xm*i; i=i-1; } return Xm; } int Delta(int x, int m) { int ans = 0; ans = Fall(x+1,m); ans = ans - Fall(x,m); return ans; } void main() { int x = 0, m =...
(C++ program) Use the code segment below to answer the two questions that follow. … int...
(C++ program) Use the code segment below to answer the two questions that follow. … int size = 0; cout << “Enter size: “; cin >> size; int sizeCode = size / 10; if (sizeCode == 0)    cout << “extra small”; else if(sizeCode == 1 )    cout << “small”; else if (sizeCode == 2)    cout << “medium”; else if (sizeCode == 3)    cout << “large”; else    cout << “extra large”; //end if … What would...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item = 0; 4. while (count < 4) { 5.      cout << "Enter item cost: "; 6.      cin >> item; 7.      item_total += item; 8.      ++count; 9. } 10. int average_cost = round(item_total / count); 11. cout << "Total cost: " << item_total << "\nAverage cost: " << average_cost; (Refer to Code Example 8-1.) If the user enters 5, 10, and 15 at the prompts, the output is: Total...
Using loop logic in a python code snippet, create a loop that counts down from 15...
Using loop logic in a python code snippet, create a loop that counts down from 15 to 5 by 3's printing the count as it is processing. example output: Counter Example count =  15 count =  10 count =  5
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT