Timeline for Tips for golfing in x86/x64 machine code
Current License: CC BY-SA 4.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 5 at 8:03 | history | edited | Peter Cordes | CC BY-SA 4.0 | added 55 characters in body |
| Mar 30, 2018 at 1:51 | history | edited | Peter Cordes | CC BY-SA 3.0 | 2-byte NOT isn't worth suggesting vs. 1 byte DEC. XOR-zeroing is the most common / widely known "peephole" optimization, so strongly encourage it even for non-golf usage. PUSH/POP trick, and LEA trick. |
| Mar 29, 2018 at 17:36 | history | edited | Peter Cordes | CC BY-SA 3.0 | mov reg,reg is 2 bytes, and talking about 1-byte xchg eax,edx would be a different answer. |
| Mar 29, 2018 at 13:35 | comment | added | Peter Cordes | @anatolyg: 200 is a poor example, it doesn't fit in a sign-extended-imm8. But yes, push imm8 / pop reg is 3 bytes, and is fantastic for 64-bit constants on x86-64, where dec / inc is 2 bytes. And push r64 / pop 64 (2 bytes) can even replace a 3 byte mov r64, r64 (3 bytes with REX). See also Set all bits in CPU register to 1 efficiently for stuff like lea eax, [rcx-1] given a known value in eax (e.g. if need a zeroed register and another constant, just use LEA instead of push/pop | |
| Nov 14, 2017 at 15:58 | vote | accept | ბიმო | ||
| Nov 14, 2017 at 15:58 | |||||
| Jul 18, 2017 at 14:28 | history | edited | ბიმო | CC BY-SA 3.0 | -1 byte for -1 initialization. |
| Jul 18, 2017 at 10:28 | comment | added | anatolyg | BTW to initialize a register to -1, use dec, e.g. xor eax, eax; dec eax | |
| Jul 17, 2017 at 22:01 | history | answered | ბიმო | CC BY-SA 3.0 |