Why does the .data section start 0x100 bytes in?

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

What happens to that first 256 bytes?

Linker script and memory map
Address of section .data set to 0x800100

Thanks,

Alan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

alank2 wrote:
What happens to that first 256 bytes?

Linker script and memory map
Address of section .data set to 0x800100

Look at the data sheet.

Iluvatar is the better part of Valar.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
0x0000..0x001F registers R0 .. R31
0x0020..0x00FF SFRs (ADC, timer, SPI, etc. etc.)
0x0100..RAMEND SRAM memory

This is the memory map that the ST, LD, STS, LDS instructions "see" and operate upon.

The SBI/CBI/IN/OUT instructions "see" the early part of that 0x0020..0x00FF but with a -0x20 offset so they see their own 0x00..0x1F (SBI/CCBI) or 0x00..0x3F (IN/OUT).

When using gdb you can read 0x80003F (for example) to access SREG and so on. Or you could even use 0x800014 to access R20.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I know in SRAM that the first 256 bytes are registers, is this why? Why would it affect flash?

Thanks,

Alan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

.data is NOT in flash! it is in SRAM

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Good point glitch! I'm trying to reconcile a file produced with this vs the flash used:

@"c:\program files\atmel\winavr\bin\avr-nm" -S --size-sort -tdec test.elf >scanelf.txt

00000190 00000006 T main

This is an empty project. A main() and nothing in it. It says 6 bytes for the main, but yet it is started at offset 190. What happened to that first 190 bytes?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

alank2 wrote:
What happened to that first 190 bytes?
Used for interrupt vectors and C startup code.

PS: Try this

avr-objdump -d -h test.elf

Then you see in detail what it is used for.

Stefan Ernst

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Stefan, they certainly sheds some light on it!!!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Some words about the CRT here:

https://www.avrfreaks.net/index.p...

and (perhaps a better description) here:

https://www.avrfreaks.net/index.p...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks clawson; those links are very informative!!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yeah I keep meaning to make that into a Tutorial though at one stage Eric did ask that I add some words along those line to the AVR-LibC documentation.