Question
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started