What is the fastest way to set a single memory cell to zero in x86? Typically the way I do it is this:
C745D800000000 MOV [ebp-28], 0
As you can see this has a pretty chunky encoding since it is using all 4 bytes for the constant. With a plain register I can use MVZE
which is more compact, but MVZE
does not work with memory.
I was thinking maybe clear a register, then MOV
the register value to the memory. Then, it would be two instructions, but only 5 bytes total instead of the one 7-byte instruction above. Following the rule "if its shorter, its usually faster", this might be preferable.