SlideShare a Scribd company logo
CSE340 - Principles of
Programming Languages
Lecture 20:
Intermediate Code I
Javier Gonzalez-Sanchez
BYENG M1-38
Office Hours: By appointment
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 2
A Compiler in Action
Lexer	
Parser	
Semantic  
Analyzer	
Code  
Generation	
Words
Tokens
Sentences
Symbol table
Uniqueness
Type matching
Translation
Source Code Ăšïƒš Intermediate Code
Intermediate Code Ăšïƒš Machine or Binary Code
Analysis
Compilation
Assembly
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 3
Source Code
{
int a;
int b;
int c;
int d;
if (a != 5) {
b = c + d;
}
print (a);
}
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 4
Intermediate (Object) Code
a,int,global 0
b,int,global 0
c,int,global 0
d,int,global 0
#E1,int,label,9
#P,int,label,1
@
lod a, 0
lit 5, 0
opr 14, 0
jmc #e1, false
lod c, 0
lod d, 0
opr 2, 0
sto b, 0
lod a, 0
opr 21, 0
opr 1, 0
Symbol table
Instructions
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 5
Translate Source to Object
{
int a;
int b;
int c;
int d;
if (a != 5) {
b = c + d;
}
print (a);
}
a,int,global 0
b,int,global 0
c,int,global 0
d,int,global 0
#E1,int,label,9
#P,int,label,1
@
lod , 0
lit 5, 0
opr 14, 0
jmc #e1, false
lod c, 0
lod d, 0
opr 2, 0
sto b, 0
lod a, 0
opr 21, 0
opr 1, 0
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 6
High-Level Languages
X,E,G,O,O
#e1,I,I,0,7
@
OPR 19, AX
STO x, AX
LIT 5, AX
OPR 21, AX
LOD #e1,AX
CAL 1, AX
OPR 0, AX
5
Virtual Machine
(interpreter)
// sorce code
int x;
int foo () {
read (x);
print (5);
}
main () {
foo ();
}
Lexer
Parser
Semantic Analyzer
Code Generation
01001010101000010
01010100101010010
10100100000011011
11010010110101111
00010010101010010
10101001010101011
Assembler
compilation execution
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 7
High-Level Languages
X,E,G,O,O
#e1,I,I,0,7
@
OPR 19, AX
STO x, AX
LIT 5, AX
OPR 21, AX
LOD #e1,AX
CAL 1, AX
OPR 0, AX
5
Virtual Machine
(interpreter)
// sorce code
int x;
int foo () {
read (x);
print (5);
}
main () {
foo ();
}
Lexer
Parser
Semantic Analyzer
Code Generation
01001010101000010
01010100101010010
10100100000011011
11010010110101111
00010010101010010
10101001010101011
Assembler
compilation execution
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 8
A Simple Virtual Machine
	
CPU	
	
	
	
	
	
	
	
ALU	
	
	
	
	
	
	
	
	
	
	
Register	
	
	
	
	
	
Memory
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 9
	
Memory	
	
	
	
	
	
	
	
        program	
	
	
	
	
	
	
	
A Simple Virtual Machine
	
CPU	
	
	
	
	
	
	
	
ALU	
	
	
	
	
	
	
	
	
	
	
Register	
	
	
	
	
	
	
	
	
Code
sto 0, s
sto 0, d
sto 0, c
sto 0, d
lod s, 0
lit “s”, 0
opr 14, 0
jmc #a1, false
lod b, 0	
	
	
	
	
	
	
	
	
	
	
	
	
Symbol  
Table
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 10
A Simple Virtual Machine
	
CPU	
	
	
	
	
	
	
	
ALU	
	
	
	
	
	
	
	
	
	
	
Register	
	
	
	
	
	
	
PC	
	
	
	
	
Memory	
	
	
	
	
	
	
	
        program	
	
	
	
	
	
	
	
	
	
	
	
Code
sto 0, s
sto 0, d
sto 0, c
sto 0, d
lod s, 0
lit “s”, 0
opr 14, 0
jmc #a1, false
lod b, 0	
	
	
	
	
	
	
	
	
	
	
	
	
Symbol  
Table
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 11
Instructions
	
	
	
instruction first second
parameter parameter
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 12
Instructions
‱  LIT <value>, <register_id>
Put a constant value in a CPU register
Examples:
LIT 5, 0
LIT 5.5, 0
LIT 'a', 0
LIT ”hello”, 0
LIT true, 0
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 13
Instructions
‱  LOD <variable>, <register_id>
Search for <variable> in the symbol table
Read its value
Put the value of <variable> in the CPU register
Examples:
LOD a, 0
LOD hello, 0
LOD cse340, 0
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 14
Instructions
‱  STO <variable>, <register_id>
Read a value from the CPU register
Search for <variable> in the symbol table
Store the value into the variable
Examples:
STO a, 0
STO hello, 0
STO cse340, 0
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 15
Example
Source Code:	
{
int a; int b;
a = 10;
b = a;
Symbol Table:
Type Name Scope Value
int a global 0
int b global 0
Intermediate (Object) Code:
LIT 10,0
STO a,0
LOD a,0
STO b,0
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 16
Instructions
‱  OPR <operation>, <register_id>
Read one or two values from the CPU register
Do the operation <operation>
Put the result into the CPU register
Examples:
OPR 1, 0 ; return
OPR 2, 0 ; add
OPR 3, 0 ; subtract
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 17
Operations
Number Action
0 Exit program
1 Return
2 ADD: POP A, POP B, PUSH B+A
3 SUBTRACT: POP A, POP B, PUSH B-A
4 MULTIPLY: POP A, POP B, PUSH B*A
5 DIVIDE: POP A, POP B, PUSH B/A
6 MOD: POP A, POP B, PUSH (B mod A)
7 POW: POP A, POP B, PUSH (A to the power B)
8 OR: POP A, POP B, PUSH (B or A)
9 AND: POP A, POP B, PUSH (B and A)
10 NOT: POP A, PUSH (not A)
11 TEST GREATER THAN: POP A, POP B, PUSH (B>A)
12 TEST LESS THAN: POP A, POP B, PUSH (B<A)
13 TEST GREATER THAN OR EQUAL: POP A, POP B, PUSH (B>=A)
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 18
Operations
Number Action
14 TEST LESS THAN OR EQUAL: POP A, POP B, PUSH (B<=A)
15 TEST EQUAL: POP A, POP B, PUSH (B=A)
16 TEST NOT EQUAL: POP A, POP B, PUSH (B<>A)
17
18 clear screen
19 read a value from the standard input
20 print a value to the standard output
21 print a value to the standard output and a newline character
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 19
Example
{
int a;
int b;
a = 10;
b = a;
a = a * 10;
b = 2 + 3 + 4;
}
Type Name Scope Value
int a global 0
int b global 0
LIT 10, 0
STO a, 0
LOD a, 0
STO b, 0
LOD a, 0
LIT 10, 0
OPR 4, 0 ; multiply
STO a, 0
LIT 2, 0
LIT 3, 0
OPR 2, 0 ; add
LIT 4, 0
OPR 2, 0 ; add
STO b, 0
OPR 1,0
OPR 0,0
Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 20
to be continued...
CSE340 - Principles of Programming Languages
Javier Gonzalez-Sanchez
javiergs@asu.edu
Summer 2015
Disclaimer. These slides can only be used as study material for the class CSE340 at ASU. They cannot be distributed or used for another purpose.

More Related Content

PDF
201506 CSE340 Lecture 21
PDF
201506 CSE340 Lecture 18
PDF
201506 CSE340 Lecture 19
PDF
201506 CSE340 Lecture 07
PDF
201506 CSE340 Lecture 22
PDF
201506 CSE340 Lecture 23
PDF
201506 CSE340 Lecture 13
PDF
201505 CSE340 Lecture 05
201506 CSE340 Lecture 21
201506 CSE340 Lecture 18
201506 CSE340 Lecture 19
201506 CSE340 Lecture 07
201506 CSE340 Lecture 22
201506 CSE340 Lecture 23
201506 CSE340 Lecture 13
201505 CSE340 Lecture 05

What's hot (20)

PDF
201506 CSE340 Lecture 15
PPTX
Booth algorithm
PDF
201505 CSE340 Lecture 06
PDF
Infix to Prefix (Conversion, Evaluation, Code)
PDF
Project on digital vlsi design
PPT
Lab 1
PPTX
Arithmetic and logic operations in c
PDF
201506 CSE340 Lecture 10
PPTX
Arithmetic and Logic instructions in Embedded C
PPT
Expression evaluation
PPTX
Testing lecture after lec 4
PPT
Functions & Procedures [7]
PDF
Code quailty metrics demystified
PDF
Lecture 8 increment_and_decrement_operators
PPT
Lecture 3 c++
PDF
Arithmetic operator
DOCX
Program for pyramid
 
PPTX
Prefix, Infix and Post-fix Notations
PPTX
Machine language
201506 CSE340 Lecture 15
Booth algorithm
201505 CSE340 Lecture 06
Infix to Prefix (Conversion, Evaluation, Code)
Project on digital vlsi design
Lab 1
Arithmetic and logic operations in c
201506 CSE340 Lecture 10
Arithmetic and Logic instructions in Embedded C
Expression evaluation
Testing lecture after lec 4
Functions & Procedures [7]
Code quailty metrics demystified
Lecture 8 increment_and_decrement_operators
Lecture 3 c++
Arithmetic operator
Program for pyramid
 
Prefix, Infix and Post-fix Notations
Machine language
Ad

Viewers also liked (20)

PPT
Slides boekpresentatie 'Sociale Media en Journalistiek'
PDF
Thehub Milan Startup Weekend
PPT
挫谈php撌java
 
PPTX
LiveOffice Email Archiving & Compliance 101
PPT
Fun at the Sculpture Gardens with Ally and Lauren
PPT
Diego Ernesto Leal
PDF
201010 SPLASH Tutorial
PDF
Week7
PPT
Chapter 3 presentation
PDF
Valvuloplastie
PPT
Presentation
PDF
007 014 belcaro corrige
PPT
Chapter 12
PDF
Angeiologie 4 2013 - 1-2014 livre des resumes
PPTX
Sanghamitra Iyengar - Índia
PPSX
open office
PDF
Terofox v port catalogue (rev.01)
PPTX
Gr trav f. risk cv s.metabolique
PPT
Corporate taxation introduction
Slides boekpresentatie 'Sociale Media en Journalistiek'
Thehub Milan Startup Weekend
挫谈php撌java
 
LiveOffice Email Archiving & Compliance 101
Fun at the Sculpture Gardens with Ally and Lauren
Diego Ernesto Leal
201010 SPLASH Tutorial
Week7
Chapter 3 presentation
Valvuloplastie
Presentation
007 014 belcaro corrige
Chapter 12
Angeiologie 4 2013 - 1-2014 livre des resumes
Sanghamitra Iyengar - Índia
open office
Terofox v port catalogue (rev.01)
Gr trav f. risk cv s.metabolique
Corporate taxation introduction
Ad

Similar to 201506 CSE340 Lecture 20 (20)

PPT
5_IntermediateCodeGeneration.ppt
PDF
201505 - CSE340 Lecture 01
PPTX
ISA.pptx
PPTX
Chapter_04_ARM_Assembly.pptx ARM ASSEMBLY CODE
PPT
Compiler Design Unit 5
PDF
201505 CSE340 Lecture 02
PPTX
Introduction to Assembly Language & various basic things
PPTX
Kuliah07 TBK-Compiler 111111111111111111
PPT
Assembly Langauge Assembly Langauge Assembly Langauge
PPTX
UNit-4.pptx programming the basic computer
PPTX
Lecture 12 intermediate code generation
PPT
MIPS instruction set microprocessor lecture notes
PDF
Assembly Codes in C Programmes - A Short Notes by Arun Umrao
PPTX
Unit iv(simple code generator)
PPTX
Assembly chapter One.pptx
PPT
Assembly Language Basics
PPT
Unit 1 c - all topics
PDF
Writing a C Compiler Build a Real Programming Language from Scratch Nora Sandler
PDF
lec01_introanalytics-for-the-internet-of-things-iot-intelligent-analytics-for...
PDF
201801 CSE240 Lecture 07
5_IntermediateCodeGeneration.ppt
201505 - CSE340 Lecture 01
ISA.pptx
Chapter_04_ARM_Assembly.pptx ARM ASSEMBLY CODE
Compiler Design Unit 5
201505 CSE340 Lecture 02
Introduction to Assembly Language & various basic things
Kuliah07 TBK-Compiler 111111111111111111
Assembly Langauge Assembly Langauge Assembly Langauge
UNit-4.pptx programming the basic computer
Lecture 12 intermediate code generation
MIPS instruction set microprocessor lecture notes
Assembly Codes in C Programmes - A Short Notes by Arun Umrao
Unit iv(simple code generator)
Assembly chapter One.pptx
Assembly Language Basics
Unit 1 c - all topics
Writing a C Compiler Build a Real Programming Language from Scratch Nora Sandler
lec01_introanalytics-for-the-internet-of-things-iot-intelligent-analytics-for...
201801 CSE240 Lecture 07

More from Javier Gonzalez-Sanchez (20)

PDF
201804 SER332 Lecture 01
PDF
201801 SER332 Lecture 03
PDF
201801 SER332 Lecture 04
PDF
201801 SER332 Lecture 02
PDF
201801 CSE240 Lecture 26
PDF
201801 CSE240 Lecture 25
PDF
201801 CSE240 Lecture 24
PDF
201801 CSE240 Lecture 23
PDF
201801 CSE240 Lecture 22
PDF
201801 CSE240 Lecture 21
PDF
201801 CSE240 Lecture 20
PDF
201801 CSE240 Lecture 19
PDF
201801 CSE240 Lecture 18
PDF
201801 CSE240 Lecture 17
PDF
201801 CSE240 Lecture 16
PDF
201801 CSE240 Lecture 15
PDF
201801 CSE240 Lecture 14
PDF
201801 CSE240 Lecture 13
PDF
201801 CSE240 Lecture 12
PDF
201801 CSE240 Lecture 11
201804 SER332 Lecture 01
201801 SER332 Lecture 03
201801 SER332 Lecture 04
201801 SER332 Lecture 02
201801 CSE240 Lecture 26
201801 CSE240 Lecture 25
201801 CSE240 Lecture 24
201801 CSE240 Lecture 23
201801 CSE240 Lecture 22
201801 CSE240 Lecture 21
201801 CSE240 Lecture 20
201801 CSE240 Lecture 19
201801 CSE240 Lecture 18
201801 CSE240 Lecture 17
201801 CSE240 Lecture 16
201801 CSE240 Lecture 15
201801 CSE240 Lecture 14
201801 CSE240 Lecture 13
201801 CSE240 Lecture 12
201801 CSE240 Lecture 11

Recently uploaded (20)

PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Introduction to Artificial Intelligence
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Transform Your Business with a Software ERP System
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Nekopoi APK 2025 free lastest update
PDF
System and Network Administration Chapter 2
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Introduction to Artificial Intelligence
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Upgrade and Innovation Strategies for SAP ERP Customers
How to Choose the Right IT Partner for Your Business in Malaysia
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
wealthsignaloriginal-com-DS-text-... (1).pdf
Reimagine Home Health with the Power of Agentic AI​
How to Migrate SBCGlobal Email to Yahoo Easily
Transform Your Business with a Software ERP System
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Design an Analysis of Algorithms I-SECS-1021-03
PTS Company Brochure 2025 (1).pdf.......
Nekopoi APK 2025 free lastest update
System and Network Administration Chapter 2
Odoo Companies in India – Driving Business Transformation.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Understanding Forklifts - TECH EHS Solution
Adobe Illustrator 28.6 Crack My Vision of Vector Design

201506 CSE340 Lecture 20

  • 1. CSE340 - Principles of Programming Languages Lecture 20: Intermediate Code I Javier Gonzalez-Sanchez BYENG M1-38 Office Hours: By appointment
  • 2. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 2 A Compiler in Action Lexer Parser Semantic   Analyzer Code   Generation Words Tokens Sentences Symbol table Uniqueness Type matching Translation Source Code Ăšïƒš Intermediate Code Intermediate Code Ăšïƒš Machine or Binary Code Analysis Compilation Assembly
  • 3. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 3 Source Code { int a; int b; int c; int d; if (a != 5) { b = c + d; } print (a); }
  • 4. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 4 Intermediate (Object) Code a,int,global 0 b,int,global 0 c,int,global 0 d,int,global 0 #E1,int,label,9 #P,int,label,1 @ lod a, 0 lit 5, 0 opr 14, 0 jmc #e1, false lod c, 0 lod d, 0 opr 2, 0 sto b, 0 lod a, 0 opr 21, 0 opr 1, 0 Symbol table Instructions
  • 5. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 5 Translate Source to Object { int a; int b; int c; int d; if (a != 5) { b = c + d; } print (a); } a,int,global 0 b,int,global 0 c,int,global 0 d,int,global 0 #E1,int,label,9 #P,int,label,1 @ lod , 0 lit 5, 0 opr 14, 0 jmc #e1, false lod c, 0 lod d, 0 opr 2, 0 sto b, 0 lod a, 0 opr 21, 0 opr 1, 0
  • 6. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 6 High-Level Languages X,E,G,O,O #e1,I,I,0,7 @ OPR 19, AX STO x, AX LIT 5, AX OPR 21, AX LOD #e1,AX CAL 1, AX OPR 0, AX 5 Virtual Machine (interpreter) // sorce code int x; int foo () { read (x); print (5); } main () { foo (); } Lexer Parser Semantic Analyzer Code Generation 01001010101000010 01010100101010010 10100100000011011 11010010110101111 00010010101010010 10101001010101011 Assembler compilation execution
  • 7. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 7 High-Level Languages X,E,G,O,O #e1,I,I,0,7 @ OPR 19, AX STO x, AX LIT 5, AX OPR 21, AX LOD #e1,AX CAL 1, AX OPR 0, AX 5 Virtual Machine (interpreter) // sorce code int x; int foo () { read (x); print (5); } main () { foo (); } Lexer Parser Semantic Analyzer Code Generation 01001010101000010 01010100101010010 10100100000011011 11010010110101111 00010010101010010 10101001010101011 Assembler compilation execution
  • 8. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 8 A Simple Virtual Machine CPU ALU Register Memory
  • 9. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 9 Memory        program A Simple Virtual Machine CPU ALU Register Code sto 0, s sto 0, d sto 0, c sto 0, d lod s, 0 lit “s”, 0 opr 14, 0 jmc #a1, false lod b, 0 Symbol   Table
  • 10. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 10 A Simple Virtual Machine CPU ALU Register PC Memory        program Code sto 0, s sto 0, d sto 0, c sto 0, d lod s, 0 lit “s”, 0 opr 14, 0 jmc #a1, false lod b, 0 Symbol   Table
  • 11. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 11 Instructions instruction first second parameter parameter
  • 12. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 12 Instructions ‱  LIT <value>, <register_id> Put a constant value in a CPU register Examples: LIT 5, 0 LIT 5.5, 0 LIT 'a', 0 LIT ”hello”, 0 LIT true, 0
  • 13. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 13 Instructions ‱  LOD <variable>, <register_id> Search for <variable> in the symbol table Read its value Put the value of <variable> in the CPU register Examples: LOD a, 0 LOD hello, 0 LOD cse340, 0
  • 14. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 14 Instructions ‱  STO <variable>, <register_id> Read a value from the CPU register Search for <variable> in the symbol table Store the value into the variable Examples: STO a, 0 STO hello, 0 STO cse340, 0
  • 15. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 15 Example Source Code: { int a; int b; a = 10; b = a; Symbol Table: Type Name Scope Value int a global 0 int b global 0 Intermediate (Object) Code: LIT 10,0 STO a,0 LOD a,0 STO b,0
  • 16. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 16 Instructions ‱  OPR <operation>, <register_id> Read one or two values from the CPU register Do the operation <operation> Put the result into the CPU register Examples: OPR 1, 0 ; return OPR 2, 0 ; add OPR 3, 0 ; subtract
  • 17. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 17 Operations Number Action 0 Exit program 1 Return 2 ADD: POP A, POP B, PUSH B+A 3 SUBTRACT: POP A, POP B, PUSH B-A 4 MULTIPLY: POP A, POP B, PUSH B*A 5 DIVIDE: POP A, POP B, PUSH B/A 6 MOD: POP A, POP B, PUSH (B mod A) 7 POW: POP A, POP B, PUSH (A to the power B) 8 OR: POP A, POP B, PUSH (B or A) 9 AND: POP A, POP B, PUSH (B and A) 10 NOT: POP A, PUSH (not A) 11 TEST GREATER THAN: POP A, POP B, PUSH (B>A) 12 TEST LESS THAN: POP A, POP B, PUSH (B<A) 13 TEST GREATER THAN OR EQUAL: POP A, POP B, PUSH (B>=A)
  • 18. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 18 Operations Number Action 14 TEST LESS THAN OR EQUAL: POP A, POP B, PUSH (B<=A) 15 TEST EQUAL: POP A, POP B, PUSH (B=A) 16 TEST NOT EQUAL: POP A, POP B, PUSH (B<>A) 17 18 clear screen 19 read a value from the standard input 20 print a value to the standard output 21 print a value to the standard output and a newline character
  • 19. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 19 Example { int a; int b; a = 10; b = a; a = a * 10; b = 2 + 3 + 4; } Type Name Scope Value int a global 0 int b global 0 LIT 10, 0 STO a, 0 LOD a, 0 STO b, 0 LOD a, 0 LIT 10, 0 OPR 4, 0 ; multiply STO a, 0 LIT 2, 0 LIT 3, 0 OPR 2, 0 ; add LIT 4, 0 OPR 2, 0 ; add STO b, 0 OPR 1,0 OPR 0,0
  • 20. Javier Gonzalez-Sanchez | CSE340 | Summer 2015 | 20 to be continued...
  • 21. CSE340 - Principles of Programming Languages Javier Gonzalez-Sanchez javiergs@asu.edu Summer 2015 Disclaimer. These slides can only be used as study material for the class CSE340 at ASU. They cannot be distributed or used for another purpose.