I'm new to assembly and I'm trying to copy a string from an input char const char* source
into another string given in the input parameter, char* destination
and I have to do it via in line assembly x86, and here is my code:
Note: volatile marks that the variable/code region can change unexpectedly from an external source.
void samestring(const char* start, char* end) {
asm volatile (
"mov %[src], %%rsi\n"
"mov %[dest], %%rdi\n"
"xor %%al, %%al\n"
"inc %%rdi\n"
"cmpb $0, %%dl\n"
"jne copy_loop\n"
:
: "memory", "%rsi", "%rdi", "%rax", "%rdx"
);
}
This is the code that I found from a reddit post about a similar problem, and since I'm new to assembly, I don't really know if this method is efficient or whether there are ways I can improve this code or not, so I would like to consult experts of assembly to help tell me about what I can and should edit in the code above to make it less time consuming,
any help would be greatly appreciated.