Re: asm conflict question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Richard Bonomo writes:
 > 
 > I am hoping someone can give me a little
 > advice in how to proceed.  I have
 > some C-code which I compile under
 > gcc-3.4.5 which employs a definition
 > such as this:
 > 
 > #define disable() \
 >      ({ register int __Status __asm__ ("d"); \
 >      __asm__ ("clra      ; save CPU status"); \
 >      __asm__ volatile ("tfr     cc,b" : "=d" (__Status) : : "d", "b"); \
 >      __asm__ ("orcc    #0x50   ; disable interrupts"); \
 >      __Status; })
 > 
 > When an attempt is made to compile, upon hitting the
 > spot in the program where this code winds up being
 > inserted, the compiler produces this error message
 > 
 > error: asm-specifier for variable `__Status' conflicts with asm clobber list
 > 
 > and quits.
 > 
 > After doing quite a bit if digging, I do know that for some
 > reason the compiler is probably complaining about the
 > assignment of register "d" (which includes registers
 > "a" and "b" in the Motorola 6809 as its high and
 > low components).
 > 
 > However, I am still at quite a loss as to how
 > I am to deal with this: how do I get around this,
 > short of rewriting this and other functions to
 > use ordinary variables as much as possible?
 > 
 > Can you shed any light on what, precisely is being
 > objected to, and how to meet that objection?

Sure.  You declare a register variable "__Status" that lives in
register d.  You then use that same register as an asm output.  gcc is
complaining about that conflict.

It's easy to fix.  Something like this:

#define disable() \
     ({  int __Status; \
     __asm__ volatile ("clra      ; save CPU status"); \
     __asm__ volatile ("tfr     cc,b" : "=d" (__Status)); \
     __asm__ volatile ("orcc    #0x50   ; disable interrupts"); \
     __Status; })

Andrew.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux