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

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

Re: [avr-libc-dev] How many bits wide is __data_load_end?


From: Joerg Wunsch
Subject: Re: [avr-libc-dev] How many bits wide is __data_load_end?
Date: Wed, 29 Sep 2010 21:42:24 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

As Bob Paddock wrote:

> From the error that I'm getting, below, I belive that __data_load_end
> is only 16 bits wide?

No, obviously it's wider:

 0x0003c370   __data_load_start = LOADADDR (.data)
 0x0003c378   __data_load_end = (__data_load_start + SIZEOF (.data))

(That's from a map file.)

Note that the linker has no notion of what C knows as a "type".  It
only has symbols.

>   uint16_t flash_end_u16 = (uint16_t) &(__data_load_end[0]);

Your problem is that the & operator makes a pointer out of something
else, and pointers in AVR-GCC are fixed to 16 bits in size.  You have
to avoid turning the large integer __data_load_end actually is into a
pointer (syntactically).  I couldn't find any way using C syntax for
this, unless resorting straight to assembly:

static inline uint32_t get_data_load_end(void)
{
  uint32_t tmp;

  asm volatile("ldi %A0, lo8(__data_load_end)" "\n"
               "ldi %B0, hi8(__data_load_end)" "\n"
               "ldi %C0, hlo8(__data_load_end)" "\n"
               "ldi %D0, hhi8(__data_load_end)"
               : "=r"(tmp));
  return tmp;
}


-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)



reply via email to

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