Answered step by step
Verified Expert Solution
Link Copied!

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 #5: Student Grades
Write an assembly program to read the grades of 10 students in 3 courses (Math, Science and English).
Each grade has to be from 0 to 100. Your program s_start:
; Math input
lea dx,[prompt1]
mov ah,09h
int 21h
lea si,[math_grades]
call input_grades
; Science input
lea dx,[prompt2]
mov ah,09h
int 21h
lea si,[science_grades]
call input_grades
; English input
lea dx,[prompt3]
mov ah,09h
int 21h
lea si,[english_grades]
call input_grades
; Display report header
lea dx,[report_header]
mov ah,09h
int 21h
lea dx,[newline]
mov ah,09h
int 21h
lea dx,[report_line]
mov ah,09h
int 21h
lea dx,[newline]
mov ah,09h
int 21h
; Display course headers
lea dx,[course_headers]
mov ah,09h
int 21h
lea dx,[newline]
mov ah,09h
int 21h
lea dx,[report_line]
mov ah,09h
int 21h
lea dx,[newline]
mov ah,09h
int 21h
; Process and display Math degrees
lea si,[math_grades]
lea di,[math_degrees +1]
call categorize_degrees
call display_degrees
; Process and display Science degrees
lea si,[science_grades]
lea di,[science_degrees +1]
call categorize_degrees
call display_degrees
; Process and display English degrees
lea si,[english_grades]
lea di,[english_degrees +1]
call categorize_degrees
call display_degrees
; Exit the program
mov ah,4Ch
int 21h
input_grades:
xor cx, cx ; Initialize counter
input_loop:
mov ah,01h ; Read character from standard input
int 21h
cmp al,13 ; Check if it's Enter
je input_done
mov [si], al ; Store the character in the buffer
inc si
inc cx
cmp cx,30 ; Check if 30 characters are entered
je input_done
jmp input_loop
input_done:
ret
categorize_degrees:
xor cx, cx ; Clear the counter
mov cl,30 ; Number of grades to process
categorize_loop:
mov al,[si] ; Load the next character from SI
cmp al,13 ; Check if it's a carriage return
je skip_line
cmp al,'' ; Check if it's a space
je skip_space
sub al,'0' ; Convert ASCII to integer
cmp al,85
jae grade_A
cmp al,75
jae grade_B
cmp al,65
jae grade_C
cmp al,50
jae grade_D
jmp grade_F
skip_space:
jmp next_grade
skip_line:
jmp next_grade
grade_A:
inc byte [di] ; Increment the count for Degree A
jmp next_grade
grade_B:
add di,1
inc byte [di] ; Increment the count for Degree B
jmp next_grade
grade_C:
add di,2
inc byte [di] ; Increment the count for Degree C
jmp next_grade
grade_D:
add di,3
inc byte [di] ; Increment the count for Degree D
jmp next_grade
grade_F:
add di,4
inc byte [di] ; Increment the count for Degree F
next_grade:
inc si
loop categorize_loop
ret
display_degrees:
; Display degrees header
lea dx,[degrees]
mov ah,09h
int 21h
lea dx,[newline]
mov ah,09h
int 21h
; Display degree counts for each course
lea si,[math_degrees +1]
lea di,[math_degrees +2]
call display_course_degrees
lea si,[science_degrees +1]
lea di,[science_degrees +2]
call display_course_degrees
lea si,[english_degrees +1]
lea di,[english_degrees +2]
call display_course_degrees
; Display success rates
lea dx,[success_rates]
mov ah,09h
int 21h
; Move to the next line
lea dx,[newline]
mov ah,09h
int 21h
ret
display_course_degrees:
; Display course name
lodsb
mov ah,09h
int 21h
; Display degree counts
mov cl,5 ; Number of degrees
display_loop:
lea dx,[space]
mov ah,09h
int 21h
lodsb
mov ah,09h
int 21h
lea dx,[space]
mov ah,09h
int 21h
loop display_loop
; Move to the next line
lea dx,[newline]
mov ah,09h
int 21h
ret
prompt1 db "Enter the degree of the ten students for Math separated by space: $"
prompt2 db "Enter the degree of the ten students for Science separated by space: $"
prompt3 db "Enter the degree of the ten students for English separated by space: $"
report_header db "The Degrees Report: $"
report_line db "----------------------------- $"
course_headers db "Math Science English $"
degrees db "A B C D F $"
newline db 13,10,"$"
space db " $"
math_grades db 30 ; Increased to accommodate two digits per grade
science_grades db 30
english_grades db 30
math_degrees db 5
science_degrees db 5
english_degrees db 5
success_rates db 4
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

5. Explain how to conduct an appraisal feedback interview.

Answered: 1 week ago

Question

2. Answer the question, Who should do the appraising?

Answered: 1 week ago