3 ms·
Would someone mind explaining what all the assembly instructions in the meme do? In particular I'm wondering why you would do xor rcx, rcx when that result is a
by kayson 5y ago
Would someone mind explaining what all the assembly instructions in the meme do? In particular I'm wondering why you would do xor rcx, rcx when that result is always 0
- CoastalCoder 5y ago> why you would do xor rcx, rcx when that result is always 0 It's an idiomatic way to populate a register with the value zero. Not sure if it's still true, but IIRC it took fewer cycles than the more obvious "load #0 into $rcx" instruction.
- saagarjha 5y agoThese days you also get the benefit that it’s four bytes shorter, since it doesn’t have to store an immediate: 48 31 c9 xor rcx,rcx 48 c7 c1 00 00 00 00 mov rcx,0x0 (This is even shorter: 31 c9 xor ecx,ecx )
- rep_lodsb 5y agoIt should be easier for the processor to detect xor-reg-with-itself as a special case. Intel has documented this as the preferred instruction to use since the Pentium afaik.
- kloopersoop 5y agoWe call those runes “the shibboleth of an assembly programmer.” They are ancient and wise. If one speaks them, one knows of and yearns for a simpler time when MOV vs XOR was a debate. (Neighbor’s got it, and I am as unsure of contemporary relevance as they are.)