From owner-freebsd-hackers@FreeBSD.ORG Mon Jun 13 12:26:18 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 C629416A41C for ; Mon, 13 Jun 2005 12:26:18 +0000 (GMT) (envelope-from gerarra@tin.it) Received: from vsmtp2.tin.it (vsmtp2.tin.it [212.216.176.222]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7731C43D1D for ; Mon, 13 Jun 2005 12:26:18 +0000 (GMT) (envelope-from gerarra@tin.it) Received: from ims3a.cp.tin.it (192.168.70.103) by vsmtp2.tin.it (7.0.027) id 42ABD4F2000771E1; Mon, 13 Jun 2005 14:26:16 +0200 Received: from [192.168.70.226] by ims3a.cp.tin.it with HTTP; Mon, 13 Jun 2005 14:26:14 +0200 Date: Mon, 13 Jun 2005 14:26:14 +0200 Message-ID: <429C8E8F00015E63@ims3a.cp.tin.it> In-Reply-To: <200506131412.38967.hselasky@c2i.net> From: gerarra@tin.it To: freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable X-Originating-IP: 151.100.38.110 Cc: hselasky@c2i.net 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: Mon, 13 Jun 2005 12:26:18 -0000 >http://www.freebsd.org/cgi/query-pr.cgi?pr=3D80980 > >In FreeBSD 6-current the code for "bus_space_write_multi_1()" says: > > __asm __volatile(" \n\ > cld \n\ > 1: lodsb \n\ > movb %%al,(%2) \n\ > loop 1b" : > "=3DS" (addr), "=3Dc" (count) : > "r" (bsh + offset), "0" (addr), "1" (count) : > "%eax", "memory", "cc"); > >This is equivalent to: > >while(--count) >{ > /* I/O */ >} > >which is obviously wrong, because it doesn't check for count equal to ze= ro. >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 need= s >to >be added: > >or %ecx, %ecx >jz 2 > >2: This is wrong beacause the result is stored in ecx. Better using JECXZ in= struction before the loop. Greeting, rookie