i386, asm and forbidden spilled registers...

Krister Walfridsson cato@df.lth.se
Fri Oct 30 14:39:00 GMT 1998


I tried to compile the NetBSD i386 kernel with a egcs built from todays
source. Egcs complains on most asm statements, but I don't understand
why...

For example, the following code gives the error

foo.c:7: Invalid `asm' statement:
foo.c:7: fixed or forbidden register 2 (cx) was spilled for class CREG.


static __inline void
insb(int port, void *addr, int cnt)
{
  	__asm __volatile("cld\n\trepne\n\tinsb"			:
								:
			 "d" (port), "D" (addr), "c" (cnt)	:
			 "%edi", "%ecx", "memory");
}

void
foo(void)
{
  insb(0,0,0);
}


Are there some kind of documentation somewhere how to write correct asm
statements? I didn't find anything relevant in the gcc info files...

   /Krister




More information about the Gcc mailing list