Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Re: This assembly oughta be something silly...Thanks

2005-06-16 by John Samperi

At 08:12 AM 16/06/2005, you wrote:
>No, I am not confused.

You are contradicting me. :-D

>The instruction set doc is a little confusing, since I was
>trying to apply previous concepts ( z80, 8085, 8088 etc...)

The problem is that the AVR is a Modified Harvard architecture
device where you have separate data and program busses as against
a Josephson( spell?) architecture (z80, 6800 etc) where you have
a single bus for program and data. i.e. the 68HC711 has ram at
0x00, EEPROM at 0xf800 and Rom at 0xe000 and they can be accessed
with the same instruction as they are on the same memory block. In
fact you can run programs from ram, eeprom ot rom.

With the AVR you can ONLY run programs from the program memory area/bus
(i.e. flash in this case) and both the EEPROM and ram are in the
data area/bus. The modified Harvard architecture allows data to be stored
in the program area.

So the poor assembler needs to know where you want to keep your
string before it can assemble your program.

To tell it where to put things you have 3 directives.

.cseg  (code segment) puts things in program memory space.
That's where your code is located along with any strings or
constants you may want to have.

.cseg
program code etc

strings in flash
Test_str:
     .db      "The old brown fox jumps over the lazy dog."
     .db      0x0d, 0x0a, 0

you need to use LPM to get data from the flash

.dseg (data segment)

this is where you allocate your variable spaces in ram

you were trying to locate your string here. It should really
come up with an error or at least a warning as it cannot be
done at run time.

.dseg ******** can't be done
Test_str:
     .db      "The old brown fox jumps over the lazy dog."
     .db      0x0d, 0x0a, 0

.eseg (EEPROM segment)

you can store data or strings here but as the EEPROM is in a serial
bus you need a small program to get the data out as Dave as shown you.

Armed with the above you are up and running at full speed :-)
Once you get used to the Harvard architecture it's very easy.
I miss not being able to run stuff from ram though.....


Regards

John Samperi

******************************************************
                         Ampertronics Pty. Ltd.
   11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
          Tel. (02) 9674-6495       Fax (02) 9674-8745
                Email: samperi@ampertronics.com.au
                  Website  http://www.ampertronics.com.au
* Electronic Design   * Custom Products   * Contract Assembly
******************************************************

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.