Computer Sciences Dept.

CS/ECE 354 Machine Organization and Programming

Fall 2008 Section 1
Instructor Mark D. Hill
TAs Mark Liu & Somayeh Sardashti

Homework 2 // Due Friday, October 10, before 5pm

Send e-mail questions to Mark Liu, mliu@cs.wisc.edu

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


Program

Program Statement

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 digit that represents an integer. The program checks that the input character represents an integer that is greater than 1 and less than 10. The program calculates and prints out whether or not this integer is coprime with respect to each of the integers 2-9.

Note that no array is used.

Here are examples of program execution. User input is given in boldface to distinguish it from program output.

Enter a 1-digit integer: 8
8 and 2 coprime? N 
8 and 3 coprime? Y 
8 and 4 coprime? N 
8 and 5 coprime? Y 
8 and 6 coprime? N 
8 and 7 coprime? Y 
8 and 8 coprime? N 
8 and 9 coprime? Y

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

Integer is too small

Enter a 1-digit integer: 0
Bad user input.  Quitting.
Again, integer is too small
Enter a 1-digit integer: 1
Bad user input.  Quitting.
User input contains something other than a digit character
Enter a 1-digit integer: X
Bad user input.  Quitting.
Again, user input contains something other than a digit character
Enter a 1-digit integer: a
Bad user input.  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 your partner's name, 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 coprime.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.
  3. After the program reads exactly one character, it processes the character. The program does not continue to read more characters waiting for the newline to be encountered.
  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. Do not add looping to repeat the program's functionality.
  6. Do not implement procedures/functions/methods. Do not use an array.

Notes

  1. We use a simulator to run and test our assembly language programs. This simulator currently runs on the Centos 4 Linux machines used for this class (the emperor and royal machines). You will need to be sitting at or remotely logged in to one of these machines in order to use the simulator. See the simulator guide for brief instructions on how to invoke the simulator.

    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.

Handing In the Program

Your MAL source code must be in a file named coprime.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 coprime.s file. This program copies the specifically named file to a directory accessible by the instructor and TAs. (P.S. If you add the path /s/handin/bin within your .cshrc.local file, re-login, then you can omit /s/handin/bin/ from the command.)

 
Computer Sciences | UW Home