4 ms·
You are correct but using programmers terminology here is confusing. The opcodes 31 C0 mean "Set EAX register to zero" The opcodes 31 D8 mean "Set EAX to EAX
by tomtomtom777 6y ago
You are correct but using programmers terminology here is confusing.
The opcodes 31 C0 mean "Set EAX register to zero"
The opcodes 31 D8 mean "Set EAX to EAX xor EBX"
The trick part is in the mnemonics used by assemblers and literature that transcribe the first as "XOR EAX, EAX".
It isn't actually implemented as such, so it isn't really an "optimization"
- FartyMcFarter 6y agoI'm not sure what you mean by "programmers terminology". 0x31 0xC0 is disassembled to "xor eax, eax". This is not nitpicking, as there's an important difference. The "xor eax, eax" instruction affects CPU flags [1], while "mov eax, 0" doesn't [2]. > It isn't actually implemented as such The implementation is independent of the meaning of the instruction set. There are many implementations of x86 instructions with differing levels and kinds of optimization, so we can't make general statements about that. [1] https://c9x.me/x86/html/file_module_x86_id_330.html https://c9x.me/x86/html/file_module_x86_id_330.html [2] https://c9x.me/x86/html/file_module_x86_id_176.html https://c9x.me/x86/html/file_module_x86_id_176.html