CS-220, Sections 50,51 Lab # 5, 3-2-06 Lab Report Due: 3-23-06 In this assignment you are to write an 80X86 assembly language program and a C language program for the IBM-PC, each of which will process some two-digit decimal integer grades entered by the user. Specifically each program should do the following: Prompt the user to enter two-digit decimal integers from the keyboard. Each integer represents a grade between 2 and 99. A grade of 01 will be a sentinel indicating that the last grade has been entered. After each grade is entered the program should determine whether it is an A, B, C, D, or F, and display the corresponding character (A, B, C, D, or F) next to the grade entered by the user. The criteria are as follows: 90 <= grade <= 99 ..... A 80 <= grade <= 89 ..... B 70 <= grade <= 79 ..... C 60 <= grade <= 69 ..... D 2 <= grade <= 59 ..... F After the 01 indicating end of input is entered, the program should compute and output the average of all the grades entered and how many A's, B's, C's, D's, and F's there were. The following is a screen shot of a sample program run. Your program output should look something like it. (Bold underlined characters are entered by the user.) Enter the two decimal digits of each grade (00 when done) 77 C 98 A 56 F 70 C t Invalid decimal digit, enter both digits again 86 B 94 A 8x Invalid decimal digit, enter both digits again 64 D 72 C 85 B 01 The Average is: 78 number of As: 02 number of Bs: 02 number of Cs: 03 number of Ds: 01 number of Fs: 01 The C language program should be quite straight-forward (although there may be some "issues" with error handling). The assembly language program will require careful consideration of some of the following: 1. Input from the keyboard and output to the video display under DOS are character oriented. The operating system has routines that are capable of doing that kind of I/O. Those routines are invoked with the INT 21h instruction. To "call" these operating system (OS) services from your assembly language programs you must load AH register with a service number which tells the OS which service you are requesting and then execute the INT 21h instruction. In most cases the OS must be provided data and/or will return data to the calling program. Those data values are transferred via the general purpose registers. For this lab the DOS routines you will need are: (A) Single character input from the keyboard: AH=1; after the INT 21h instruction, AL will contain the ASCII code of the first character entered by the user from the keyboard. (B) Single character output to the screen: AH=2; DL must contain the ASCII code of the character to be displayed prior to executing INT 21h. (C) String output to the screen: AH=9; DX must contain the offset of the string to be displayed (in a data segment) prior to executing INT 21h. The last character in that string must be a '$'. For example, the following string defined in the data segment could be displayed on the screen with the string output (AH=9) DOS service: prompt db 'Enter two decimal digit grades (00 when done)',0Dh,0Ah,'$' Note that 0Dh and 0Ah are the ASCII codes for a carriage return and a line feed. The code to display that string would then be something like: mov ah,9 ;Display String OS service lea dx,prompt ;Load offset part of address of prompt into DX int 21h ;Call the OS routine that displays the string You will also need to define other strings. 2. Your assembly language program will be making its calculations using integer arithmetic. Data input from the keyboard are character (ASCII) codes. So you must convert the ASCII codes for the two digits entered by the user to its decimal equivalent. In other words your program should have variables to hold the ASCII codes for each of the digits entered and also for the value of the decimal number those codes are encoding. Your data segment might have the following declarations: high_digit db ? ;Will hold the ASCII code for the first digit low_digit db ? ;Will hold the ASCII code for the second digit num_value db ? ;Will hold the value of the two-digit number Your program must have a procedure to convert the two ASCII codes to their equivalent numeric value. In addition, your program will be computing integer results such as the average and the number of A's, B's ... etc. These are to be output as decimal integers. But the operating system output routines can only output ASCII codes. So your program must have a procedure to convert a two-digit decimal integer to the ASCII codes for its two digits and store the resulting codes. Your data segment should contain declarations like some of the following to hold values to be output: countA db 0 countB db 0 ...... avg db ? Note, you will also need other variables to hold any temporary values computed by your program. 3. Your program should do error checking. If the user enters any characters from the keyboard that are not decimal digits, it should display an error message that prompts the user to enter both digits again. The best way of handling this is to use an error- checking procedure. You may assume that there will not be more than 99 grades entered by the user and that the sum of all the grades entered will never exceed 65535 (the largest unsigned integer that can be stored in a 16-bit register or memory location). You have two weeks (three including Spring Break) to do this assignment, but please get started on it as soon as you can. The assembly language program will be divided up into relatively short procedures, which you can design and implement individually. We'll be covering most of the topics you will need to do this assignment during the next week or two of class. You should submit well-organized, readable, error-free printed copies of the .LST files of each program as well as a diskette or CD-ROM that contains the source code files and the executable files. You should also turn in printed copies of screen captures of the output of your programs. In addition you should submit a hierarchy chart that clearly shows the calling relationship between your assembly language program's procedures, and, for each of its procedures, a flow chart showing the flow of logic of the procedure.