\"forloop\" in assembly so I am trying to write a program with the input and out
ID: 3885101 • Letter: #
Question
"forloop" in assembly
so I am trying to write a program with the input and output in assembly but the rest of the functions in assembly language.
The program consists of reading a string of y's and n's, outputting the number of y's and n's as well as outputting number of y's and n's in asterisks.
ex. input: yynnyynn
output: number of y's = 4 = ****
number of n's = 4 = ****
My problem has to do with writing my "forloop" in assembly. It for some reason starts looping infinitely. What am I doing wrong?
}
"forloop" in assembly
so I am trying to write a program with the input and output in assembly but the rest of the functions in assembly language.
The program consists of reading a string of y's and n's, outputting the number of y's and n's as well as outputting number of y's and n's in asterisks.
ex. input: yynnyynn
output: number of y's = 4 = ****
number of n's = 4 = ****
My problem has to do with writing my "forloop" in assembly. It for some reason starts looping infinitely. What am I doing wrong?
#include using namespace std; char c; int numY; int numN; void askForInput() { cout << "Enter a string of votes: "; } void readChar() { cin.get(c); } void printAst() { cout << "*"; } void outputY() { cout << "No. of YES votes = " << numY << " = "; } void outputN() { cout << "No. of NO votes = " << numN << " = "; } int main() { _asm { call askForInput call readChar whileloop : cmp c, ' ' je endWhile cmp c, 'y' je incY // inc numN // jmp readAgain incY : inc numY mov edx, numY jmp readAgain readAgain : call readChar jmp whileloop mov ecx, 1; i = 1 forloopY: cmp ecx, edx Jge endfor; if ecx < edx jmp to endfor call printAst inc ecx; ++i jmp forloopY endWhile: call outputY jmp forloopY endfor: } system("pause"); return 0; }
Explanation / Answer
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.