Mail Archives: djgpp/1998/08/26/10:00:36
GAMMELJL AT SLU DOT EDU wrote:
>
> Thanks to those who responded to my query about
> movl $0x0,%edx vs xorl %edx,%edx
> The movl sets %edx to zero, whereas xorl sets %edx and the carry bit to
> zero. Thus the two statements above are not exactly the same thing.
> This fact could make little difference to all but a few programmers,
> and those few probably already know to avoid the xorl command when
> writing codes in assembly language. I find that the movl command
> results in faster executables even when xorl can be used as above
> (in those cases in which the carry bit does not matter).
Have you checked if indeed the carry flag (or ZF, OF, AF) influenced the
the result? It most probably does, but you never know for sure :-(
Unless the xorl is used in a loop that is repeated millions of times in
your program replacing xorl with movl is probably not a superb idea,
since xorl is encoded with only 2 bytes whereas movl takes 5 bytes, and
they nearly execute in the same time (approx. 0 s).
--
\ Vik /-_-_-_-_-_-_/
\___/ Heyndrickx /
\ /-_-_-_-_-_-_/ Knight in the Order of the Unsigned Types
- Raw text -