Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Jun 2005 23:31:58 +0200
From:      Uwe Doering <gemini@geminix.org>
To:        Norbert Koch <NKoch@demig.de>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Obvious bug in /sys/i386/include/bus.h (was: bus_at386.h)
Message-ID:  <42AF4CCE.9040308@geminix.org>
In-Reply-To: <000001c57016$8e4b0600$4801a8c0@ws-ew-3.W2KDEMIG>
References:  <000001c57016$8e4b0600$4801a8c0@ws-ew-3.W2KDEMIG>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
Norbert Koch wrote:
>>>So
>>>how can I fix this in assembly. I am not an expert with inlined assembly,
>>>so
>>>maybe someone can correct me if I am wrong, but something like this needs
>>>to
>>>be added:
>>>
>>>or %ecx, %ecx
>>>jz 2
>>>
>>>2:
>>
>>This is wrong beacause the result is stored in ecx. Better using
>>JECXZ instruction
>>before the loop.
> 
> No, it's a correct method to set/reset the zero flag:
>     (X | X) == X just as (X & X) == X
> 
> So, he could also write: "and %ecx, %ecx".
> [...]

Also, on pipelined processors like Intel Pentium and better you would 
use "test %ecx, %ecx" for this purpose which internally is an "and", but 
since it drops the result and just sets the condition register it is 
faster than "and" or "or".  At least potentially.  Depends on the 
surrounding code.

    Uwe
-- 
Uwe Doering         |  EscapeBox - Managed On-Demand UNIX Servers
gemini@geminix.org  |  http://www.escapebox.net



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?42AF4CCE.9040308>