Intermediate Code Generator
Expressed as quadruples:
Opr Arg1, Arg2, Store/result
If there is a while, add
jmpf
right away only
jmpf
always come first
Intermediate Code Generator OperatorsIntermediate Code Generator OperatorsPasted image 20241214144120.png
Example Alvina Aulia Intermediate Code Generator
x := 1;
y := x + 10;
while (x<y) {
x := x + 1;
if (x % 2 == 1) then
y := y + 1;
else y := y - 2;
}
- mov 1, , x
(x := 1)
- add x, 10, t1
(x + 10)
- mov t1, , y
(y := ...)
- lt x, y, t2
(x < y)
- jmpf t2, , [17]
(while ...)
- add x, 1, t3
(x + 1)
- mov x, , t3
(x := ...)
- mod x, 2, t4
(x % 2)
- eq t4, 1, t5
(... == 1)
- jmpf t5, , [14]
(if ...)
- add y, 1, t6
(y + 1)
- mov t6, , y
(y := ...)
- jmp , , [17]
break
- sub y, 1, t7
(y - 2)
- mov t7, , y
(y := ...)
- jmp , , [17]
break
- ...
remaining code
Status: #idea
Tags: compilation-techniques > Final ExamCompilation Techniques NotesMid Exam
RE to DFA
RE to E-NFA to DFA
Context Free Grammar
Top down parsing
Final Exam
Bottom Up Parsing
Directed Acyclic Graph
TAC, Triples, Quadriples
Intermediate Code Generator
Annotated Parse Tree
Three Address Statement
https://www.youtube.com/watch?v=\_Jng5xgLxkI&list=PLB2GiO0mMjw9J_OwnDMAqtsANzWsIylQz&index=9&ab_channel=HIMTIBINUS
Status: #MOC
Tags: