1 \ *****************************************************************************
2 \ * Copyright (c) 2004, 2008 IBM Corporation
3 \ * All rights reserved.
4 \ * This program and the accompanying materials
5 \ * are made available under the terms of the BSD License
6 \ * which accompanies this distribution, and is available at
7 \ * http://www.opensource.org/licenses/bsd-license.php
10 \ * IBM Corporation - initial implementation
11 \ ****************************************************************************/
14 \ Hex dump facilities.
21 : .char ( c -- ) dup bl 7f within 0= IF drop [char] . THEN emit ;
23 cr dump-cur dup 8 0.r [char] : emit 10 /dump / 0 DO
24 space dump-cur dump-first dump-last within IF
25 dump-cur 'dump execute /dump 2* 0.r ELSE
26 /dump 2* spaces THEN dump-cur /dump + to dump-cur LOOP
27 /dump 1 <> IF drop EXIT THEN
29 10 0 DO dump-cur dump-first dump-last within IF
30 dump-cur 'dump execute .char ELSE space THEN dump-cur 1+ to dump-cur LOOP ;
31 : (dump) ( addr len reader size -- )
32 to /dump to 'dump bounds /dump negate and to dump-first to dump-last
33 dump-first f invert and to dump-cur
34 base @ hex BEGIN dump-line dump-cur dump-last >= UNTIL base ! ;
35 : du ( -- ) dump-last 100 'dump /dump (dump) ;
36 : dump ['] c@ 1 (dump) ;
37 : wdump ['] w@ 2 (dump) ;
38 : ldump ['] l@ 4 (dump) ;
39 : xdump ['] x@ 8 (dump) ;
40 : rdump ['] rb@ 1 (dump) ;
41 \ : iodump ['] io-c@ 1 (dump) ;
42 \ : siodump ['] siocfg@ 1 (dump) ;