avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] inline ASM newbie problem


From: Marco Randazzo
Subject: Re: [avr-gcc-list] inline ASM newbie problem
Date: Tue, 11 Oct 2005 18:47:07 +0200

Yeah! It works, thanks!
I also discovered that if I write this:
 
: //output operands
: "r" (servo_prot_offset) //input operands
: "r18", "r24", "r25" //constraints
 
the compiler avoids to use r24, r25, r26 for %0 and chooses r19 for %0, so I can avoid to push/pop those registers in my routine.
But... for r19 I can be sure that the compiler is smart enough to choose a register (r19) that is not currently used by the code before/after my "asm volatile" routine, am I right?
 
Marco
 
----- Original Message -----
Sent: Tuesday, October 11, 2005 1:28 PM
Subject: RE: [avr-gcc-list] inline ASM newbie problem

Hi again!

 

Using the “l” constraint might solve the problem…

The following:

 

uint8_t servo_prot_offset;

 

  asm volatile (

   "\n"

   "PUSH    R18" "\n\t"

   "PUSH    R24" "\n\t"

   "PUSH    R25" "\n\t"

   "        LDI     R24,0x00" "\n\t"

   "        LDI     R25,0x00" "\n\t"

   "l1   :  ADIW    R24,0x01" "\n\t"

   "        LDI     R18,0x06" "\n\t"

   "        CP       R24,%0  " "\n\t"

   "        CPC     R25,R18 " "\n\t"

   "        BRCS    l1"       "\n\t"

   "POP     R25" "\n\t"

   "POP     R24" "\n\t"

   "POP     R18" "\n\t"

   : //output operands

   : "l" (servo_prot_offset) //input operands

  );

 

Generates:

…

                    LDI     R24,0x00

                    LDI     R25,0x00

            l1   :  ADIW R24,0x01

                    LDI     R18,0x06

                    CP     R24,r15 

                    CPC   R25,R18

                    BRCS l1

…

 

Please note I haven’t thought thru what you’re trying to do so it might be awfully wrong!

 

/niklo

 


From: address@hidden [mailto:address@hidden On Behalf Of Marco Randazzo
Sent: den 10 oktober 2005 08:25
To: address@hidden
Subject: [avr-gcc-list] inline ASM newbie problem

 

Hi, I'm new to asm inline programming.

I would like to pass a simple input value to an asm routine but compiler says "error: impossible constraint in `asm'" and I can't understand what I've to do. Here is my code:

 

  uint8_t servo_prot_offset;

    [...]

  asm volatile (
   "\n"
   "PUSH    R18" "\n\t"
   "PUSH    R24" "\n\t"
   "PUSH    R25" "\n\t"
   "        LDI     R24,0x00" "\n\t"
   "        LDI     R25,0x00" "\n\t"
   "l1   :  ADIW    R24,0x01" "\n\t"
   "        LDI     R18,0x06" "\n\t" 
   "        CPI     R24,%0  " "\n\t"  <--- HERE I WANT COMPARE R24 WITH THE VALUE OF servo_prot_offset

   "        CPC     R25,R18 " "\n\t"
   "        BRCS    l1"       "\n\t"
   "POP     R25" "\n\t"
   "POP     R24" "\n\t"
   "POP     R18" "\n\t"
   : //output operands
   : "M" (servo_prot_offset) //input operands

  );

 

Thanks in advance,

Marco Randazzo


reply via email to

[Prev in Thread] Current Thread [Next in Thread]