GCC inline asm -- HELP!!!!

Hi, On the following line

asm ("sbi %0, %1": "=I"(PORTC):"I" (4));

I keep getting impossible constraint.

The problem seems to be that no constraint (letter) (I tried them all) seem to be compatible with the lvalue of PORTC (or any other port). But if you diable the lvalue mechanism in sfr_defs.h then it complaints understandibly about that output needs an lvalue. Is there a way around this problem?

I am using studio 4 version 4.12 + service pack 4 and winAVR 2008 06 10.

Reply to
HansMartinasm
Loading thread data ...

It's a good idea to specify in your posts that you are using the AVR - gcc is available for dozens of targets.

PORTC is defined as a macro that boils down to a cast involving pointers to volatile bytes. You can't pass that as a value to inline assembly, as it can only be used in certain contexts (you can take its address and pass that, if you really wanted to).

However, this is all fairly irrelevant - using inline assembly like that is *not* how you set a port bit using avr-gcc. It would definitely be a good idea to read some of the documentation and look at some of the examples before you waste any more of your time:

formatting link

For reference, the way to pass PORTC to an inline assembly function is given in the FAQ:

formatting link

Reply to
David Brown

If you want a sbi in an AVR using gcc version 4.x, try

PORTC |= (1

Reply to
Tauno Voipio

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.