however, if buffer1 is local, it's on the stack and referenced by EBPoffset won't work because the address is not known at assemble-timelea esi,[ebp-12]LEA calculates the value of (ebp-12) and places it in esi

LEA might be used for an array index if the base address is in a register - like in a loop, for examplelea edx,[esi+4*ecx]

LEA is sometimes used to perform math, even though it's intended for addressinglea ecx,[4*ecx+ecx]multiplies ECX x 5

3. LODSB and STOSB are a bit slowerhowever, there are times when they still might be usedfor example, parsing a command line is only done once - and not many characters to processso, speed isn't criticalthe code is small, because LODSB and STOSB are single-byte op-codes

For the most part, for what you have shown, I see it as a matterof one's preference. You use what you are used to, or what youlike. You should at least assemble the code and look at a listing tosee what opcodes are actually generated.

That said, and without looking at a listing, I prefer the first in yourexample 1. One instruction versus two and one memory referenceversus two. I prefer the first again in your example 2. I have notused LEA enough to know how it differs from the moves in thissimple case. The results are identical. In your third example I wouldnormally use the first over the second. Mainly due to less typing,and thus less room for error. In fact for that example I would use: