Question: Plese help me with the _ asm, I cannot figure out how to output two words per line ' #include #include #include using namespace std;

Plese help me with the _asm, I cannot figure out how to output two words per line
'#include
#include
#include
using namespace std;
char sentence[100];
int i;
char c;
void readSentence()
{
cout << "Enter a sentence: ";
cin.getline(sentence,100,'
');
}
void skipLine()
{
cout << endl;
}
void display()
{
cout << c;
}
int main()
{
//cannot make another dl, it wont make sense
//cannot break it, it wont work
//cannot double up, it wont work
//my best bet is to allow is to compute 2 words and go to the next line
_asm
{
Call readSentence; //reading the sentence
lea esi, sentence; //making sentence an esi
mov dl,[esi]; //moving the sentence in
whileLoop:
cmp dl,'\0'; //when there is no input
je endWhile; //goes to endWhile
mov dl,[esi]; //moving the sentence to dl
mov c, dl //moving the dl to c
call display; //displaying the one letter
add esi, 1; //goes to the next letter
mov dl,[esi]; //saves the letters being outputted
inc i; //idk
cmp [esi],''; //if word has space
Je newLine; //go to new line
jmp whileLoop; //lets all the words play out until it gets to a space
newLine:
Call skipLine; //calls the skip part
add esi, 1; //adds another word??
inc i; //idk
jmp whileLoop; //does the loop again
endWhile: //end asm
}
cout << endl;
system("pause");
return 0;
}
/*-----------------------output---------------------------------------
Enter a sentence: The best way to care for others is to first care for yourself
Output:
The best
way to
care for
others is
to first
care for
yourself
Press any key to continue ...
------------------------------------------------------------------------*/'

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!