Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / fm / lib / dump.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: dump.fth
4\
5\ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6\
7\ - Do no alter or remove copyright notices
8\
9\ - Redistribution and use of this software in source and binary forms, with
10\ or without modification, are permitted provided that the following
11\ conditions are met:
12\
13\ - Redistribution of source code must retain the above copyright notice,
14\ this list of conditions and the following disclaimer.
15\
16\ - Redistribution in binary form must reproduce the above copyright notice,
17\ this list of conditions and the following disclaimer in the
18\ documentation and/or other materials provided with the distribution.
19\
20\ Neither the name of Sun Microsystems, Inc. or the names of contributors
21\ may be used to endorse or promote products derived from this software
22\ without specific prior written permission.
23\
24\ This software is provided "AS IS," without a warranty of any kind.
25\ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
26\ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
27\ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
28\ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
29\ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
30\ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
31\ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
32\ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
33\ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
34\ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
35\ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
36\
37\ You acknowledge that this software is not designed, licensed or
38\ intended for use in the design, construction, operation or maintenance of
39\ any nuclear facility.
40\
41\ ========== Copyright Header End ============================================
42\ @(#)dump.fth 2.6 95/04/19
43\ From Perry/Laxen, largely verbatim
44\ Copyright 1985-1990 Bradley Forthware
45
46\ The dump utility gives you a formatted hex dump with the ascii
47\ text corresponding to the bytes on the right hand side of the
48\ screen. In addition you can use the SM word to set a range of
49\ memory locations to desired values. SM displays an address and
50\ its contents. You can go forwards or backwards depending upon
51\ which character you type. Entering a hex number changes the
52\ contents of the location. DL can be used to dump a line of
53\ text from a screen.
54
55decimal
56
57only forth also hidden also definitions
58
59headers
60defer dc@ ' c@ is dc@
61headerless
62: .2 (s n -- ) <# u# u# u#> type space ;
63: d.2 (s addr len -- ) bounds ?do i dc@ .2 loop ;
64: emit. (s char -- )
65 d# 127 and dup printable? 0= if drop ascii . then emit
66;
67: emit.ln (s addr len -- )
68 bounds ?do i dc@ emit. loop
69;
70: dln (s addr --- )
71 ??cr dup n->l 8 u.r 2 spaces 8 2dup d.2 space
72 over + 8 d.2 space
73 d# 16 emit.ln
74;
75
76: ?.n (s n1 n2 -- n1 )
77 2dup = if ." \/" drop else 2 .r then space ;
78: ?.a (s n1 n2 -- n1 )
79 2dup = if ." v" drop else 1 .r then ;
80
81: .head (s addr len -- addr' len' )
82 ??cr over d# 16 >> d# 16 >> ?dup if
83 8 u.r 2 spaces
84 else
85 10 spaces
86 then
87 swap dup d# -16 and swap d# 15 and
88 8 0 do i ?.n loop space d# 16 8 do i ?.n loop
89 space d# 16 0 do i ?.a loop rot +
90;
91headers
92
93: (dump) ( addr len -- )
94 base @ -rot hex .head ( addr len )
95 dup 0= if 1+ then
96 bounds do i dln exit? ?leave 16 +loop base !
97;
98also forth definitions
99
100: dump ( addr len -- ) ['] c@ is dc@ (dump) ;
101: du ( addr -- addr+64 ) dup d# 64 dump d# 64 + ;
102
103only forth also definitions