ECE291 Computer Engineering II Lockwood, Spring 1999

Machine Problem 1: Score Chart

Due DateThursday, Feb 11, 1999
Purpose Looping, branching, and math operations.
Points50

Introduction

For this machine problem, you are to write a program which produces a frequency distribution table of ECE291 scores. The program converts a list of raw homework, MP, exam, and final scores into a table that shows the frequencies of the total scores. The output of your program will be similar to the score distribution charts on the ECE291 gradebook page; except that your output will use ASCII '*' symbols rather than red bars. Futher, your program will plot the number of scores in a 16-bit range, rather than the 10-point range on the web page.

A list of scores is given to you in the form of a database. For ECE291, our database is collection of records that each hold a student ID and individual raw scores. The ID is an alpha-numeric string stored as 5 ASCII characters and terminated with a '$' symbol. Each of the 16 individual raw scores is stored as a 1-byte unsigned integer. The total score is represented as a 2-byte unsigned integer. In total, each ECE291 record occupies 24 bytes.

Sample databases are included with this assignment. The real database with your IDs and scores is available on-line from the gradebook page.

Record Format

The record format of the ECE291 database is summarized below. In this table 'A' represents an ASCII character; '$' represents the ASCII character used to mark the end of a string; 'B' represents a 1-byte unsigned integer; and 'WW' represents a 2-byte unsigned integer. The offset refers to the starting location of each field in each 24-byte array.

 
Field ID Homework Machine Problems Exams Final Total
Data AAAAA$ BBBBBB BBBBBBB BB B WW
Offset 06789 101112131415 16171819202122

For this machine problem, you will use the INCLUDE directive to read a database of fictitious ECE291 scores into your program. This directive will insert the contents of the specified file into your .ASM program at the time you assemble with MASM. The gbk-test.dta and gbk-big.dta files each define a variable called gbk which holds an entire database of student records as well as a variable called numrec which stores the number of records in the database. The contents of gbk-test.dta is shown below:

; Format: id,'$',hw0,hw1,hw2,hw3,hw4,hw5,
;         mp0,mp1,mp2,mp3,mp4,mp5,mp6(project),
;         exam1,exam2,final

gbk db 'PRFCT','$',25,75,75,75,75,75, 25,50,50,50,50,50,125, 150,150,200, 0,0
    db 'DOPEY','$',10,40,40,40,40,40,  0,20,30,40,40,40, 70,  50, 60, 70, 0,0
    db 'HAPPY','$',25,20,75,25,75,25, 25,50,35,50,40,50,100, 115, 90,150, 0,0
    db 'LUCKY','$',20,70,70,70,70,70, 20,40,40,40,40,40, 90, 110,120,150, 0,0
    db 'ANGRY','$',20,40,40,40,40,30, 10,20,30,40,40,30, 70,  60, 50, 70, 0,0

numrec dw 5 

A similar table of current scores for this class can be dynamically generated and downloaded from the ECE291 on-line gradebot.

Procedures

This assignment has three procedures. You will receive credit for this assignment by replacing each of three procedures listed below with your own code.

Sample Output

   464 ..    479 **
   480 ..    495 
   496 ..    511 
   512 ..    527 
   528 ..    543 
   544 ..    559 
   560 ..    575 
   576 ..    591 
   592 ..    607 
   608 ..    623 
   624 ..    639 
   640 ..    655 
   656 ..    671 
   672 ..    687 
   688 ..    703 
   704 ..    719 
   720 ..    735 
   736 ..    751 
   752 ..    767 *
   768 ..    783 *
   784 ..    799 
   800 ..    815 
   816 ..    831 
   832 ..    847 
   848 ..    863 
   864 ..    879 
   880 ..    895 
   896 ..    911 
   912 ..    927 
   928 ..    943 
   944 ..    959 
   960 ..    975 
   976 ..    991 
   992 ..   1007 *

LIBMP1 Calls: 
CompTotal 
FillTable 
PlotChart 

   640 ..    655 *
   656 ..    671 *
   672 ..    687 
   688 ..    703 *
   704 ..    719 ***
   720 ..    735 *
   736 ..    751 ***
   752 ..    767 ***
   768 ..    783 *******
   784 ..    799 ********
   800 ..    815 ****
   816 ..    831 *********
   832 ..    847 *****
   848 ..    863 ************
   864 ..    879 ***********
   880 ..    895 ********
   896 ..    911 ***
   912 ..    927 *
   928 ..    943 *
   944 ..    959 ***

LIBMP1 Calls: 
CompTotal 
FillTable 
PlotChart 

Preliminary Procedure

Final Steps

  1. Download and print the MP1 grading sheet from the web site.
  2. Verify that your program meets all requirements for handin.
  3. Demonstrate MP1.EXE to a TA or to the instructor. You will then be asked to recompile and demonstrate MP1 with different database files. Your program must work with all given input. Once approved, you are ready to turn in your program.
  4. Be prepared to answer questions about any aspect of the operation of your program. The TAs will not accept an MP if you cannot fully explain the operation of your code.
  5. Print MP1.ASM
  6. Electrically submit your programs to the TA's handin floppy:
    A:\HANDIN MyWindowsLogin
  7. Take your printout and disk with MP1 to the same TA which approved your demonstration. Be sure that your name is on the disk and on the printout.

MP1.ASM (Program framework)

PAGE 75, 132 TITLE MP1 your name current date COMMENT * Score Chart ----------- ECE291: Machine Problem 1 Prof. John W. Lockwood University of Illinois, Dept. of Electrical & Computer Engineering Spring 1999 Revision 2.0 This program produces a distribution table of ECE291 total scores using a table of raw scores for homeworks, machine problems, exams, and the final. * ;====== SECTION 1: Define constants ========================================= CR EQU 0Dh LF EQU 0Ah ESCKEY EQU 1Bh ;====== SECTION 2: Declare external procedures ============================== extrn binasc:near ; From lib291.lib (Described in the lab manual) extrn dspout:near ; (You can use these functions freely) extrn dspmsg:near ; extrn mp1xit:near ; From libmp1.lib: Call to exit your program extrn LibCompTotal:near ; From libmp1.lib extrn LibFillTable:near ; (You need to write these yourself) extrn LibPlotChart:near ; Public gbk, numrec, crlf, pbuf, ScoreDist, MinBin, MaxBin ;====== SECTION 3: Define stack segment ===================================== stkseg segment stack ; STACK SEGMENT db 64 dup ('STACK ') stkseg ends ;====== SECTION 4: Define code segment ====================================== cseg segment public 'CODE' ; CODE and DATA SEGMENT assume cs:cseg, ds:cseg, ss:stkseg, es:nothing ;====== SECTION 5: Declare variables for main procedure ===================== ; Format of the gradebook database: ; [Note that each record is 24 bytes long] ; ; ID: 5 ASCII letters or numbers ; hw0..final: 1-byte unsigned integers (array of 16 elements) ; tot: 2-byte unsigned integer (calculated as per instructions) ; flag: 1 byte (not used for this assignment) ; ; ID,'$',hw0,hw1,hw2,hw3,hw4,hw5, ; mp0,mp1,mp2,mp4,mp5,mp6,exam1,exam2,final,total INCLUDE gbk-test.dta ; Read from External File ; This directive inserts the contents of the file gbk.dta here. ; In this file, two variables are defined: gbk and numrec ; ; gbk is an array of 24-byte records holding raw scores ; numrec is defined as a 16-bit integer which stores the number of records crlf db CR,LF,'$' ; Carriage Return / Line Feed String pbuf db 7 dup(?) ; Buffer for use with BINASC / DSPMSG library routines ScoreDist db 65 dup(0) ; Table of 64 byte-size integers ; ScoreDist[0]=Number of scores between 0 .. 15 ; ScoreDist[1]=Number of scores between 16 .. 31 ; ... ; ScoreDist[64]=Number of scores between 1024 .. 1030 MinBin dw 64 ; Lowest Score Range (The first bin that is non-zero) ; Computed by CompTable, used by PlotChart MaxBin dw 0 ; Highest Score Range (The last bin that is non-zero) ; Computed by CompTable, used by PlotChart ;====== SECTION 6a: Your procedure ========================================== CompTotal Proc near ; Purpose: Computes the total score (total) for each student in the ; gradebook as the sum of HW, MP, exam, and the final scores. ; Inputs: numrec : Number of records in database ; gbk : Reads hw, mp, exam, and final fields of records ; Output: gbk : Writes to total field of gbk records Call LibCompTotal ;Comment this line and replace with your own code ret CompTotal ENDP FillTable Proc NEAR ; Purpose: Computes the score distribution array, (ScoreDist), ; as the frequency of students that achieve a range of scores. ; This routine should also compute the lowest and highest score ranges. ; Input: gbk : Reads Total fields from each gbk record ; Outputs: ScoreDist : Array that counts students achiving score range ; MinBin : Index of the first non-empty ScoreDist element ; MaxBin : Index of the last non-empty ScoreDist element Call LibFillTable ;Comment this line and replace with your own code ret FillTable ENDP PlotChart Proc NEAR ; Purpose: Plot Distibution Table from MinBin .. MaxBin ; Inputs: ScoreDist array, MinBin, MaxBin ; Outputs: None - Writes output to screen Call LibPlotChart ;Comment this line and replace with your own code ret PlotChart ENDP ;====== SECTION 6b: Main procedure ========================================== main proc far mov ax, cseg ; Initialize DS register to equal CS mov ds, ax call CompTotal ; Compute totals in each record call FillTable ; Populate ScoreDist with # of similar scores call PlotChart ; Print chart of score frequencies call mp1xit main endp cseg ends end main