Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Converting C++ code to MASM code (Assembly Language for intel x86 processors) Please convert this code that counts the occurrences of words in a string

Converting C++ code to MASM code (Assembly Language for intel x86 processors)

Please convert this code that counts the occurrences of words in a string and displays them; this needs to be converted from C++ to Assembly for intel x86 processors. The Assembly code should be able to compile on Microsoft Visual Studio and if you know the Irvibe32 library, use that as well:

#include

#include

using namespace std;

int main()

{

string source;

int wordCount = 1;

int occurrence = 0;

string word = "";

string tempWord = "";

int counter = 0;

int uniqueWords = 0;

cout<< "Please enter string: " <

cin>>source

for(int i = 0; i < source.length(); i++)

{

if(source[i] == ' ')

{

wordCount++;

}

}

string *strArray = new string[wordCount];

int *countArray = new int[wordCount];

for(int i = 0; i < strArray->length(); i++)

{

strArray[i] = "";

countArray[i] = 0;

}

for(int i = 0; i < wordCount; i++)

{

word = "";

while( source[counter] != 32 && counter < source.length() )

{

word = word + source[counter];

counter++;

}

counter++;

for(int arrayCounter = 0; arrayCounter < wordCount; arrayCounter++)

{

if(strArray[arrayCounter] == "")

{

strArray[arrayCounter] = word;

countArray[arrayCounter] = 1;

uniqueWords++;

arrayCounter = wordCount;

}

else if(strArray[arrayCounter] == word)

{

countArray[arrayCounter]++;

arrayCounter = wordCount;

}

}

}

for(int i = 0; i < uniqueWords; i++)

{

cout << strArray[i] << " " << countArray[i] << endl;

}

delete[] strArray;

delete[] countArray;

system("pause");

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions

Question

What is Constitution, Political System and Public Policy? In India

Answered: 1 week ago

Question

What is Environment and Ecology? Explain with examples

Answered: 1 week ago