From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <3B185520.BA8CCC3B@princeton.edu> From: Martin Harriss MIME-Version: 1.0 To: 9fans@cse.psu.edu Subject: Re: [9fans] gcc x86 assembly help References: <20010601225409.1D11D199C0@mail.cse.psu.edu> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Fri, 1 Jun 2001 22:53:20 -0400 Topicbox-Message-UUID: add7cdf8-eac9-11e9-9e20-41e7f4b1d025 Russ Cox wrote: > > Ishwar has been trying to compile drawterm on a > Linux 2.4 kernel. The drawterm code (like the Inferno > code before it) depends on the fact that there are > different TSS registers in each process in Linux, > but this changed in 2.4 so the Linux-specific code > broke. > > He's now trying to use the pthread-specific code > (which works well under FreeBSD and Irix), but gets > a weird message from gcc about "impossible register > constraint in asm" on the x86 test-and-set code. > > typedef struct Lock Lock; > struct Lock { > int val; > }; > > int > canlock(Lock *l) > { > int v; > > __asm__( "movl $1, %%eax\n\t" > "xchgl %%eax,(%%ebx)" > : "=a" (v) > : "ebx" (&l->val) > ); > switch(v) { > case 0: return 1; > case 1: return 0; > default: print("canlock: corrupted 0x%lux\n", v); > } > return 0; > } > > Does anyone with more gcc inline assembly experience > know what's wrong with this (or what changed in gcc > in the latest Linux distributions to make it start > rejecting this)? > > Thanks. > Russ I think the problem may be the "ebx" constraint. I've never seen it written like that -- I thought that for the [e]bx register the constraint was simply "b". The current manual seems to confirm that. Can you try "b" and see if you have any luck? Martin Reference: http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_16.html#SEC175