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));
}
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!!*/
Get Answers For Free
Most questions answered within 1 hours.