Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

As you can read about herehere the loop instruction decrements ECX, jumps if it's not 0 and continues if it's 0.

edi is used as a pointer to the end of the string. ecx is set to the length of the string

This line is sneaky: mov esi,OFFSET target - 2

The loop is the equivalent of:

a = 0;
b = source.length - 1;
for (int i = source.length; i >= 0; i++) {
   target[a] = source[b];
   a++;
   b--;
}

As you can read about here the loop instruction decrements ECX, jumps if it's not 0 and continues if it's 0.

edi is used as a pointer to the end of the string. ecx is set to the length of the string

This line is sneaky: mov esi,OFFSET target - 2

The loop is the equivalent of:

a = 0;
b = source.length - 1;
for (int i = source.length; i >= 0; i++) {
   target[a] = source[b];
   a++;
   b--;
}

As you can read about here the loop instruction decrements ECX, jumps if it's not 0 and continues if it's 0.

edi is used as a pointer to the end of the string. ecx is set to the length of the string

This line is sneaky: mov esi,OFFSET target - 2

The loop is the equivalent of:

a = 0;
b = source.length - 1;
for (int i = source.length; i >= 0; i++) {
   target[a] = source[b];
   a++;
   b--;
}
Source Link
Eric Hughes
  • 841
  • 6
  • 19

As you can read about here the loop instruction decrements ECX, jumps if it's not 0 and continues if it's 0.

edi is used as a pointer to the end of the string. ecx is set to the length of the string

This line is sneaky: mov esi,OFFSET target - 2

The loop is the equivalent of:

a = 0;
b = source.length - 1;
for (int i = source.length; i >= 0; i++) {
   target[a] = source[b];
   a++;
   b--;
}