Answered step by step
Verified Expert Solution
Question
1 Approved Answer
make the count for the input correct like the picture Project # 5 : Student Grades Write an assembly program to read the grades of
make the count for the input correct like the picture
Project #: Student Grades
Write an assembly program to read the grades of students in courses Math Science and English
Each grade has to be from to Your program sstart:
; Math input
lea dxprompt
mov ahh
int h
lea simathgrades
call inputgrades
; Science input
lea dxprompt
mov ahh
int h
lea sisciencegrades
call inputgrades
; English input
lea dxprompt
mov ahh
int h
lea sienglishgrades
call inputgrades
; Display report header
lea dxreportheader
mov ahh
int h
lea dxnewline
mov ahh
int h
lea dxreportline
mov ahh
int h
lea dxnewline
mov ahh
int h
; Display course headers
lea dxcourseheaders
mov ahh
int h
lea dxnewline
mov ahh
int h
lea dxreportline
mov ahh
int h
lea dxnewline
mov ahh
int h
; Process and display Math degrees
lea simathgrades
lea dimathdegrees
call categorizedegrees
call displaydegrees
; Process and display Science degrees
lea sisciencegrades
lea disciencedegrees
call categorizedegrees
call displaydegrees
; Process and display English degrees
lea sienglishgrades
lea dienglishdegrees
call categorizedegrees
call displaydegrees
; Exit the program
mov ahCh
int h
inputgrades:
xor cx cx ; Initialize counter
inputloop:
mov ahh ; Read character from standard input
int h
cmp al ; Check if it's Enter
je inputdone
mov si al ; Store the character in the buffer
inc si
inc cx
cmp cx ; Check if characters are entered
je inputdone
jmp inputloop
inputdone:
ret
categorizedegrees:
xor cx cx ; Clear the counter
mov cl ; Number of grades to process
categorizeloop:
mov alsi ; Load the next character from SI
cmp al ; Check if it's a carriage return
je skipline
cmp al ; Check if it's a space
je skipspace
sub al ; Convert ASCII to integer
cmp al
jae gradeA
cmp al
jae gradeB
cmp al
jae gradeC
cmp al
jae gradeD
jmp gradeF
skipspace:
jmp nextgrade
skipline:
jmp nextgrade
gradeA:
inc byte di ; Increment the count for Degree A
jmp nextgrade
gradeB:
add di
inc byte di ; Increment the count for Degree B
jmp nextgrade
gradeC:
add di
inc byte di ; Increment the count for Degree C
jmp nextgrade
gradeD:
add di
inc byte di ; Increment the count for Degree D
jmp nextgrade
gradeF:
add di
inc byte di ; Increment the count for Degree F
nextgrade:
inc si
loop categorizeloop
ret
displaydegrees:
; Display degrees header
lea dxdegrees
mov ahh
int h
lea dxnewline
mov ahh
int h
; Display degree counts for each course
lea simathdegrees
lea dimathdegrees
call displaycoursedegrees
lea sisciencedegrees
lea disciencedegrees
call displaycoursedegrees
lea sienglishdegrees
lea dienglishdegrees
call displaycoursedegrees
; Display success rates
lea dxsuccessrates
mov ahh
int h
; Move to the next line
lea dxnewline
mov ahh
int h
ret
displaycoursedegrees:
; Display course name
lodsb
mov ahh
int h
; Display degree counts
mov cl ; Number of degrees
displayloop:
lea dxspace
mov ahh
int h
lodsb
mov ahh
int h
lea dxspace
mov ahh
int h
loop displayloop
; Move to the next line
lea dxnewline
mov ahh
int h
ret
prompt db "Enter the degree of the ten students for Math separated by space: $
prompt db "Enter the degree of the ten students for Science separated by space: $
prompt db "Enter the degree of the ten students for English separated by space: $
reportheader db "The Degrees Report: $
reportline db $
courseheaders db "Math Science English $
degrees db A B C D F $
newline db $
space db $
mathgrades db ; Increased to accommodate two digits per grade
sciencegrades db
englishgrades db
mathdegrees db
sciencedegrees db
englishdegrees db
successrates db
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started