Presentation is loading. Please wait.

Presentation is loading. Please wait.

C-to-LC3 Compiler Over the course of the next two weeks, you will build a program that will compile C code to LC-3 assembly language Don't panic! You.

Similar presentations


Presentation on theme: "C-to-LC3 Compiler Over the course of the next two weeks, you will build a program that will compile C code to LC-3 assembly language Don't panic! You."— Presentation transcript:

1 C-to-LC3 Compiler Over the course of the next two weeks, you will build a program that will compile C code to LC-3 assembly language Don't panic! You can do this! The compiler will only allow for a (very small) subset of the C programming language You will be given a lot of skeleton code to help you get started

2 ADD SP, SP, -1 STR R7, SP, 0 STR FP, SP, 0 ADD FP, SP, 0 LDR R0, FP, 4 LDR R1, FP, 5 ADD R0, R1, R0 STR R0, FP, 0 LDR R0, FP, 0 AND R1, R1, 0 ADD R1, R1, 8 STR R0, FP, 3 ADD SP, SP, 1 int fun (int a, int b) { int x = a + b; return x + 8; }

3 Lab #5 (last week) Input: a string containing up to 10 white-space separated tokens (substrings) Output: a 10-element string array, each holding one of the substrings This is known as “tokenizing” a string

4 Lab #6 (today) Use the solution to Lab #5 (we'll give you one if you didn't do the lab) to find variables that are being declared in a C program Part 1: find parameters int fun2 (int dog, int cat) { Part 2: find variable declarations int a = x + 5; int c = a + x, d, e = b;

5 Homework #7 (due next Monday)
Implement a data structure called a Linked List to represent the symbol table We will see Linked Lists in class tomorrow Modify solution to today's lab to populate the symbol table with variable names and offsets Look for basic compiler errors: variable declared multiple times undeclared variables

6 Homework #8 (due Monday 12/10)
Generate prologue in LC-3 Compile each line of code to LC-3 Generate epilogue in LC-3

7 Today Go to course website, then Schedule, then follow the link for today's Lab Assignment Download solution to Lab #5 if you need it Download skeleton code and test code and make sure it all compiles Start coding! You may work with other people This is Part 1 of Homework #7


Download ppt "C-to-LC3 Compiler Over the course of the next two weeks, you will build a program that will compile C code to LC-3 assembly language Don't panic! You."

Similar presentations


Ads by Google