[Top][All Lists]

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

[avr-libc-dev] Program memory macros and -mint8

From: Nils Kristian Strom
Subject: [avr-libc-dev] Program memory macros and -mint8
Date: Fri, 08 Nov 2002 23:44:59 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2b) Gecko/20021018

Hello again

Some more questions about -mint8 support (although not supported)

I wonder why the program memory macros use this cast for the (16-bit) address:

unsigned short __addr16 = (unsigned short)(addr);

The problem is that sizeof(unsigned short)==2 when compiling "normally" (without -mint8), and sizeof(unsigned short)==1 when compiling with -mint8.

I have written program memory macros that uses (void*), (char*) etc. to hold the address, which works flawlessly for both -mint8 and 16 bit integers.

Example for the __LPM_enhanced__ function in progmem.h :

#define __LPM_enhanced_2__(addr) ({             \
        char * __addr16 = (char *)(addr);       \
        unsigned char __result;                 \
        __asm__ (                               \
                "lpm %0, Z"                   \
                : "=r" (__result)             \
                : "z" (__addr16)              \
        );                                      \
        __result;                               \

I wonder why this approach is not used througout avr-libc, to make support for 8 bit ints less clumersome.

Are there any issues I fail to understand ?

  Nils Strom

reply via email to

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