Re: test eax, eax - why?
- From: "randyhyde@xxxxxxxxxxxxx" <spamtrap@xxxxxxxxxx>
- Date: 24 Aug 2006 15:22:23 -0700
spamtrap@xxxxxxxxxx wrote:
Hi everyone,
I'm trying to learn x86 assembly language, and in addition to reading
the necessary books, trying the programmes etc., I'm also compiling my
own example C code and comparing it with the resultant (Visual C++)
code.
One thing I tried was compiling the "infinite" while(1){ ... } loop. I
got something like this:
mov eax, 1
test eax, eax
je label2
this seems somewhat odd. I know that "test" does a bitwise and of eax
and eax, but in this case, the rest of the
instruction (je) is not carried out. Why bother with this at all? Or
have I got the wrong end of the stick?
I suspect you didn't turn optimizations on :-)
Either that, or you've got a really *bad* compiler. But this is such an
easy optimization, I'd have to guess that you didn't turn optimization
on. When you don't have optimization active, most compiler generate
pretty lame code.
Cheers,
Randy Hyde
.
- References:
- test eax, eax - why?
- From: spamtrap
- test eax, eax - why?
- Prev by Date: Re: Suggestion for some good ASM books?
- Next by Date: Re: enabling x87 interrupts
- Previous by thread: Re: test eax, eax - why?
- Next by thread: enabling x87 interrupts
- Index(es):
Relevant Pages
|