Question: Read a sentence with period at the end. Display the sentence so that all vowels are in uppercase
sample I/O
Enter a sentence: proud is self-respect.
Output: prOUd Is sElf-rEspEct.
I have written a c++ code for this, I need to translate that to assembly language, we use c++to implement the assembly language. I have written some code for transferring a and e to uppercase, but still get wrong, can you help me with that? Thanks!
c++:
#include
#include
using namespace std;
char a[50];
int i;
void read() {
cout << "Enter a sentence: ";
cin.get(a, 50);
}
void display() {
for (int i = 0; i < 50; i++) {
if (a[i] == 'a') {
a[i] = 'A';
}else if (a[i] == 'e') {
a[i] = 'E';
}else if (a[i] == 'i') {
a[i] = 'I';
}else if (a[i] == 'o') {
a[i] = 'O';
}else if(a[i] == 'u') {
a[i] = 'U';
}
}
my assembly code:
char a[50];
int i;
void read() {
cout << "Enter a sentence: ";
cin.get(a, 50);
}
void toUppercaseA() {
a[i] = 'A';
}
void toUppercaseE() {
a[i] = 'E';
}
void display() {
cout << a << endl;
}
int main() {
_asm {
call read;
mov i, 0;
forloop:
mov eax, i;
//mov eax, i;
cmp i, 3;
jg endloop;
cmp [a + eax], 'a';
je uppercaseA;
cmp [a + eax], 'e';
je uppercaseE;
inc i;
jmp forloop;
uppercaseA:
call toUppercaseA;
jmp forloop;
uppercaseE:
call toUppercaseE;
jmp forloop;
endloop:
call display;
}
system("pause");
return 0;
}