The following code written in C # in VS2010 for .Net 4.0:
bool b = false;
has the following disassembly:
XOR EDX,EDX MOV DWORD PTR[EBP-3Ch],EDX
which makes perfect sense.
However, the following code:
bool b = true;
has the following disassembly:
MOV EAX,1 AND EAX,0FFh MOV DWORD PTR[EBP-3Ch],EAX
What is the purpose of the AND operation? Why not just MOV EAX,1 ?
Line | EAX ----------- 1 | 0x01 2 | 0x01 & 0xFF = 0x01 3 | 0xFF
Ozzah
source share