; Chapter 6 Program
; Programmed in MASM on April 17th
; Replaced .ENDIF, and .ELSEIF directives with cmp and jump statements
INCLUDE Irvine32.inc
.data
TRUE = 1
FALSE = 0
gradeAverage DWORD ? ; grade average
credits DWORD ? ; amount of credits
OkToRegister BYTE ?
prompt2 BYTE "Enter the amount of credits ",0
prompt3 BYTE "Enter grade average ",0
prompt4 BYTE "Credit's cannot be less than 1 or greater than 30, Please enter a valid amount of credits: ",0
prompt5 BYTE "The student can register ",0
prompt6 BYTE "The student cannot register ",0
.code
main PROC
mov OkToRegister,FALSE
mov edx,OFFSET prompt3
call WriteString
call ReadInt
mov gradeAverage,eax
mov edx,OFFSET prompt2
call WriteString
call ReadInt
mov credits,eax
cmp credits,30
ja toomany
cmp credits,1
jbe toomany
cmp credits,1
ja good
toomany:call crediterror
good:
cmp gradeAverage,350
jbe Larger
mov OkToRegister,TRUE
jmp register1
Larger:
cmp gradeAverage,250
jbe ppp
cmp credits,16
ja ppp
mov OkToRegister,TRUE
jmp register1
ppp:
cmp credits,12
ja register1
mov OkToRegister,TRUE
cmp OkToRegister,1
JE register1
cmp OkToRegister,0
JE cregister1
cregister1:
call cregister
register1:
call register
exit
main ENDP
crediterror proc
mov edx,OFFSET prompt4
call WriteString
call ReadInt
mov credits,eax
ret
crediterror ENDP
register proc
mov edx,OFFSET prompt5
call WriteString
ret
register ENDP
cregister proc
mov edx,OFFSET prompt6
call WriteString
ret
cregister ENDP
END main
Instead of displaying one or the other it displays both.
Here is the assignment for the program:
Using the College Registration example from Section 7.3 as a starting point, do the following:
Recode the logic using CMP and conditional jump instructions (instead of the .IF and .ELSEIF directives).
Perform range checking on the credits value; it cannot be less than 1 or greater than 30. If an invalid entry is discovered, display an appropriate error message.
Prompt the user for the grade average and credits values.
Display a message that shows the outcome of the evaluation, such as "The student can register" or "The student cannot register".
The Irvine32 library is required for this solution program.