I want to calculate length of the word, but I have error. I don’t understand why.
int new_strlen(char* word)
{
int len = 0;
__asm__ ("mov ecx, 100nt"
"mov esi, %1nt"
"mov al, 0nt"
"repne scasbnt"
"mov %0, 100nt"
"sub %0, ecxnt"
: "=a"(len)
: "r"(word)
: "%ecx","%esi", "%eax"
);
return len;
}
My error is “‘asm’ operand has impossible constraints”.
I attempted to use the __asm{} construct, but it is not available on the x64 architecture.I am compiling a program using the “-masm=intel” flag. My compiler is “g++”. Also I attempted to use “volatile” but it useless.
Do you have any thoughts on this matter? I would appreciate it if you could share your insights.
I am very grateful!
I try anything. Pls, help me
user24607044 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.