aboutsummaryrefslogtreecommitdiff
path: root/forth/forth/avr/xdump.fs
blob: e8a4d93b9d18ffe0ea134218f38d6506559250a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
\ *********************************************************************
\                                                                     *
\    Filename:      xdump.txt                                         *
\    FlashForth:    5.0                                               *
\    MCU            ATmega                                            *
\    Application:                                                     *
\                                                                     *
\    Author:        Mikael Nordman                                    *
\                                                                     *
\ *********************************************************************
\    FlashForth is licensed acording to the GNU General Public License*
\ *********************************************************************

-xdump
marker -xdump

\ Display the contents of raw FLASH memory,
\ given the starting address and length.
\ The address is a raw address without mapping
\ Displays in hex notation and printable ASCII.
\ xdump expects base to be hex.
\

: ud.r <# 1- for # next #s #> type ;
: u.2 $ff and 0 2 ud.r space ;
: xx@ 2dup x@ dup ;

\ Extended Memory Dump.
\
: xdump  ( d.addr +n -- )
   rot $fffe and           \ start on even address
   rot rot $10 u/          \ number of rows to print
   for
     cr 2dup 6 ud.r 
     [char] : emit space   \ display row addr
     $8 for
       xx@ u.2 #8 rshift u.2 2 m+
     next
     -$10 m+               \ wind back the addr
     $8 for                \ print ASCII
       xx@ >pr emit >< >pr emit 2 m+
     next
   next
   2drop cr  ;