[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Assembler error message
From: |
Jens Andersen |
Subject: |
Re: [avr-gcc-list] Assembler error message |
Date: |
Fri, 16 Mar 2001 23:28:51 +0100 |
Hi Robert,
I think that your problems come from the fact that the CBR instruction
requires
a register as the target, and as you want to modify a variable, this
wont work.
I assume that what you want to do, is to clear one or more bits in a
variable,
using a bit mask, so maybe you could try this.
//IR_Status variable
#define IR_Avail 128
volatile unsigned char IR_Status = 0x20;
#define CLEARBIT_CONST(var, mask) (var &= ~mask)
void main(void)
{
CLEARBIT_CONST(IR_Status, IR_Avail);
}
Compiled with option -O2 this generates the following assembler code.
10:test.c **** CLEARBIT_CONST(IR_Status, IR_Avail);
56 .stabn 68,0,10,.LM2-main
57 .LM2:
58 0008 8091 0000 lds r24,IR_Status
59 000c 8F77 andi r24,lo8(127)
60 000e 8093 0000 sts IR_Status,r24
11:test.c **** }
I think that this is as best as you can get it. :)
Best regards
Jens Andersen
Robert Rozman wrote:
>
> Hello,
>
> thanks for response. Only one short question:
> - I'd like macro CLEARBIT_CONST to influence value of variable 'var'. Do I
> have to add something to output section of macro too - as it is now, it
> seems like it doesn't have any output or influence on variable.
>
> Thanks in advance,
>
> Robert Rozman
>
> -----Izvorno sporoèilo-----
> Od: Denis Chertykov <address@hidden>
> Za: Robert Rozman <address@hidden>
> Kp: address@hidden <address@hidden>
> Datum: 16. marec 2001 20:17
> Zadeva: Re: [avr-gcc-list] Assembler error message
>
> >Try to use:
> >
> >#define CLEARBIT_CONST(var,mask) \
> > asm volatile (\
> > "andi %0, lo8(0xff - (%1)) "\
> > : /* no outputs */\
> > : "r" ((u08) (var)), \
> > "i" ((u08) (mask)) \
> > )
> >
> >
> >Or:
> >
> >#define CLEARBIT_CONST(var,mask) \
> > asm volatile (\
> > "cbr %0, %1) "\
> > : /* no outputs */\
> > : "r" ((u08) (var)), \
> > "i" ((mask)) /* <-------- type casting to u08 removed */ \
> > )
>
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://avr.jpk.co.nz/mailman/listinfo/avr-gcc-list