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: Niklas Lövgren
Subject: RE: [avr-gcc-list] inline ASM newbie problem
Date: Tue, 11 Oct 2005 13:25:00 +0200

Hi

Don’t know assembler that much but the following might do what you want:

 

  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" // changed to regular compare…

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

   "        BRCS    l1"       "\n\t"

   "POP     R25" "\n\t"

   "POP     R24" "\n\t"

   "POP     R18" "\n\t"

   : //output operands

   : "r" (servo_prot_offset) //input operands

  );

 

If you look at the output though the compiler uses  r24 for servo_prot_offset too L But it’s maybe something in the right direction J

The “M” constraint can only? Be used for numeric constants it seems.

 

/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]