For this assignment, you may work in pairs (2 people). All students (whether working in a pair or not) must individually turn in the assignment by individually running the handin program. Therefore, 2 copies of the assignment will be turned in for those working as a pair. The grader will choose to grade only one copy of a pair's work, and assign the same score to both students.
If working in a pair, the names of BOTH students must appear at the top of the turned in assignment.
Write a MAL program that does a very small part of what the C program in assignment 1 did. The MAL program requests and reads in exactly one character, which represents the integer value (from assignment 1). The program calculates this integer value cubed, and then prints the calculated value.
Note that no array is used.
Legal values for the single character read by the program
are the digit characters '0' to '9'.
Zero cubed is defined to be the integer value 1.
Here are examples of program execution. User input is given in boldface to distinguish it from program output.
Acceptable program input
Enter a value 0-9: 2 2^3 = 8
Again, acceptable program input
Enter a value 0-9: 8 8^3 = 512
Again, acceptable program input
Enter a value 0-9: 0 0^3 = 1
The following examples illustrate what the program does with bad input.
Character is not a digit
Enter a value 0-9: X Bad user input. Quitting.
Again, character is not a digit
Enter a value 0-9: - Bad user input. Quitting.
Again, character is not a digit
Enter a value 0-9: k Bad user input. Quitting.
Also include a comment at the top of the source code with your name (and your partner's name, if working in a pair).
See Guidelines for Programs to see an indication of point allocation used in program grading.
cube.s,
and place the entire program into this file.
This file is what will be turned in.
It must have exactly this name to make the lab-supported handin program work.
A suffix of .s is the convention
used in Unix operating systems to
indicate an assembly language source code file.
getc,
putc, and
puts.
done instruction) in the program.
It will take some time for you to get used to the simulator. Allocate extra time for this, and start well before the assignment is due. The user interface will allow you to set breakpoints and single step through your code. It will also show you the contents of registers for your program.
Note that the ability to use this simulator across the network (not sitting in front of an instructional Unix machine) is not guaranteed. An X-server must be available.
Your MAL source code must be in a file named
cube.s.
Turn in your program by running the lab-supported handin program.
/s/handin/bin/handin -c cs354-1 -a a2 -d .
while your current working directory is
the one containing the cube.s file.
This program copies the specifically named file to
a directory accessible by the instructor and TAs.