avr-libc-dev
[Top][All Lists]
Advanced

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

[avr-libc-dev] Constant address to program memory in C


From: Shaun Jackman
Subject: [avr-libc-dev] Constant address to program memory in C
Date: Thu, 22 Nov 2007 12:55:37 -0700

I've been bitten twice now by this little gotcha:

#define BOOTLOADER 0x1f00
void goto_bootloader(void)
{
        goto *BOOTLOADER;
}

The above  code is buggy. The worst of it is, it will work just fine
until your application program becomes just a little bigger than it
used to be. It should be...

#define BOOTLOADER 0x1f00
#define PM(a) ((a) >> 1)
void goto_bootloader(void)
{
        goto *PM(BOOTLOADER);
}

The assembler has a pm(a) operator for this very reason. It would be
useful for avr-libc to have a similar macro.

Cheers,
Shaun




reply via email to

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