Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Eric Lilling & Matthew Dangerfield
- INCLUDE Irvine32.inc
- .386
- .model flat,stdcall
- .stack 4096
- ExitProcess proto, dwExitCode: dword
- .data
- prompt BYTE "Enter a test score (999 to exit): ", 0
- score BYTE "Test Score: ", 0
- grade BYTE " Letter grade: ", 0
- newline BYTE " ", 13,10,0
- numScores BYTE "Number of test scores: ", 13,10,0
- Num1 DWORD ?
- counter DWORD 0
- .code
- main proc
- mov edx,OFFSET Prompt ; Prints Prompt
- call WriteString
- call ReadInt ; reads an integer from input (hopefully)
- mov Num1, eax
- add counter, 1
- mov edx, OFFSET score ;display the generated integer score
- call WriteString ;print the string TstScr
- mov eax, Num1
- call WriteDec
- call CalcGrade ;returned letter grade will be in AL
- mov edx, OFFSET grade
- call WriteString
- call WriteChar
- mov edx, OFFSET newline
- call WriteString
- cmp eax, 999
- je done
- jmp main
- done:
- mov edx, OFFSET numScores
- call WriteString
- mov eax, counter
- call WriteDec
- exit
- exit
- main endp
- CalcGrade proc
- mov eax, Num1
- cmp eax, 999
- je next
- cmp eax, 90 ;if score >= 90, jump to label LA
- jae LA
- cmp eax, 80
- jae LB
- cmp eax, 70
- jae LC
- cmp eax, 60
- jae LD
- jmp LF
- ;save the corresponding letter into AL
- LA: mov al, 'A'
- ret
- jmp main
- LB: mov al, 'B'
- ret
- jmp main
- LC: mov al, 'C'
- ret
- jmp main
- LD: mov al, 'D'
- ret
- jmp main
- LF: mov al, 'F'
- ret
- jmp main
- next:
- exit
- CalcGrade endp
- end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement