[Top][All Lists]

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

Re: [avr-gcc-list] Someting I don"t understand with PGM_P et pgm_read_by

From: Joerg Wunsch
Subject: Re: [avr-gcc-list] Someting I don"t understand with PGM_P et pgm_read_byte_far()
Date: Wed, 2 Mar 2005 12:36:08 +0100 (MET)

Simon Han <address@hidden> wrote:

> I might be wrong, but I recalled one post 1 year ago talking about
> the problem.  The problem is that gcc wants the address be "byte
> addressable" while Atmega128 program flash should be addressed by
> word (2 bytes).

Nope, the AVR has two different addressing modi for ROM.  It uses word
addressing when considering ROM as a code pointer target (JMP, CALL,
IJMP etc.), and it uses byte addressing (even though the ROM is
supposedly organized by 16-bit words) when considering it as a data
pointer target (LPM, ELPM, SPM).  That's why you need to consider
RAMPZ for code ROM access on the ATmega128 yet you don't have to do
anything to jump through the entire ROM with your program code using
16-bit pointers.  That's also why the assembler needs that pm operator
(program memory address).

To further add to the confusion, Atmel appears to always refer to ROM
locations in terms of 16-bit units (even though it could occasionally
be addressed in terms of 8-bit units), while the GNU toolchain
externally counts in 8-bit units, regardless of whether the target
uses 8-bit, 16-bit, 32-bit, or 64-bit words.  This is what you can
observe in all command-line options (-Wl,-T ...).

J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/

reply via email to

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