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

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

[avr-gcc-list] Addition to Inline ASM FAQ?


From: Grant Stockly
Subject: [avr-gcc-list] Addition to Inline ASM FAQ?
Date: Tue, 10 Sep 2002 13:11:53 -0800

#define loop_until_bit_is_clear(port, bit) \
__asm__ __volatile__ ( \
"L_%=: " "sbic %0, %1" "\n\t" \
"rjmp L_%=" \
: /* no outputs */ \
: "I" ((uint8_t)(port)), \
"I" ((uint8_t)(bit)) \
)

The above is perfectly fine for a macro...but lets say you have a longer routine and many constants? It would be long to put them all at the end. I've found that the below will work fine. I think that this method of defining constants should be noted somewhere.

asm volatile(   "PS1    = 0x00\n\t"
                "PS2    = 0x01\n\t"
                "PS3    = 0x02\n\t"
                "PS4    = 0x03\n\t"
                "ES1    = 0x04\n\t"
                "ES2    = 0x05\n\t"
                "ES3    = 0x06\n\t"
                "ES4    = 0x07\n\t"
                "ESTIM1 = 0x00\n\t"
                "ESTIM2 = 0x01\n\t"
                "ESTIM3 = 0x02\n\t"
                "ESTIM4 = 0x03\n\t"
                "PSTIM1 = 0x04\n\t"
                "PSTIM2 = 0x05\n\t"
                "PSTIM3 = 0x06\n\t"
                "PSTIM4 = 0x07\n\t"
                "PORTB  = 0x18\n\t"
                "PSTIM  = PORTB\n\t"
                "ESTIM  = PORTB\n\t"
"               cli\n\t"                //Disable interrupts while executing
...
...
...

Grant

avr-gcc-list at http://avr1.org



reply via email to

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