Assignment 3

CS/ECE 354, Spring 2013


Send e-mail questions to Jim Paton, paton@cs.wisc.edu
Please include [CS354] at the beginning of the subject line in any emails.
Due Wednesday, March 13, before 5pm.


Collaboration Policy

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 and sections of BOTH students must appear at the top of the turned in assignment.


Program Statement

This MAL program is an extension and variation on Assignment 2, to incorporate more aspects of the C program implemented in Assignment 1. (The next assignment will re-implement much of the C program, in MIPS assembly language, using a fixed set of conventions for function implementation.) This program uses an array to hold multiple integers entered by the user.

In addition to reading in each hexadecimal value, the program will place the two's complement representation of that value into an array.

After the program has the valid integers in the array, it prints the values out (in decimal).

Just like in assignment 2, the user enters the newline character to identify the end of a hexadecimal value. For this assignment, if the user enters a newline as the first character of a hexadecimal value, that signals that no more hexadecimal values are to be entered. This provides a way for the user to enter fewer than 6 values.

Here are examples of program execution. User input is given in boldface to distinguish it from program output. Note that the user must enter the newline character after each integer input in this program.

Acceptable program input

Enter up to 6 hexadecimal values (newline to quit):
Enter value: 0013
Enter value: -cab
Enter value: 
Values entered in decimal:
19
-3243

Again, acceptable program input, showing that after the user enters the 6th value, the program stops prompting for values, and continues on.

Enter up to 6 hexadecimal values (newline to quit):
Enter value: -b
Enter value: a0
Enter value: -00000
Enter value: 780000
Enter value: 25000a
Enter value: -a6
Values entered in decimal:
-11
160
0
7864320
2424842
-166

The following examples illustrate what the program does with bad input.

Bad character or digit character for any of the values

Enter up to 6 hexadecimal values (newline to quit):
Enter value: -b09
Enter value: 123h
Bad hex value encountered. Quitting.

Again, bad character or digit character

Enter up to 6 hexadecimal values (newline to quit):
Enter value: 99ab-
Bad hex value encountered. Quitting.

Again, bad character within an integer (assume that there is a space or tab character after the 'e')

Enter up to 6 hexadecimal values (newline to quit):
Enter value: ace 
Bad hex value encountered. Quitting.

Requirements

  1. Your program must follow style guidelines as given in Style Guidelines.

    Also include a comment at the top of the source code with your name and section (and your partner's name and section, if working in a pair).

    See Guidelines for Programs to see an indication of point allocation used in program grading.

  2. Name your source code program arrayhex.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.
  3. Declare and use an array of 6 integers for holding the integer values for the hexadecimal values entered.
  4. Organize your program such that there is only one exit point (the done instruction) in the program.
  5. Your program is to operate and appear the same as the examples given above. Use the same prompts and strings. Do not produce output other than what is shown in the examples. Also, the program runs once, and then exits. To restart the program, the user must either click run on the simulator or restart the simulator entirely.
  6. Do not implement procedures/functions/methods.
  7. Just like assignment 2, the only I/O instructions permitted are getc, putc, and puts.
  8. Note that points will be deducted for repeated code blocks that implement what could easily be done with a loop.

Notes

Handing In the Program

You will turn in your assembly language source code file by uploading your file to the assignment 3 Moodle site.

Make sure that your source code is in a single file named arrayhex.s. You may upload early versions of your code, but the last one you upload is the only one we will see or score. You do not need to mark your assignment as submitted; we will score either the draft or the submitted file. Once you mark your file as submitted, you may not change it or upload another version.