Re: asm conflict question

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

 



Richard Bonomo writes:
 > 
 > 
 > On Wed, 9 Aug 2006, Andrew Haley wrote:
 > 
 > <snip>
 > 
 > > MM, wrong.  gcc might put something between the insns.  Ok, try
 > >
 > > #define disable() \
 > >     ({  int __Status; \
 > >     __asm__ volatile ("clra      ; save CPU status\n" \
 > >                       "tfr     cc,b\n" \
 > >                       "orcc    #0x50   ; disable interrupts" \
 > >                        : "=d" (__Status)); \
 > >     __Status; })
 > >
 > 
 > OK, I get this error message:
 > 
 > error: can't find a register in class `Q_REGS' while reloading `asm'
 > 
 > which I think is generated by the companion "restore" function.

OK.  Well, you have a worked example -- now you need to read the
manual about Extended Asm and do the same with restore() that you did
with disable().

 > Here are the 3 function definitions as they
 > currently stand:
 > 
 > #define disable() \
 >       ({  int __Status; \
 >       __asm__ volatile ("clra      ; save CPU status\n" \
 >                         "tfr     cc,b\n" \
 >                         "orcc    #0x50   ; disable interrupts" \
 >                          : "=d" (__Status)); \
 >       __Status; })
 > 
 > #define restore(X) \
 >      ({ int __Status = (X); \
 >      __asm__ ("tfr       b,cc    ; restore status" : : "d" (__Status) : 
 > "d", "cc"); })  [NOTE that the line wrapped in this message]
 > 
 > #define enable() \
 >      __asm__ ("andcc     #0xaf   ; enable interrupts")
 > 
 > 
 > The disable function is as you (Andrew) suggested.
 > The restore function and enable function definitions
 > are unchanged.
 > 
 > BTW, I am not familiar with the syntax which was
 > and it being used.  What does (for example)
 > ("tfr       b,cc    ; restore status" : : "d" (__Status) :"d", "cc")
 > mean in this context?

Here, register d is being used as an input and it's also being
clobbered.  That doesn't seem right to me.  Something more like using
"=d" as the ouput and a matching constraint "0" for the input might
work better.

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