I am trying to convert a C++ function code that converts passed string argument to UPPERCASE, into inline assembly code. Below is what i did:
// Funtion to convert each letter of employee name to uppercase.
// Input : employee structure object as refrence.
void capitalise_name(employee &emp)
{
// //for loop to parse each letter the employee name
// for (int i = 0; i < emp.name.length(); ++i)
// {
// //convert the letter to uppercase
// emp.name[i] = toupper(emp.name[i]);
// }
__asm__
(
"mov ecx, emp.name"
"call toUpper"
"mov eax,1"
"mov ebx,0"
"int 80h"
"toUpper:"
"mov al,[ecx]"
"cmp al,0x0"
"je done"
"cmp al,'a'"
"jb next_please"
"cmp al,'z'"
"ja next_please"
"sub al,0x20"
"mov [ecx],al"
"next_please:"
"inc ecx"
"jmp toUpper"
"done:"
);
}
When i am compiling this program i am getting below error:
> Executing task: C/C++: g++.exe build active file <
Starting build...
C:\Data\mingw32\bin\g++.exe -fdiagnostics-color=always -g "C:\Users\rawat\Downloads\New folder\delivery\program.cpp" -o "C:\Users\rawat\Downloads\New folder\delivery\program.exe"
C:\Users\rawat\AppData\Local\Temp\ccRQyKCt.s: Assembler messages:
C:\Users\rawat\AppData\Local\Temp\ccRQyKCt.s:1003: Error: too many memory references for `mov'
Build finished with warning(s).
Terminal will be reused by tasks, press any key to close it.
Please suggest how can i resolve it thanks!