Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Weird error when giving a final count

Hey! Well I'm writing a program that will take a given number of grades(90%,77%,36%, etc) and once the user types a negative number to stop, it will output the total for each, so for the grade I wrote above, it would show:

ACount: 1
BCount: 0
CCount: 1
DCount: 0
FCount: 1

Everything works fine, but when I use the sentinel to get my final totals, they all have weird smiley face guys, followed by a "-1". I put a screen shot here:

Here is the code:
; a program that takes the numbers of grades and returns the total of each
; author:
; date: 8/11/09



ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD

cr EQU 0dh ; carridage return character
Lf EQU 0ah ; linefeed character

.STACK 4096 ; reserve 4096-byte stack


prompt1 BYTE cr,Lf,Lf,"Please enter the grade. Enter - to exit and get your total: ", 0
ACount BYTE ?
BCount BYTE ?
CCount BYTE ?
DCount BYTE ?
FCount BYTE ?
gradeIn BYTE 20 DUP (?)
AOut BYTE cr,Lf,Lf, "Total number of A's: ", 0
BOut BYTE cr,Lf, "Total number of B's: ", 0
COut BYTE cr,Lf, "Total number of C's: ", 0
DOut BYTE cr,Lf, "Total number of D's: ", 0
FOut BYTE cr,Lf, "Total number of F's: ", 0

.CODE ; start main code

whileGrade: output prompt1
input gradeIn,20
atod gradeIn
cmp eax,0
jl endGrade

gradeDecide: cmp eax, 90
jge ifA
cmp eax, 80
jge iffB
cmp eax, 70
jge ifC
cmp eax, 60
jge ifD
jmp ifF

ifA: inc ACount
jmp whileGrade

iffB: inc BCount
jmp whileGrade

ifC: inc CCount
jmp whileGrade

ifD: inc DCount
jmp whileGrade

ifF: inc FCount
jmp WhileGrade

endGrade: output AOut
output ACount
output BOut
output BCount
output COut
output CCount
output DOut
output DCount
output FOut
output FCount
jmp endCode

endCode: INVOKE ExitProcess, 0

PUBLIC _start

Any ideas?

Also, random, but is 'ifb' a mnemonic? I had to change it to 'iffB' because it wouldn't accept 'ifB'.
Sign In or Register to comment.