User Tools

Site Tools


en:words:hier

idump edump dump

In microcontrolern like AVR Atmega there are three different types off memory - RAM, Flash and Eeprom. Use dump in RAM, idump for instruction memory (flash) and edump for eeprom. There are minitools as well. Use ? to inspect content of an single address in RAM, i? and e? do the same in instruction memory and eeprom. If you like to see ascii values as well, use ?? i?? and e?? instead. See example to get an idea of how to use these minitools in amforth on AVR atmega.

> : test  ." hallo" ;  test 
hallo ok 
> ' test 10 - 20 idump 
 C58   4B2 1E98 1DC3 1E63 1E63  797 1C8D   72 
 C60    98 1E98 1EAD 1DC3 1E5C 1E5C  797 1C41 
 C68  7404 7365   74 1FEB 1C0A  235 6805 6C61 
 C70  6F6C  261 1C41 FFFF FFFF FFFF FFFF FFFF 
 C78  FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF  ok 

> c68 i?? 
7404 t.  ok 
> c70 i?? 
6F6C ol  ok 

forth soucre code

 
hex 

( item -- ) 
: .item     4 u.r space ;  \ asm ok 

( addr -- ) 
: i?     i@ .item ; 
: e?     e@ .item ; 
: ?       @ .item ; 

( addr n -- addr+n ) 
: .icells   0 do  dup i?    1+ loop ; \ flash 
: .ecells   0 do  dup e? cell+ loop ; \ eeprom 
: .rcells   0 do  dup  ? cell+ loop ; \ ram 

( addr -- ) 
: .addr     cr .item space ; 

( addr1 len1 -- addr2 len2 ) 
: trim     swap fff8 and swap 7 or ; 

( addr len -- ) \ numbers are in hex. 
: idump   trim 0 ?do   dup .addr   8 .icells   8 +loop ; 
: edump   trim 0 ?do   dup .addr   8 .ecells  10 +loop ; 
:  dump   trim 0 ?do   dup .addr   8 . cells  10 +loop ; 

\ tested ok on amforth-2.9 06.10.2008 mk 

\ type a character 
: .ascii ( c -- )  7F and dup 20 < if drop 2E then emit ; \ ignore bit8 

\ type content of cell and its ascii values. 
: .aa  ( addr -- )  dup ff00 and ff / .ascii  00ff and .ascii  space ; 

\ inspect an address 
( addr -- ) 
: i??     i@ dup .item .aa ; 
: e??     e@ dup .item .aa ; 
:  ??      @ dup .item .aa ; 

\ tested ok on amforth-2.9 08.10.2008 mk 
\ ca. 222 cells of flash 
\ finis 
en/words/hier.txt · Last modified: 2013-06-06 21:26 by 127.0.0.1