Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. ; Eric Lilling & Matthew Dangerfield
  2. INCLUDE Irvine32.inc
  3. .386
  4. .model flat,stdcall
  5. .stack 4096
  6. ExitProcess proto, dwExitCode: dword
  7.  
  8. .data
  9. prompt BYTE "Enter a test score (999 to exit): ", 0
  10. score BYTE "Test Score: ", 0
  11. grade BYTE " Letter grade: ", 0
  12. newline BYTE " ", 13,10,0
  13. numScores BYTE "Number of test scores: ", 13,10,0
  14. Num1 DWORD ?
  15. counter DWORD 0
  16.  
  17. .code
  18. main proc
  19. mov edx,OFFSET Prompt ; Prints Prompt
  20. call WriteString
  21.  
  22. call ReadInt ; reads an integer from input (hopefully)
  23. mov Num1, eax
  24. add counter, 1
  25.  
  26. mov edx, OFFSET score ;display the generated integer score
  27. call WriteString ;print the string TstScr
  28. mov eax, Num1
  29. call WriteDec
  30.  
  31. call CalcGrade ;returned letter grade will be in AL
  32.  
  33. mov edx, OFFSET grade
  34. call WriteString
  35. call WriteChar
  36.  
  37. mov edx, OFFSET newline
  38. call WriteString
  39.  
  40. cmp eax, 999
  41. je done
  42.  
  43. jmp main
  44. done:
  45. mov edx, OFFSET numScores
  46. call WriteString
  47. mov eax, counter
  48. call WriteDec
  49. exit
  50.  
  51. exit
  52. main endp
  53.  
  54. CalcGrade proc
  55. mov eax, Num1
  56. cmp eax, 999
  57. je next
  58. cmp eax, 90 ;if score >= 90, jump to label LA
  59. jae LA
  60. cmp eax, 80
  61. jae LB
  62. cmp eax, 70
  63. jae LC
  64. cmp eax, 60
  65. jae LD
  66. jmp LF
  67. ;save the corresponding letter into AL
  68.  
  69. LA: mov al, 'A'
  70. ret
  71. jmp main
  72. LB: mov al, 'B'
  73. ret
  74. jmp main
  75. LC: mov al, 'C'
  76. ret
  77. jmp main
  78. LD: mov al, 'D'
  79. ret
  80. jmp main
  81. LF: mov al, 'F'
  82. ret
  83. jmp main
  84. next:
  85. exit
  86. CalcGrade endp
  87. end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement