From owner-freebsd-current Fri Nov 27 21:26:50 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id VAA05157 for freebsd-current-outgoing; Fri, 27 Nov 1998 21:26:50 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.15.68.22]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id VAA05152 for ; Fri, 27 Nov 1998 21:26:46 -0800 (PST) (envelope-from bde@godzilla.zeta.org.au) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.7/8.8.7) id QAA22443; Sat, 28 Nov 1998 16:26:35 +1100 Date: Sat, 28 Nov 1998 16:26:35 +1100 From: Bruce Evans Message-Id: <199811280526.QAA22443@godzilla.zeta.org.au> To: current@FreeBSD.ORG, dyson@iquest.net Subject: Re: Fix for incorrect clobbers in asm's Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >Specifically, it is totally incorrect to clobber any of the input >or output operands. The workaround is to indicate that the clobbered >registers are output operands, with no subsequent usage. It might >be counter-intuitive, but is the suggested solution to the problem. This is best written using constraints that say that some output operands are the same as input operands. There is no other way if the input operands aren't in fixed registers. >Index: i386/include/cpufunc.h >=================================================================== >RCS file: /local/home/ncvs/src/sys/i386/include/cpufunc.h,v >retrieving revision 1.81 >diff -C1 -r1.81 cpufunc.h >*** cpufunc.h 1998/08/17 08:57:05 1.81 >--- cpufunc.h 1998/11/28 00:46:45 >*************** >*** 192,196 **** > { > __asm __volatile("cld; rep; insb" >! : : "d" (port), "D" (addr), "c" (cnt) >! : "di", "cx", "memory"); > } >--- 192,198 ---- > { >+ int ndi, ncx; > __asm __volatile("cld; rep; insb" >! : "=D"(ndi), "=c"(ncx) >! : "d" (port), "D" (addr), "c" (cnt) >! : "memory"); > } Rewritten using constraints: __asm __volatile("cld; rep; insb" : "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "d" (port) : "memory"); This discards the output operands in the input variables to avoid extra local variables. This is harmless because the input variables are dead, and more natural because it is normal for pointers to be incremented and counts to be decremented. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message