Textbook Notes (270,000)
CA (160,000)
U of C (1,000)
CPSC (7)


Computer Science
Course Code
CPSC 355
Leonard Manzara

This preview shows page 1. to view the full 4 pages of the document.
Computing Machinery I
Assignment 5
Part A: Recursion, Global Variables and Separate Compilation
Arithmetic expressions can be translated into postfix form using recursion given the following rules:
Translation is done by creating an individual conversion function for each of the syntactic constructs
expression, term, and factor. As these syntactic constructs are defined recursively, their corresponding
procedures are also structured recursively. Given the expressions:
(a + b) * c - d . (Note: the period terminates output)
the program should translate this input to a postfix output:
The C version of the program is:
Translate the functions find(), expression(), term(), and factor() into assembly language, and put these into
a separate .m file. These functions will be called from the main() function given above, which will be in its
own .c file. Your functions will call the library routines scanf(), exit(), and printf(). Input will be
redirected from standard input; capture the program output using script. Your TA will give you input
expressions to translate.
Part B: External Pointer Arrays and Command-Line Arguments
Given the following declaration in C:
write a SPARC assembly language program to accept as command line arguments three integer strings
representing a date in the format mm dd yyyy. Your program will print the date with the name of month as
well as the correct suffix. For example:
Be careful about the 1st, the 2nd, and the 3rd, distinguishing the 1st from the 11th from the 21st and the
31st. Don't forget the comma after the day. Your program should exit, printing this error message, if three
arguments are not given: usa ge mm d d yyy y . You will need to call atoi() to convert strings to numbers, and printf() to
produce the output. Run your program three times with different input to illustrate that it works; capture
the output using script.
New Skills need for this Assignment:
Understanding and use of external variables in SPARC assembly
External arrays of pointers
Calling assembly functions from main()
Calling library functions from assembly routines
Command line arguments
Submit the following:
You're Reading a Preview

Unlock to view full version