Hi David,

 > Just noticed something with the @i word with addressing.
>
>
>> : strng s" ABCDEFGHIJKLM" ;
>
> ok
>
>> ' strng 3 + @i .
>
> 4241 ok
>
>> ' strng 4 + @i .
>
> 4443 ok
>
>> ' strng 5 + @i .
>
> 4645 ok
>
>>
>
>
> It looks like there is an implied 'cells' when using @i. Is this correct?

The picture is a bit more complex. First the trivial things:
The Atmegas use a 16bit opcode schema. Every machine instruction
is basically a 16bit number. The program counter register (the
pointer for the machine code) that points to the next machine
instruction is incremented by 1 and points to the next flash cell, at 
16bit distance. So I think its ok to assume, that the flash has
16bit per address unit, there is a 8bit access too, but
that is not the "natural" size of it. EEPROM and RAM have 8bits per
address unit.

When I designed amforth, I wanted to keep the specific
elements. Having a 16bit forth system, its obvious that I use
one address unit to get the flash contents and two consecutive
address units for EEPROM and RAM (Endianess is basically determined
by the few 16bit ports in the IO region). They all end up in a
16bit number. Same with the addresses: a 16bit number is a perfect
target for the controller PC register (aka a "far jump" instruction).

Things got a little bit more complex with the 256x controllers but not
that much.


> (what I actually want is c@i - i.e. read 1 byte)

IMHO the @i should be better named a c@i, since c@ is
defined as the fetch of a single address unit content.
But...

Not the complex stuff: You compile strings into the
flash. If you'd have written a single number, nothing
complicated would have happened ;) Just look at the
example code for e.g. the table driven sine function
in the sources.

Strings consist of many bytes for the characters (the xchar
extensions from forth 2012 are not part of amforth, yet). So I
decided to combine two characters into one flash cell and store them 
that way. That makes words like itype and find(-name) a bit more
complex but the savings of flash space are more important.

HTH
Matthias


------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
_______________________________________________
Amforth-devel mailing list for http://amforth.sf.net/
Amforth-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to