In disassembly, I often see that string manipulation instructions are being used without regard to the state of the direction flag (DF), like this:
or ecx, 0FFFFFFFFh
xor eax, eax
mov edi, ebp
repne scasb
CLD
or STD
instructions are not found since function begins, neither other instructions which could affect DF flag.
So does the compiler assume the predefined state of this flag since program launch, courtesy of the loader, and being preserved unchanged while program runs?
DF
before changing it, and restoring it afterwards. – TidyDF
and the compiler relies on that. – Adventist