Answer the question
In order to leave comments, you need to log in
How to set the value of a variable in SRAM when it is declared?
Only recently I began to study the AVR assembler, under the Atmega8 controller, using the AVR-GCC compiler. And the question arose - how can you set the value of a variable in SRAM when declaring in the .data section? Under the AVRASM2 compiler, this is done, as I understand it, something like this:
.DSEG
variable: .byte 0xff
.data
variable: .byte 0xff
AVR Memory Usage
----------------
Device: atmega8
Program: 64 bytes (0.8% Full)
(.text + .data + .bootloader)
Data: 2 bytes (0.2% Full)
(.data + .bss + .noinit)
Disassembly of section .data:
00800060 <_edata-0x2>:
800060: ff 00 .word 0x00ff ; ????
Answer the question
In order to leave comments, you need to log in
In fact, at address 0x0060 there is some kind of garbage that has nothing to do with what I wanted to put there.
__do_copy_data
and __do_clear_bss
into each translation unit that defines objects in the .data and .bss sections, respectively. In hand-written assembler files, they can be mentioned explicitly.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question