CSC 220 Program #2

"Life is an array, old chum"

Program #2 is:

  • due Tuesday November 1, 2005

  • worth 10 points, or 10% of your grade

Description

Write an assembly program that queries the user for an array of integers and manipulates them. Then, allow the user to select menu items to 1) report the minimum and maximum values in the array, 2) sort the numbers, or 3) quit the session.

Here's an example session (user input in bold):

How many numbers will you be entering? 5
Go.
Enter #1/5> 7
Enter #2/5> 17
Enter #3/5> 20
Enter #4/5> 3
Enter #5/5> 1
Done.
Entered: 7, 17, 20, 3, 1
Enter a choice [1=MinMax, 2=Sort, 3=Quit] > 1
Min is 1. Max is 20.
Enter a choice [1=MinMax, 2=Sort, 3=Quit] > 2
Sorted order is: 1, 3, 7, 17, 20
Enter a choice [1=MinMax, 2=Sort, 3=Quit] > 3
Done.

You should limit the size of the array at, say, 20 numbers. If the user requests more numbers than that (or less than 1), then print an error and exit. That's secret nerd code for saying that your arrays should not be dynamically allocated... unless you want to, I guess. Also, speaking of what you want... if you want to do more interesting functions than min/max with your arrays, feel free but let me know your plans beforehand.

Also, you must implement this program in two slightly different ways:

  1. Store the array of integers as an un-initialized global variable
  2. Store the array of integers as a local variable (presumably, local to main())

Peak at the array examples that I have provided (it's some other link on the "Programs" web page) for help on creating arrays that are either local or global variables. These two choices should be separate executables.

     

Implementation

You can use any sorting algorithm you'd like. Bubble sort, insertion sort, and quicksort are all given in the CSC 160 textbook or you can google them.

Please implement the following functions:

  • int min( int *array, int num)
  • int max( int *array, int num)
  • void sort( int *array, int num)

You can implement other functions as well, if you want to make your program easier to understand and follow.

Again, for your sanity, write program #2 one section at a time. Get one function working, then move onto the next. For example:

  1. Read in numbers (scanf)
  2. Write numbers (printf)
  3. Report min/max
  4. Sort
  5. Add interactive menu on top of it all
  6. Do "the other" way of storing array (you should still be able to use all you old functions)

You can implement your program in one large file or separate files.

 

Logistics

Hey, all this stuff is the same as Program #1.

Please place your completed code in the k: drive. This should include:

  • *.s assembly language files
  • *.exe executable file(s)
  • README.txt describing the status of your program... specifically identifying any problems that you were unable to overcome.

You must comment your code. Uncommented programs will face fierce and heavy penalties. Tell me what each block of assembly code is meant to accomplish. Also, please use meaningful names for labels, so that your code is easier to follow. Of course, programs that don't even compile will face a very difficult judgment as well.