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 int fun (int a, int b) { int x = a + b; return x + 8; } ADD ADD STR ADD STR ADD ADD LDR LDR ADD STR LDR AND ADD ADD STR ADD STR ADD STR ADD ADD ADD ADD SP, SP, R7, SP, FP, SP, FP, R0, R1, R0, R0, R0, R1, R1, R0, R0, SP, FP, SP, R7, SP, SP, SP, SP, SP, SP, SP, SP, SP, SP, SP, FP, FP, R1, FP, FP, R1, R1, R1, FP, SP, SP, SP, SP, SP, SP, SP, SP, -1 -1 0 -1 0 -1 0 4 5 R0 0 0 0 8 R0 3 1 0 1 0 1 1 1 1 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 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; 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 Homework #8 (due Monday 12/10) • Generate prologue in LC-3 • Compile each line of code to LC-3 • Generate epilogue in LC-3 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