Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / fm / meta / meta1.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: meta1.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 ============================================
42id: @(#)meta1.fth 2.9 03/12/08 13:22:34
43purpose:
44copyright: Copyright 1990-2003 Sun Microsystems, Inc. All Rights Reserved
45copyright: Copyright 1985-1990 Bradley Forthware
46copyright: Use is subject to license terms.
47
48\ Meta compiler. Host system: F83 Target system: 68K F83
49
50\ Variables and store don't work very well. Use "is" instead.
51create meta.f ," meta1.fth 2.9 03/12/08"
52
53only forth also definitions
54\
55\ These are OK to leave permenantly installed because the meta compiler
56\ never gets saved into an image
57\
58headers
59defer meta-xref-on ' noop is meta-xref-on
60defer meta-xref-off ' noop is meta-xref-off
61[ifnexist] xref-header-hook
62\ Bootstrapping..
63defer xref-header-hook ' noop is xref-header-hook
64defer xref-find-hook ' noop is xref-find-hook
65[then]
66[ifnexist] xref-hide-hook
67\ Bootstrapping..
68defer xref-hide-hook ' noop is xref-hide-hook
69defer xref-reveal-hook ' noop is xref-reveal-hook
70[then]
71[ifnexist] xref-string-hook
72\ Bootstrapping
73defer xref-string-hook ' noop is xref-string-hook
74[then]
75
76vocabulary meta
77vocabulary symbols
78vocabulary labels
79
80\ This will be set later
810 constant compilation-base
82
830 constant origin-t
84variable dp-t
85variable current-t
86variable context-t
87
88\ Return the host address where the given target address is being compiled
89: >hostaddr ( target-address -- host-address )
90 origin-t - compilation-base +
91;
92: hostaddr> ( host-address -- target-address )
93 compilation-base - origin-t +
94;
95
96: allot-t ( #bytes -- ) dp-t +! ;
97
98: here-t ( -- target-adr ) dp-t @ ;
99
100: target-image ( l.adr -- ) is compilation-base ;
101: org ( adr -- ) dup dp-t ! is origin-t ;
102
103\ voc-ptr is the address of the first thread
104
105: $sfind ( adr len -- acf [ -1 | 1 ] | adr len false )
106 $canonical ['] symbols $vfind
107;
108
109\ Version that allows target variables and constants to be interpreted
110\ : xconstant ( n -- )
111\ current link@ >r context link@ >r [compile] labels definitions
112\ lastword canonical "create ,
113\ r> context link! r> current link!
114\ does> @
115\ ;
116\
117\ Version that doesn't
118: xconstant ( n -- ) drop ;
119
120\ This is a version of create that creates a word in a specific vocabulary.
121\ The vocabulary is passed as an explicit argument. This would be somewhat
122\ easier if the search-order stuff were implemented in a less "hard-wired"
123\ manner.
124
125: $vcreate ( adr len voc-cfa -- )
126 context link@ >r current link@ >r warning @ >r
127 context link! definitions
128 warning off
129 $create
130 r> warning ! r> current link! r> context link!
131;
132\ : vcreate ( str voc-cfa -- ) count $vcreate ;