Upgrade to Pro — share decks privately, control downloads, hide ads and more …

UP Lecture 27

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

UP Lecture 27

Compilers
Intermediate Code IV
(202605)

Transcript

  1. Dr. Javier Gonzalez-Sanchez | Compilers | 2 jgs jgs GitHub

    Classroom Final Project: https://classroom.github.com/a/pTxhXv6V
  2. Dr. Javier Gonzalez-Sanchez | Compilers | 4 jgs jgs Programming

    Assignment 4 Level 1 LIT, LOD, STO, OPR
  3. Dr. Javier Gonzalez-Sanchez | Compilers | 6 jgs jgs Review

    Programming Assignment 4 Level 2 JMP, JMC
  4. Dr. Javier Gonzalez-Sanchez | Compilers | 7 jgs jgs Example

    | if { int a; int b; a = 10; if (a>1) { print (a); } else { print (b); } return; } int a global 0 int b global 0 int #e1 global 10 int #e2 global 12 LIT 10, 0 STO a, 0 LOD a, 0 LIT 1, 0 OPR 11, 0 ; > JMC #e1, false LOD a, 0 OPR 20, 0 ;print JMP #e2, 0 LOD b, 0 OPR 20, 0 ;print OPR 1, 0 OPR 0, 0
  5. Dr. Javier Gonzalez-Sanchez | Compilers | 8 jgs jgs Example

    | while { int a; int b; a = 10; while (a>1){ print (a); } return; } int a global 0 int b global 0 int #e1 global 10 int #e2 global 3 LIT 10, 0 STO a, 0 LOD a, 0 LIT 1, 0 OPR 11, 0 ; > JMC #e1, false LOD a, 0 OPR 20, 0 ;print JMP #e2, 0 OPR 1, 0 OPR 0, 0
  6. Dr. Javier Gonzalez-Sanchez | Compilers | 9 jgs jgs Exercise

    { int a; int b; a = 10; while (a>1) { if (a != 0) { print (a); } else { print (b); } a = a -1; } }
  7. Dr. Javier Gonzalez-Sanchez | Compilers | 15 jgs jgs Review

    Programming Assignment 4 Level 3 Homework: SWITCH
  8. Dr. Javier Gonzalez-Sanchez | Compilers | 16 jgs jgs What

    about this? Translate this source code to intermediate code: int a; switch (a) { case 1: { print("hi”); break;} case 2: { print("world"); break;} default: { print(”end"); break;} }
  9. jgs jgs Compilers Javier Gonzalez-Sanchez, Ph.D. [email protected] Spring 2025 Copyright.

    These slides can only be used as study material for the Compilers course at Universidad Panamericana. They cannot be distributed or used for another purpose.