Search code examples
assemblyavratmega

AVR Byte Storage


Hey I'm new to assembly programming with the AVR family but familiar with uC's like the PIC. What I'm confused about right now is the following excerpt from some sample code.

.dseg
.org 0x0100

RegA: .byte 1
RegB: .byte 1
RegC: .byte 1

....

With the PIC family, you specify the address of the labeled register right after defining the label. In the AVR family however with this syntax I'm not sure where RegC is stored. I understand that the SRAM on the ATMega328P is 16-bits wide so this means that RegA and RegB are stored at 0x0100? And as a result the stack pointer automatically increments and stores RegC at the address 0x0101?


Solution

  • It looks this code defines three one-byte variables in data memory (RAM).

    • RegA would be stored at 0x0100 (this is the address of a byte in RAM, not a 16-bit word or anything like that)
    • RegB would be stored at 0x0101
    • RegC would be stored at 0x0102

    If you are able to compile and link this code, you should be able to look at the disassembly listing or map file to verify this.