From owner-freebsd-hackers@FreeBSD.ORG Tue Jun 14 21:32:06 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9B41316A41C for ; Tue, 14 Jun 2005 21:32:06 +0000 (GMT) (envelope-from gemini@geminix.org) Received: from gen129.n001.c02.escapebox.net (gen129.n001.c02.escapebox.net [213.73.91.129]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5B6B943D1D for ; Tue, 14 Jun 2005 21:32:06 +0000 (GMT) (envelope-from gemini@geminix.org) Message-ID: <42AF4CCE.9040308@geminix.org> Date: Tue, 14 Jun 2005 23:31:58 +0200 From: Uwe Doering Organization: Private UNIX Site User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.8) Gecko/20050526 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Norbert Koch References: <000001c57016$8e4b0600$4801a8c0@ws-ew-3.W2KDEMIG> In-Reply-To: <000001c57016$8e4b0600$4801a8c0@ws-ew-3.W2KDEMIG> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Received: from gemini by geminix.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.51 (FreeBSD)) id 1DiJ0p-0007lm-3E; Tue, 14 Jun 2005 23:31:59 +0200 Cc: freebsd-hackers@freebsd.org Subject: Re: Obvious bug in /sys/i386/include/bus.h (was: bus_at386.h) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jun 2005 21:32:06 -0000 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