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

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

Re: [avr-gcc-list] inline assembler problem


From: Peter N Lewis
Subject: Re: [avr-gcc-list] inline assembler problem
Date: Fri, 17 Aug 2001 16:29:52 +0800

The varible "bit" is an input not an output parameter !!
So it is in the wrong line of the __asm__ __volatile__ statement !
I think you have to write:

        __asm__ __volatile__ (
                "code...." "\n\t"
                .
                .
                "code...." "\n\t"
                : "=r" (crchi), "=r" (crclo)
                : "0" (crchi), "1" (crclo), "=r" (bit)
                : "r24", ....   << registers that may be modified and
                                   the compiler has to concern about !
        );

Further: what is "=&r" ? I only know "=r", and if I want to reference
a memory (pointer), then "=m" is used.

Read the GCC-AVR Inline Assembler Cookbook by Harald Kipp

http://www.egnite.de/ethernut/GCCAVRInlAsmCB.pdf

=&r means that the register parameter cannot be the same as any input register - you want this if you are going to write to it before you have finished with any input parameters. The list (from the above document) is:

Constraint Used for Range
a Simple upper registers r16 to r23
b Base pointer registers pairs y,z
d Upper register r16 to r31
e Pointer register pairs x,y,z
G Floating point constant 0.0
I 6-bit positive integer constant 0 to 63
J 6-bit negative integer constant -63 to 0
K Integer constant 2 (Program counter?)
L Integer constant 0
l Lower registers r0 to r15
M 8-bit integer constant 0 to 255
N Integer constant -1
O Integer constant 8, 16, 24
P Integer constant 1
r Any register r0 to r31
t Temporary register r0
w Special upper register pairs r24, r26, r28, r30
x Pointer register pair X x (r27:r26)
y Pointer register pair Y y (r29:r28)
z Pointer register pair Z z (r31:r30)

Enjoy,
   Peter.

--
<http://www.interarchy.com/>  <ftp://ftp.interarchy.com/interarchy.hqx>



reply via email to

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