News for hackers. Stuff that matters.
Re:Smallest x86 ELF Hello World by VeXocide on Tuesday October 11, 2011 @12:52PM (#3099315)
You are right in that

    31 c0             xor %eax, %eax
is shorter than

    b8 00 00 00 00    mov $0, %eax
but that's not the main reason it's often used in shellcode. The xor reg, reg is preferred because it means the resulting shellcode will not contain a null byte. This is desirable since the null-byte is often used as a string terminator, in environment variables for example.
Re:Smallest x86 ELF Hello World by limmeau on Tuesday October 11, 2011 @03:16PM (#3099912)
Another reason to use xor: in the old days, ALU reg-reg commands were generally faster than reg-mem moves.

The 8086 assembly tutorial book I used then recommended to use "sub ax, ax" instead because it was less surprising.