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

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

Re: [avr-gcc-list] Include ASM in C


From: Peter N Lewis
Subject: Re: [avr-gcc-list] Include ASM in C
Date: Sat, 9 Jun 2001 11:16:01 +0800

I'm new to AVR GCC and I'm trying to include some assembler instructions in my
C-program.

I'm new too, but so far it is working well.

but when I do the same but replacing the address of the port by its label
like:

asm volatile("sbi PORTB,0x07;");

Well, sbi is already defined in iomacros.h, so in this case, all you would do is:

#include <iomacros.h> (or just io.h since it includes it as well)

then

sbi( PORTB, 7 );

Generally you can do most things without using any direct assembly language.

If you want to know how this is done, just look at the iomacros.h file to see how they did it:

#define __sbi(port, bit)                                \
        __asm__ __volatile__ (                          \
                "sbi %0,%1"                           \
                : /* no outputs */                      \
                : "I" ((uint8_t)(port)),              \
                  "I" ((uint8_t)(bit))                        \
        )

Frankly, I have not yet come to terms with the meanings of the : stuff and % stuff. It is all defined in Harald Kipp's document GCC-AVR Inline Assember Cookbook at http://www.egnite.de/en/main1_1_3.htm.

Enjoy,
   Peter.

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



reply via email to

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