Professor Simonson

How Computers Work

CSC 195

Quiz 2 - 15 points


Due Midnight, Wednesday,  April 12

Write a machine language program that accepts a number total_number and then accepts total_number numbers and prints out their average, minimum and maximum.     
It will be helpful to have memory locations for the following variables:  total_number, number, count, sum, currentmax, currentmin. 
You should use a loop with this plan:

Read total_number
Copy total_number to count
Read first number
Store it in sum, currentmax, currentmin
Subtract 1 from from count
Loop:
    Read next number
    Add it to sum
    Compare number to currentmax and if number is bigger then store it in currentmax
    Compare number to currentmin and if number is smaller then store it in currentmin
    Subtract one from count
    If count equals 0 then go FinishUp
    Branch back to Loop
FinishUp:
    Print out currentmax, currentmin, and sum/total_number.


Feel free to ask for help or hints.

Translate any three lines of your program from assembly into machine language (i.e. binary.)  Assume all address modes and commands are as we discussed in class.



 
 

back
 


shai@stonehill.edu