Compilers and computer architecture Code-generation (1): stack-machines
Martin Berger 1 November 2019
1Email: M.F.Berger@sussex.ac.uk, Office hours: Wed 12-13 in
Chi-2R312
1 / 1
Compilers and computer architecture Code-generation (1): - - PowerPoint PPT Presentation
Compilers and computer architecture Code-generation (1): stack-machines Martin Berger 1 November 2019 1 Email: M.F.Berger@sussex.ac.uk , Office hours: Wed 12-13 in Chi-2R312 1 / 1 Recall the function of compilers 2 / 1 Plan for the next two
1Email: M.F.Berger@sussex.ac.uk, Office hours: Wed 12-13 in
1 / 1
2 / 1
Lexical analysis Syntax analysis Source program Semantic analysis, e.g. type checking Intermediate code generation Optimisation Code generation Translated program
3 / 1
4 / 1
5 / 1
6 / 1
7 / 1
8 / 1
9 / 1
10 / 1
11 / 1
12 / 1
13 / 1
14 / 1
15 / 1
16 / 1
17 / 1
18 / 1
19 / 1
20 / 1
21 / 1
22 / 1
23 / 1
24 / 1
25 / 1
26 / 1
27 / 1
28 / 1
29 / 1
30 / 1
31 / 1
32 / 1
33 / 1
34 / 1
35 / 1
36 / 1
37 / 1
38 / 1
39 / 1
40 / 1
41 / 1
42 / 1
43 / 1
44 / 1
45 / 1
I_PushImm ( 0 ) // Begin first command x = 0 I_Pop ( x ) I_PushImm ( 1 ) // Initialisation of loop I_Pop ( i ) I_DefineLabel ( loopCondition ) I_PushImm ( 100 ) // test for loop termination I_PushAbs ( i ) I_CompGreaterThan I_JumpTrue ( loopExit ) I_PushAbs ( i ) // Command x = x+i I_PushAbs ( x ) I_Plus I_Pop ( x ) I_PushImm ( 1 ) // Command x = x+1 I_PushAbs ( x ) I_Plus I_Pop ( x ) I_PushImm ( 1 ) // Incrementing loop variable I_PushAbs ( i ) I_Plus I_Pop ( i ) I_Jump ( loopCondition ) I_DefineLabel( loopExit ) 46 / 1
47 / 1
48 / 1