Date: Fri, 27 Nov 1998 19:56:32 -0500 (EST) From: "John S. Dyson" <dyson@iquest.net> To: current@FreeBSD.ORG Subject: Fix for incorrect clobbers in asm's Message-ID: <199811280056.TAA03374@y.dyson.net>
next in thread | raw e-mail | index | archive | help
--ELM912214592-3366-0_ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Note that the specification for clobbers in inline asm's on GCC hasn't always been clear. The attached patches correct the clobbers in the inline asms for current. 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. -- John | Never try to teach a pig to sing, dyson@iquest.net | it makes one look stupid jdyson@nc.com | and it irritates the pig. --ELM912214592-3366-0_ Content-Type: text/plain; charset=ISO-8859-1 Content-Disposition: attachment; filename=clobbers.diff Content-Description: clobbers.diff Content-Transfer-Encoding: 7bit Index: i386/i386/identcpu.c =================================================================== RCS file: /local/home/ncvs/src/sys/i386/i386/identcpu.c,v retrieving revision 1.52 diff -C1 -r1.52 identcpu.c *** identcpu.c 1998/10/06 13:16:23 1.52 --- identcpu.c 1998/11/28 00:49:10 *************** *** 106,107 **** --- 106,108 ---- { + int nax; __asm __volatile( *************** *** 112,116 **** "movl %%edx, (12)(%%esi);" ! : : "a" (ax), "S" (p) ! : "ax", "bx", "cx", "dx" ); --- 113,117 ---- "movl %%edx, (12)(%%esi);" ! : "=a"(nax) : "a" (ax), "S" (p) ! : "bx", "cx", "dx" ); 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"); } *************** *** 200,204 **** { __asm __volatile("cld; rep; insw" ! : : "d" (port), "D" (addr), "c" (cnt) ! : "di", "cx", "memory"); } --- 202,208 ---- { + int ndi, ncx; __asm __volatile("cld; rep; insw" ! : "=D"(ndi), "=c"(ncx) ! : "d" (port), "D" (addr), "c" (cnt) ! : "memory"); } *************** *** 208,212 **** { __asm __volatile("cld; rep; insl" ! : : "d" (port), "D" (addr), "c" (cnt) ! : "di", "cx", "memory"); } --- 212,218 ---- { + int ndi, ncx; __asm __volatile("cld; rep; insl" ! : "=D"(ndi), "=c"(ncx) ! : "d" (port), "D" (addr), "c" (cnt) ! : "memory"); } *************** *** 323,327 **** { __asm __volatile("cld; rep; outsb" ! : : "d" (port), "S" (addr), "c" (cnt) ! : "si", "cx"); } --- 329,334 ---- { + int nsi, ncx; __asm __volatile("cld; rep; outsb" ! : "=S"(nsi), "=c"(ncx) ! : "d" (port), "S" (addr), "c" (cnt)); } *************** *** 331,335 **** { __asm __volatile("cld; rep; outsw" ! : : "d" (port), "S" (addr), "c" (cnt) ! : "si", "cx"); } --- 338,343 ---- { + int nsi, ncx; __asm __volatile("cld; rep; outsw" ! : "=S"(nsi), "=c"(ncx) ! : "d" (port), "S" (addr), "c" (cnt)); } *************** *** 339,343 **** { __asm __volatile("cld; rep; outsl" ! : : "d" (port), "S" (addr), "c" (cnt) ! : "si", "cx"); } --- 347,352 ---- { + int nsi, ncx; __asm __volatile("cld; rep; outsl" ! : "=S"(nsi), "=c"(ncx) ! : "d" (port), "S" (addr), "c" (cnt)); } Index: i386/isa/sound/audio.c =================================================================== RCS file: /local/home/ncvs/src/sys/i386/isa/sound/audio.c,v retrieving revision 1.19 diff -C1 -r1.19 audio.c *** audio.c 1998/07/15 11:47:58 1.19 --- audio.c 1998/11/28 00:50:36 *************** *** 167,168 **** --- 167,169 ---- { + int nbx, ncx, ndi, nsi; if (n > 0) { *************** *** 172,176 **** "stosb\n\t" ! "loop 1b\n\t": :"b"(table), "c"(n), "D"(buff), "S"(buff) ! :"bx", "cx", "di", "si", "ax"); } --- 173,178 ---- "stosb\n\t" ! "loop 1b\n\t" ! :"=b"(nbx), "=c"(ncx), "=D" (ndi), "=S" (nsi) :"b"(table), "c"(n), "D"(buff), "S"(buff) ! :"ax"); } --ELM912214592-3366-0_-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199811280056.TAA03374>