Im not an optomization person per say, but i have a few rule of thumbs.. like minimize the number of 8 bit operations in your program, and maximize 32 bit operations.. but every so often you *have* to 8 bit work.

My question is which is a better approach for character string processing:

xor eax, eax

lea edx, string
@@:
[b]mov al, [edx][/b]

.. process 32 bit eax ..
inc edx
cmp xx, yy
jne @B


Or...

lea edx, string

@@:
[b]movzx eax, BYTE PTR [edx][/b]

.. process 32 bit eax ..

inc edx
cmp xx, yy
jne @B


Im thinking that the zero extended mov would be better, since it also giving the processor information that the rest of the eax register doesnt need to be preserved in any way. But on the other hand, i dont really know if Intel/Amd continued to develop this command since 386 days...

Thanks!
:alright:
NaN
Posted on 2003-07-17 20:19:37 by NaN
NaN
i think


xor eax,eax
mov al,[edi]

not equal


movsz eax, BYTE PTR [edx]

if byte ptr == 1xxx'xxxxb
in first case eax == 0000'0000'0000'0000"0000'0000'1xxx'xxxxb
in second case eax == 1111'1111'1111'1111"1111'1111'1xxx'xxxxb

if choice from xor+mov and movzx i use first.
Posted on 2003-07-18 00:09:56 by P2M
My Bad.. I mistyped it. The command should be "movzx eax, byte ptr ".
Posted on 2003-07-18 00:15:35 by NaN
Posted on 2003-07-18 01:21:36 by P2M
Nan,

mov al, is definitely shorter than movzx version since movzx is part of the "new" instruction (starts with 0Fh).

But I doubt you would run into any partial register stall from your code, but then again it is not really nice to mix 32/16/8 bits registers. Maybe the following would be intersting to you.

http://www.asmcommunity.net/board/index.php?topic=12306
Posted on 2003-07-18 07:08:08 by roticv