Intermediate Code Generator
Expressed as quadruples:
Opr Arg1, Arg2, Store/result
If there is a
while
orif
, addjmpf
right away only
do while
usesjmpt
only
jmpf
always come first
Intermediate Code Generator OperatorsIntermediate Code Generator OperatorsPasted image 20241214144120.png
Example Alvina Aulia Intermediate Code Generator (while)
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 ...) is false
- add x, 1, t3
(x + 1)
- mov t3, , x
(x := ...)
- mod x, 2, t4
(x % 2)
- eq t4, 1, t5
(... == 1)
- jmpf t5, , [14]
(else ...)
- add y, 1, t6
(y + 1)
- mov t6, , y
(y := ...)
- jmp , , [16]
break
- sub y, 2, t7
(y - 2)
- mov t7, , y
(y := ...)
- jmp , , [17]
break
- ...
remaining code
Example Ivan Responsi 2023 (do while)
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
Code Generator
Annotated Parse Tree
Three Address Statement
resources:
https://www.youtube.com/watch?v=6yRB6dszSUo&ab_channel=HIMTIBINUS
* [x] watch all alvina aulia vids
* [x] watch responsi
(after OS)
* [ ] try example questions from kenny
* [ ] try example questions from others
* [ ] practice weak