[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-chat] Inline assembler warning: asm operand 2 probably doesn't matc
From: |
Rick Mann |
Subject: |
[avr-chat] Inline assembler warning: asm operand 2 probably doesn't match constraints |
Date: |
Sat, 5 Feb 2011 03:05:45 -0800 |
Hi. I'm doing some experiments with writing C++ wrappers to access AVR
hardware. I've got an AVRPort class that does some interesting things.
http://pastebin.com/AwuY28F9
In particular, I'm able to write a method using inline assembler that produces
code identical to the traditional C:
PORTA |= 0x03;
12: 82 b1 in r24, 0x02 ; 2
14: 83 60 ori r24, 0x03 ; 3
16: 82 b9 out 0x02, r24 ; 2
But when I try to write similar inline asm for the inverse operation, I get an
error:
void
clear(uint8_t inPins)
{
#if 0
mPort &= ~inPins;
#else
uint8_t inverse = ~inPins;
uint8_t temp;
asm volatile ( "in %0, %1" "\n\t"
"andi %0, %2" "\n\t"
"out %1, %0" "\n\t"
: "=&r" (temp)
: "I" (&mPort), "I" (inverse)
);
#endif
}
src/AVRPort.h: In member function 'virtual msg_t BlinkThread::entry()':
src/AVRPort.h:61: warning: asm operand 2 probably doesn't match constraints
src/AVRPort.h:61: error: impossible constraint in 'asm'
If instead of asm I use the expression
mPort &= ~inPins;
the generated assembler looks like this:
18: 80 91 02 00 lds r24, 0x0002
1c: 8b 7f andi r24, 0xFB ; 251
1e: 8a 83 std Y+2, r24 ; 0x02
Which is certainly less space-efficient; I don't know if also runs slower. It
clobbers more registers, too.
Ideally, I'd fix the inline asm, but I don't have much experience with it, and
I'm not sure exactly what I'm doing wrong.
--
Rick
- [avr-chat] Inline assembler warning: asm operand 2 probably doesn't match constraints,
Rick Mann <=