CSE306 Processing Systems and Structures Lockwood, Spring 2003

Machine Problem 1: Score Chart

Due DateThursday, Feb 13, 2002
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 CSE306 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 CSE306 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 CSE306, 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 CSE306 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 CSE306 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 CSE306 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 CSE306 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. Verify that your program meets all requirements for handin.
  2. Demonstrate MP1.EXE to a TA or to the instructor.
  3. Electrically upload your source code to the Gradebot Server.

MP1.ASM (Program framework)

PAGE 75, 132 TITLE MP1 your_name current_date COMMENT * Score Chart ----------- CSE306: Machine Problem 1 Prof. John W. Lockwood Washington University, Dept. of Computer Science and Engineering Spring 2003 Revision 3.0 This program produces a distribution table of CSE306 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 ============================== ; You are GIVEN the following routines in LIB306.LIB ; (You may find these subroutines useful for your program!) extrn binasc:near ; From lib306 ; Converts a 16 bit binary integer into a string of decimal ; characters (ASCII-coded digits), writing them as a byte string ; into memory. ; Call with: ; AX = The 16-bit, signed integer to be converted. ; BX = Starting offset address for a 7-byte buffer to ; hold result ; (Typically the address of a variable like 'pbuf') ; Exits with: ; BX = The offset address of the first non-blank character of ; the string (this may be a minus sign, if the input ; number was negative). The string will be ; right-justified within the 7-byte buffer ; (padded with blanks to the left), and will ; have a "$" delimiter character after the last digit. ; CL = Number of non-blank characters generated in the string ; (including the sign if the number is negative). ; Example: CL = 2 for the number 78. ; Example: CL = 3 for the number -78, extrn dspout:near ; From lib306 ; Prints on the display screen the ASCII-coded character in DL. ; Call with: ; DL = ASCII code of character to be typed on the display. extrn dspmsg:near ; From lib306 ; Prints a string of ASCII-coded characters on the display ; screen. ; The string must be terminated by an ASCII dollar sign ("$"). ; The starting offset of the string is to be given as an ; input in DX. ; Call with: ; DX = Offset address of first byte of the ASCII string ; to be typed extrn mp1xit:near ; From lib306 ; Exit your program ; You are GIVEN the following library routines from LIBMP1.LIB. ; (You can use them for testing the other routines, but cannot receive ; credit for using them in your program!) extrn LibCompTotal : near ; From libmp1.lib extrn LibFillTable : near ; (You need to write these yourself) extrn LibPlotChart : near ; Make the following variables GLOBAL so that they can be used by library 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 ; INCLUDE gbk-big.dta ; Reads in larger test file (replaces above) ; 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
Copyright 1996-2003 John Lockwood