| ECE291 | Computer Engineering II | Lockwood, Fall 1996 |
| Assigned | Tuesday 9/17/96 |
| Due Date | Friday 9/27/96 |
| Purpose | Learn to write assembler code. Use looping and branching. Perform simple math operations. |
| Points | 50 |
The computation of ECE291 scores are based on a 1000-point system. A student's total score is computed as the sum of the raw points earned on the machine problems, exams, and final plus one-fourth (1/4) of the sum of the raw points earned on the homework.
The breakdown of points for each assignment is shown in the table below. MP6 refers to the final group project at the end of the semester.
| Homework | Machine Problem |
Exam | Final | |
|---|---|---|---|---|
| 0 | 24 | 25 | ||
| 1 | 75 | 50 | 150 | 200 |
| 2 | 75 | 50 | 150 | |
| 3 | 75 | 50 | ||
| 4 | 75 | 50 | ||
| 5 | 76 | 75 | ||
| 6 | 100 | |||
| Subtotal | 400 | 400 | 300 | 200 |
| HW/4 | 100 | 400 | 300 | 200 |
| Total | ||||
The list of raw scores will be 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.
| Field | ID | Homework | Machine Problems | Exams | Final | Total | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Data | AAAAA$ | B | B | B | B | B | B | B | B | B | B | B | B | B | B | B | B | WW |
| Offset | 0 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
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 file called gbk.dta into your .ASM program at the time you run MASM. The gbk.dta file defines a variable called gbk which holds the entire database as well as a variable called numrec which stores the number of records in the database. The contents of gbk.dta is shown below:
gbk db 'PERFT','$',24,75,75,75,75,76, 25,50,50,50,50,75,100, 150,150, 200,0,0
db '12345','$',24,75,70,65,70,65, 25,50,40,45,40,75, 80, 125,125, 133,0,0
db 'MEETO','$',20,60,75,70,65,76, 25,45,45,50,45,70, 90, 110,140, 140,0,0
db 'YOUTO','$', 0,75,65,75,75,72, 0,50,45,50,45,75, 95, 130,135, 150,0,0
db 'HLPME','$', 2, 4, 4, 8, 6, 8, 5,10,10,15,10, 5, 10, 50, 50, 75,0,0
numrec dw 5 ; Number of records (5 in this case)
|
Notice that the record with id=MEETO begins at a byte offset of 24x2=48 in the array. The homework zero score for this record is located at offset 24x2+6=54. The total score (which you will need to compute) for this record is defined at offset 24x2+22=70.
-ID-- hw0 hw1 hw2 hw3 hw4 hw5 mp0 mp1 mp2 mp3 mp4 mp5 mp6 Ex1 Ex2 Fin Total PERFT 24 75 75 75 75 76 25 50 50 50 50 75 100 150 150 200 1000 YOUTO 0 75 65 75 75 72 0 50 45 50 45 75 95 130 135 150 865 MEETO 20 60 75 70 65 76 25 45 45 50 45 70 90 110 140 140 851 12345 24 75 70 65 70 65 25 50 40 45 40 75 80 125 125 133 830 HLPME 2 4 4 8 6 8 5 10 10 15 10 5 10 50 50 75 248 DOSXIT: Exit to DOS |
PAGE 75, 132
TITLE MP1 your name current date
COMMENT *
This program computes class standings (grades) based on
the raw scores for homeworks, machine problems, exams,
and the final.
*
;====== SECTION 1: Define constants =======================================
CR EQU 0Dh
LF EQU 0Ah
;====== SECTION 2: Declare external procedures ============================
extrn binasc:near, dspmsg:near, dosxit:near ; From lib291.lib
extrn printrec:near ; From libmp1.lib
;====== 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 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)
;
; ID,'$',hw0,hw1,hw2,hw3,hw4,hw5,mp0,mp1,mp2,mp4,mp5,mp6,e1,e1,final,tot
INCLUDE gbk.dta
; 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
; This header should be the first line printed
hdr db '-ID-- '
db 'hw0 hw1 hw2 hw3 hw4 hw5 '
db 'mp0 mp1 mp2 mp3 mp4 mp5 mp6 '
db 'Ex1 Ex2 Fin Total',CR,LF,'$'
;====== SECTION 6: Main procedure =========================================
main proc far
mov ax, cseg ; Initialize DS register
mov ds, ax
; Your code
call dosxit
main endp
cseg ends
end main