Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using the solution program from the preceding exercise as a starting point, add

ID: 3625512 • Letter: U

Question

Using the solution program from the preceding exercise as a starting point, add the following features:
• Run in a loop so that multiple test scores can be entered.
• Accumulate a counter of the number of test scores.
• Perform range checking on the user’s input: Display an error message if the test score is less than 0 or greater than 100.

Many Thanks I will tip Karma!

preceding exercise:

INCLUDE Irvine32.inc

.data
str1 BYTE "Enter an integer score: ",0
str2 BYTE "The letter grade is: ",0

.code
main PROC
call Clrscr
mov edx,OFFSET str1 ; input score from user
call WriteString
call ReadInt
call Crlf

.IF eax >= 90 ; multiway selection structure to
mov al,'A' ; choose the correct grade letter
.ELSEIF eax >= 80
mov al,'B'
.ELSEIF eax >= 70
mov al,'C'
.ELSEIF eax >= 60
mov al,'D'
.ELSE
mov al,'F'
.ENDIF

mov edx,OFFSET str2
call WriteString
call WriteChar ; display grade letter in AL
call Crlf

exit
main ENDP
END main

Explanation / Answer

Dear, Complete code include comments too for better understanding .data
    Input:.ascii"Enter test Score:"
    Output: ascii"Grade is:"
#Number of Employees are stored in $t1
main:
     mov $t0,$1
     cmp $t0,$t1
     JLE Loop
     la $a0,Input
     syscall
Loop     # read integer into $s0
     li $v0, 5 # system call code for read integer = 5  
     syscall    # call operating system
     move $t0, $v0  # value read from keyboard returned
     cmp ax, 90  ; comparing ax to 90
     JGE GradeA ;    ja = jump if above. This is an unsigned
      cmp ax, 79  ; comparing
       JGE next ;    ja = jump if above. This is an unsigned
       next1: cmp ax, 90
               JL GradeB
     cmp ax, 69  ; comparing
       JGE next ;    ja = jump if above. This is an unsigned
       next1: cmp ax, 80
               JL GradeC
       cmp ax, 59  ; comparing
       JGE next ;    ja = jump if above. This is an unsigned
       next1: cmp ax, 70
               JL GradeD
      cmp ax, 60  ; comparing
        JL GradeF
    
# exit program
  li $v0, 10   # system call code for exit = 10
  syscall    # call operating system
           
GradeA:
       la $a0,output
       syscall
       mov dl, 'A' ; dl = ‘a‘
       mov ah, 2h ; character output subprogram
       int 21h ; call ms-dos output character
GradeB:
       la $a0,output
       syscall
       mov dl, 'B' ; dl = ‘a‘
       mov ah, 2h ; character output subprogram
       int 21h ; call ms-dos output character
GradeC:
       la $a0,output
       syscall
       mov dl, 'C' ; dl = ‘a‘
       mov ah, 2h ; character output subprogram
       int 21h ; call ms-dos output character
GradeD:
       la $a0,output
       syscall
       mov dl, 'A' ; dl = ‘a‘
       mov ah, 2h ; character output subprogram
       int 21h ; call ms-dos output character
GradeF:
       la $a0,output
       syscall
       mov dl, 'A' ; dl = ‘a‘
       mov ah, 2h ; character output subprogram
       int 21h ; call ms-dos output character