[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-chat] Inline assembler warning: asm operand 2 probably doesn't
From: |
Rick Mann |
Subject: |
Re: [avr-chat] Inline assembler warning: asm operand 2 probably doesn't match constraints |
Date: |
Tue, 8 Feb 2011 13:37:27 -0800 |
On Feb 8, 2011, at 05:45:18, Joerg Wunsch wrote:
> In article <address@hidden> you write:
>
>> http://pastebin.com/AwuY28F9
>
> "Unknown paste ID"
>
> Can't you just attach it?
As a file, I could have. This seemed easier, but I must've deleted the paste.
http://pastebin.com/AVSapiFz
>> uint8_t inverse = ~inPins;
>
>> : "I" (&mPort), "I" (inverse)
>
> The "IO port" constraint ("I") certainly cannot work here for
> "inverse".
>
> I think you need a plain "Register" ("r") constraint, so GCC will
> perform the bit complement for you, and then passes the register
> it used for the complement down to the inline asm statement.
Hrm. I tried "r", but got:
src/AVRPort.o: In function `AVRPort::clear(unsigned char)':
/Users/rmann/Desktop/TreasureBox/trunk/Firmware/src/AVRPort.h:61: undefined
reference to `r24'
Here's the disassembly of AVRPort.o (you can see the only thing in AVRPort.cpp
is the test() function at the bottom). It seems to have generated a temporary
for inverse, and not used it. Why it gets that link error is beyond me.
----------------
src/AVRPort.o: file format elf32-avr
Disassembly of section .text:
00000000 <_Z4testv>:
asm volatile ( "in %0, %1" "\n\t"
"andi %0, %2" "\n\t"
"out %1, %0" "\n\t"
: "=&r" (temp)
: "I" (&mPort), "r" (inverse)
);
0: 8e ef ldi r24, 0xFE ; 254
2: 92 b1 in r25, 0x02 ; 2
4: 90 70 andi r25, 0x00 ; 0
6: 92 b9 out 0x02, r25 ; 2
void
test()
{
gPortA->clear(1);
}
8: 08 95 ret
----------------