CS426 Compiler Assignment: Creating Lexical Scanner & Java VM Code, Assignments of Computer Science

A university-level computer science assignment for a compiler construction course in the fall of 2006. The assignment consists of two parts. In the first part, students are required to create a lexical scanner using a generator such as jlex or jflex for a subset of the c programming language. The second part involves writing and executing java virtual machine (jvm) code in the assembly language accepted by jasmin to compute the nth fibonacci number. Students are expected to learn about the java virtual machine and its class file format, as well as detailed opcode descriptions.

Typology: Assignments

Pre 2010

Uploaded on 03/16/2009

koofers-user-gp3
koofers-user-gp3 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS426 Compiler Construction
Fall 2006
Machine Problem 1
Due Thursday September 14 at 12pm (midnight)
This assignment has two parts. One involves the creation of a lexical scanner and the second learning
how to assemble code for the Java Virtual Machine.
1. For the first part of the assignment you should download a lexical scanner generator such as JLex
(http://www.cs.princeton.edu/~appel/modern/java/JLex/) or JFlex (http://jflex.de/) (both of them
generate java programs) or any other scanner generator of your choice (e.g. Flex
[http://www.cs.princeton.edu/~appel/modern/c/software/flex/] or Lex which generate C pro-
grams). Then, you should generate a scanner for a subset of C which includes
for, while, if and assignment statements
Integer and floating point variables and values
•arrays
functions and function calls.
Write a driver that prints the pair <token type, lexeme> for each token in the input file.
2. The second part you should download the jasmin assembler (http://jasmin.sourceforge.net/) and
write and succesfully execute a JVM program in the assembly language accepted by jasmin that reads
an integer, n, and computes the nth fibonacci number
(http://en.wikipedia.org/wiki/Fibonacci_sequence). For this part of the assignment you will need to
learn about the Java Virtual Machine. You can find information in the following web sites:
http://en.wikipedia.org/wiki/Java_bytecode
.class file format:
http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html
More detailed opcode descriptions
http://java.sun.com/docs/books/vmspec/2nd-edition/html/Instructions2.doc.html
JVM overview
http://java.sun.com/docs/books/vmspec/2nd-edition/html/Overview.doc.html
To hand in the MP, please send me a tar file containing
the input to the scanner generator
the program produced by the scanner generator
3. The Jasmin assembly language that computes the nth fibonacci number.

Partial preview of the text

Download CS426 Compiler Assignment: Creating Lexical Scanner & Java VM Code and more Assignments Computer Science in PDF only on Docsity!

CS426 Compiler Construction

Fall 2006

Machine Problem 1

Due Thursday September 14 at 12pm (midnight)

This assignment has two parts. One involves the creation of a lexical scanner and the second learning how to assemble code for the Java Virtual Machine.

  1. For the first part of the assignment you should download a lexical scanner generator such as JLex ( http://www.cs.princeton.edu/~appel/modern/java/JLex/ ) or JFlex ( http://jflex.de/ ) (both of them generate java programs) or any other scanner generator of your choice (e.g. Flex [ http://www.cs.princeton.edu/~appel/modern/c/software/flex/ ] or Lex which generate C pro- grams). Then, you should generate a scanner for a subset of C which includes - for, while, if and assignment statements - Integer and floating point variables and values - arrays - functions and function calls. Write a driver that prints the pair <token type, lexeme> for each token in the input file.
  2. The second part you should download the jasmin assembler ( http://jasmin.sourceforge.net/ ) and write and succesfully execute a JVM program in the assembly language accepted by jasmin that reads an integer, n , and computes the n th fibonacci number ( http://en.wikipedia.org/wiki/Fibonacci_sequence ). For this part of the assignment you will need to learn about the Java Virtual Machine. You can find information in the following web sites: - http://en.wikipedia.org/wiki/Java_bytecode - .class file format: http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html - More detailed opcode descriptions http://java.sun.com/docs/books/vmspec/2nd-edition/html/Instructions2.doc.html - JVM overview http://java.sun.com/docs/books/vmspec/2nd-edition/html/Overview.doc.html

To hand in the MP, please send me a tar file containing

  • the input to the scanner generator
  • the program produced by the scanner generator
  1. The Jasmin assembly language that computes the nth fibonacci number.