[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Re: [avr-gcc-list] Allocating variables to a fixed address]
From: |
Robert von Knobloch |
Subject: |
[Re: [avr-gcc-list] Allocating variables to a fixed address] |
Date: |
Wed, 13 May 2009 13:16:31 +0200 |
User-agent: |
Thunderbird 1.5.0.14 (X11/20060911) |
Thanks to all who have helped me to get the best solution.
I have eventually decided that an assembler jump table was really the
best in my application:
/*
******************************************************************************
* Function entry points for independent test routines
******************************************************************************
*/
// Function declarations
void test_lcd_2(PGM_P);
void test_lcd_string(PGM_P);
.
. //Snip/
.
void test_flash_read(uint16_t);
void test_flash_write(uint8_t, uint8_t);
void jumptable(void) __attribute__((__naked__));
FUNCTION_SECTION void jumptable(void)
{
asm ("test_lcd_2: jmp prog_lcd_string2");
asm ("test_lcd_string: jmp prog_lcd_string");
.
. //Snip/av
.
asm ("test_pgm_read_byte: jmp flash_read_byte");
asm ("test_pgm_read_word: jmp flash_read_word");
}
======================================================
Curiously I could not use e.g.
asm ("test_pgm_read_byte: jmp pgm_read_byte");
"undefined reference to 'pgm_read_byte'" although it is defined and in
scope.
Where pgm_read_byte is a library function from avr-libc.
I had to supply a stub function of my own [flash_read_byte()] to, in
turn, call pgm_read_byte()
and then it was happy :-)
Thanks to all,
Robert.