xref: /titanic_52/usr/src/lib/efcode/engine/fcode.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright (c) 2000 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate  * All rights reserved.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate #include <stdio.h>
30*7c478bd9Sstevel@tonic-gate #include <stdlib.h>
31*7c478bd9Sstevel@tonic-gate #include <string.h>
32*7c478bd9Sstevel@tonic-gate #include <ctype.h>
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #include <fcode/private.h>
35*7c478bd9Sstevel@tonic-gate #include <fcode/log.h>
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate int fcode_impl_count = 0;
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate void (*crash_ptr)(fcode_env_t *env) = do_crash;
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate uchar_t
42*7c478bd9Sstevel@tonic-gate next_bytecode(fcode_env_t *env)
43*7c478bd9Sstevel@tonic-gate {
44*7c478bd9Sstevel@tonic-gate 	uchar_t	byte;
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate 	byte = *env->fcode_ptr;
47*7c478bd9Sstevel@tonic-gate 	env->fcode_ptr += env->fcode_incr;
48*7c478bd9Sstevel@tonic-gate 	return (byte);
49*7c478bd9Sstevel@tonic-gate }
50*7c478bd9Sstevel@tonic-gate 
51*7c478bd9Sstevel@tonic-gate ushort_t
52*7c478bd9Sstevel@tonic-gate get_next_token(fcode_env_t *env)
53*7c478bd9Sstevel@tonic-gate {
54*7c478bd9Sstevel@tonic-gate 	ushort_t token = next_bytecode(env);
55*7c478bd9Sstevel@tonic-gate 	if ((token) && (token < 0x10)) {
56*7c478bd9Sstevel@tonic-gate 		token = (token << 8) | next_bytecode(env);
57*7c478bd9Sstevel@tonic-gate 	}
58*7c478bd9Sstevel@tonic-gate 	env->last_fcode = token;
59*7c478bd9Sstevel@tonic-gate 	return (token);
60*7c478bd9Sstevel@tonic-gate }
61*7c478bd9Sstevel@tonic-gate 
62*7c478bd9Sstevel@tonic-gate ushort_t
63*7c478bd9Sstevel@tonic-gate get_short(fcode_env_t *env)
64*7c478bd9Sstevel@tonic-gate {
65*7c478bd9Sstevel@tonic-gate 	ushort_t u;
66*7c478bd9Sstevel@tonic-gate 
67*7c478bd9Sstevel@tonic-gate 	/*
68*7c478bd9Sstevel@tonic-gate 	 * Logical or DOES NOT guarantee left to right evaluation...
69*7c478bd9Sstevel@tonic-gate 	 */
70*7c478bd9Sstevel@tonic-gate 	u = next_bytecode(env) << 8;
71*7c478bd9Sstevel@tonic-gate 	return (u | next_bytecode(env));
72*7c478bd9Sstevel@tonic-gate }
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate uint_t
75*7c478bd9Sstevel@tonic-gate get_int(fcode_env_t *env)
76*7c478bd9Sstevel@tonic-gate {
77*7c478bd9Sstevel@tonic-gate 	uint_t u;
78*7c478bd9Sstevel@tonic-gate 
79*7c478bd9Sstevel@tonic-gate 	/*
80*7c478bd9Sstevel@tonic-gate 	 * Logical or DOES NOT guarantee left to right evaluation...
81*7c478bd9Sstevel@tonic-gate 	 */
82*7c478bd9Sstevel@tonic-gate 	u = get_short(env) << 16;
83*7c478bd9Sstevel@tonic-gate 	return (u | get_short(env));
84*7c478bd9Sstevel@tonic-gate }
85*7c478bd9Sstevel@tonic-gate 
86*7c478bd9Sstevel@tonic-gate void
87*7c478bd9Sstevel@tonic-gate expose_acf(fcode_env_t *env, char *name)
88*7c478bd9Sstevel@tonic-gate {
89*7c478bd9Sstevel@tonic-gate 	if (name == NULL)
90*7c478bd9Sstevel@tonic-gate 		name = "<unknown>";
91*7c478bd9Sstevel@tonic-gate 	EXPOSE_ACF;
92*7c478bd9Sstevel@tonic-gate 	debug_msg(DEBUG_CONTEXT, "CONTEXT:expose_acf: acf: %p/'%s' %p\n",
93*7c478bd9Sstevel@tonic-gate 	    LINK_TO_ACF(env->lastlink), name, env->current);
94*7c478bd9Sstevel@tonic-gate }
95*7c478bd9Sstevel@tonic-gate 
96*7c478bd9Sstevel@tonic-gate void
97*7c478bd9Sstevel@tonic-gate do_code(fcode_env_t *env, int token, char *name, void (*fn)(fcode_env_t *))
98*7c478bd9Sstevel@tonic-gate {
99*7c478bd9Sstevel@tonic-gate 	env->table[token].name = name;
100*7c478bd9Sstevel@tonic-gate 	if (fn == NULL) {
101*7c478bd9Sstevel@tonic-gate 		env->table[token].apf = NULL;
102*7c478bd9Sstevel@tonic-gate 		env->table[token].name = name;
103*7c478bd9Sstevel@tonic-gate 	} else {
104*7c478bd9Sstevel@tonic-gate 		header(env, name, strlen(name), 0);
105*7c478bd9Sstevel@tonic-gate 		env->table[token].apf = (acf_t)HERE;
106*7c478bd9Sstevel@tonic-gate 		COMPILE_TOKEN(fn);
107*7c478bd9Sstevel@tonic-gate 		expose_acf(env, name);
108*7c478bd9Sstevel@tonic-gate 	}
109*7c478bd9Sstevel@tonic-gate }
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate void
112*7c478bd9Sstevel@tonic-gate define_word(fcode_env_t *env, int flag, char *name, void (*fn)(fcode_env_t *))
113*7c478bd9Sstevel@tonic-gate {
114*7c478bd9Sstevel@tonic-gate 	header(env, name, strlen(name), flag);
115*7c478bd9Sstevel@tonic-gate 	COMPILE_TOKEN(fn);
116*7c478bd9Sstevel@tonic-gate 	expose_acf(env, name);
117*7c478bd9Sstevel@tonic-gate }
118*7c478bd9Sstevel@tonic-gate 
119*7c478bd9Sstevel@tonic-gate void
120*7c478bd9Sstevel@tonic-gate end0(fcode_env_t *env)
121*7c478bd9Sstevel@tonic-gate {
122*7c478bd9Sstevel@tonic-gate 	env->interpretting = 0;
123*7c478bd9Sstevel@tonic-gate }
124*7c478bd9Sstevel@tonic-gate 
125*7c478bd9Sstevel@tonic-gate static void
126*7c478bd9Sstevel@tonic-gate end1(fcode_env_t *env)
127*7c478bd9Sstevel@tonic-gate {
128*7c478bd9Sstevel@tonic-gate 	env->interpretting = 0;
129*7c478bd9Sstevel@tonic-gate }
130*7c478bd9Sstevel@tonic-gate 
131*7c478bd9Sstevel@tonic-gate void
132*7c478bd9Sstevel@tonic-gate blit(fcode_env_t *env)
133*7c478bd9Sstevel@tonic-gate {
134*7c478bd9Sstevel@tonic-gate 	fstack_t d = (int)get_int(env);
135*7c478bd9Sstevel@tonic-gate 	PUSH(DS, d);
136*7c478bd9Sstevel@tonic-gate 	literal(env);
137*7c478bd9Sstevel@tonic-gate }
138*7c478bd9Sstevel@tonic-gate 
139*7c478bd9Sstevel@tonic-gate void (*bbranch_ptrs[3])(fcode_env_t *env) = {
140*7c478bd9Sstevel@tonic-gate 	do_bbranch,
141*7c478bd9Sstevel@tonic-gate 	do_bqbranch,
142*7c478bd9Sstevel@tonic-gate 	do_bofbranch
143*7c478bd9Sstevel@tonic-gate };
144*7c478bd9Sstevel@tonic-gate 
145*7c478bd9Sstevel@tonic-gate void
146*7c478bd9Sstevel@tonic-gate branch_common(fcode_env_t *env, short direction, fstack_t which, int doswap)
147*7c478bd9Sstevel@tonic-gate {
148*7c478bd9Sstevel@tonic-gate 	fstack_t *sp;
149*7c478bd9Sstevel@tonic-gate 	token_t *branch_loc;
150*7c478bd9Sstevel@tonic-gate 
151*7c478bd9Sstevel@tonic-gate 	ASSERT((which < 3) && (which >= 0));
152*7c478bd9Sstevel@tonic-gate 	which = (fstack_t)&bbranch_ptrs[which];
153*7c478bd9Sstevel@tonic-gate 	set_temporary_compile(env);
154*7c478bd9Sstevel@tonic-gate 	COMPILE_TOKEN(which);
155*7c478bd9Sstevel@tonic-gate 	if (direction >= 0) {
156*7c478bd9Sstevel@tonic-gate 		bmark(env);
157*7c478bd9Sstevel@tonic-gate 		if (doswap)
158*7c478bd9Sstevel@tonic-gate 			swap(env);
159*7c478bd9Sstevel@tonic-gate 		PUSH(DS, 0);
160*7c478bd9Sstevel@tonic-gate 		compile_comma(env);
161*7c478bd9Sstevel@tonic-gate 	} else {
162*7c478bd9Sstevel@tonic-gate 
163*7c478bd9Sstevel@tonic-gate 		/*
164*7c478bd9Sstevel@tonic-gate 		 * We look down the stack for a branch location
165*7c478bd9Sstevel@tonic-gate 		 * that isn't pointing to zero (i.e. a forward branch label).
166*7c478bd9Sstevel@tonic-gate 		 * We move the first one we find to the top of the stack,
167*7c478bd9Sstevel@tonic-gate 		 * which is what gets compiled in with 'compile_comma'.
168*7c478bd9Sstevel@tonic-gate 		 * Not finding a valid branch label is bad.
169*7c478bd9Sstevel@tonic-gate 		 */
170*7c478bd9Sstevel@tonic-gate 		for (sp = env->ds; sp >= env->ds0; sp--) {
171*7c478bd9Sstevel@tonic-gate 			branch_loc = (token_t *)*sp;
172*7c478bd9Sstevel@tonic-gate 			if (branch_loc && *branch_loc) {
173*7c478bd9Sstevel@tonic-gate 				break;
174*7c478bd9Sstevel@tonic-gate 			}
175*7c478bd9Sstevel@tonic-gate 		}
176*7c478bd9Sstevel@tonic-gate 		if (sp < env->ds0)
177*7c478bd9Sstevel@tonic-gate 			log_message(MSG_ERROR, "branch_common: back: "
178*7c478bd9Sstevel@tonic-gate 			    "no branch loc on stack\n");
179*7c478bd9Sstevel@tonic-gate 		else {
180*7c478bd9Sstevel@tonic-gate 			/* Move branch_loc to top of data stack */
181*7c478bd9Sstevel@tonic-gate 			for (; sp < env->ds; sp++)
182*7c478bd9Sstevel@tonic-gate 				*sp = sp[1];
183*7c478bd9Sstevel@tonic-gate 			*sp = (fstack_t)branch_loc;
184*7c478bd9Sstevel@tonic-gate 		}
185*7c478bd9Sstevel@tonic-gate 		env->level--;
186*7c478bd9Sstevel@tonic-gate 		compile_comma(env);
187*7c478bd9Sstevel@tonic-gate 		temporary_execute(env);
188*7c478bd9Sstevel@tonic-gate 	}
189*7c478bd9Sstevel@tonic-gate }
190*7c478bd9Sstevel@tonic-gate 
191*7c478bd9Sstevel@tonic-gate void
192*7c478bd9Sstevel@tonic-gate bbranch(fcode_env_t *env)
193*7c478bd9Sstevel@tonic-gate {
194*7c478bd9Sstevel@tonic-gate 	short offset = (short)get_short(env);
195*7c478bd9Sstevel@tonic-gate 
196*7c478bd9Sstevel@tonic-gate 	branch_common(env, offset, 0, 1);
197*7c478bd9Sstevel@tonic-gate }
198*7c478bd9Sstevel@tonic-gate 
199*7c478bd9Sstevel@tonic-gate void
200*7c478bd9Sstevel@tonic-gate bqbranch(fcode_env_t *env)
201*7c478bd9Sstevel@tonic-gate {
202*7c478bd9Sstevel@tonic-gate 	short offset = (short)get_short(env);
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate 	branch_common(env, offset, 1, 0);
205*7c478bd9Sstevel@tonic-gate }
206*7c478bd9Sstevel@tonic-gate 
207*7c478bd9Sstevel@tonic-gate void
208*7c478bd9Sstevel@tonic-gate do_quote(fcode_env_t *env)
209*7c478bd9Sstevel@tonic-gate {
210*7c478bd9Sstevel@tonic-gate 	int len;
211*7c478bd9Sstevel@tonic-gate 	uchar_t *strptr;
212*7c478bd9Sstevel@tonic-gate 
213*7c478bd9Sstevel@tonic-gate 	strptr = (uchar_t *)IP;
214*7c478bd9Sstevel@tonic-gate 	len = *strptr;
215*7c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)strptr+1);
216*7c478bd9Sstevel@tonic-gate 	PUSH(DS, len);
217*7c478bd9Sstevel@tonic-gate 	strptr += TOKEN_ROUNDUP(len+2);
218*7c478bd9Sstevel@tonic-gate 	IP = (token_t *)strptr;
219*7c478bd9Sstevel@tonic-gate }
220*7c478bd9Sstevel@tonic-gate 
221*7c478bd9Sstevel@tonic-gate void
222*7c478bd9Sstevel@tonic-gate bquote(fcode_env_t *env)
223*7c478bd9Sstevel@tonic-gate {
224*7c478bd9Sstevel@tonic-gate 	char stringbuff[256];
225*7c478bd9Sstevel@tonic-gate 	int len, count;
226*7c478bd9Sstevel@tonic-gate 	char *strptr;
227*7c478bd9Sstevel@tonic-gate 
228*7c478bd9Sstevel@tonic-gate 	count = len = next_bytecode(env);
229*7c478bd9Sstevel@tonic-gate 	if (env->state) {
230*7c478bd9Sstevel@tonic-gate 		COMPILE_TOKEN(&quote_ptr);
231*7c478bd9Sstevel@tonic-gate 		strptr = (char *)HERE;
232*7c478bd9Sstevel@tonic-gate 		*strptr++ = len;
233*7c478bd9Sstevel@tonic-gate 		while (count--)
234*7c478bd9Sstevel@tonic-gate 			*strptr++ = next_bytecode(env);
235*7c478bd9Sstevel@tonic-gate 		*strptr++ = 0;
236*7c478bd9Sstevel@tonic-gate 		set_here(env, (uchar_t *)strptr, "bquote");
237*7c478bd9Sstevel@tonic-gate 		token_roundup(env, "bquote");
238*7c478bd9Sstevel@tonic-gate 	} else {
239*7c478bd9Sstevel@tonic-gate 		strptr = stringbuff;
240*7c478bd9Sstevel@tonic-gate 		while (count--)
241*7c478bd9Sstevel@tonic-gate 			*strptr++ = next_bytecode(env);
242*7c478bd9Sstevel@tonic-gate 		*strptr = 0;
243*7c478bd9Sstevel@tonic-gate 		push_string(env, stringbuff, len);
244*7c478bd9Sstevel@tonic-gate 	}
245*7c478bd9Sstevel@tonic-gate }
246*7c478bd9Sstevel@tonic-gate 
247*7c478bd9Sstevel@tonic-gate char *
248*7c478bd9Sstevel@tonic-gate get_name(token_t *linkp)
249*7c478bd9Sstevel@tonic-gate {
250*7c478bd9Sstevel@tonic-gate 	char *name, *p;
251*7c478bd9Sstevel@tonic-gate 	flag_t *fptr = LINK_TO_FLAGS(linkp);
252*7c478bd9Sstevel@tonic-gate 	int len;
253*7c478bd9Sstevel@tonic-gate 	char *cptr;
254*7c478bd9Sstevel@tonic-gate 
255*7c478bd9Sstevel@tonic-gate 	if (*fptr & FLAG_NONAME)
256*7c478bd9Sstevel@tonic-gate 		return (NULL);
257*7c478bd9Sstevel@tonic-gate 
258*7c478bd9Sstevel@tonic-gate 	cptr = (char *)fptr;
259*7c478bd9Sstevel@tonic-gate 	len = cptr[-1];
260*7c478bd9Sstevel@tonic-gate 	if (len <= 0 || len > 64 || cptr[-2] != '\0')
261*7c478bd9Sstevel@tonic-gate 		return (NULL);
262*7c478bd9Sstevel@tonic-gate 
263*7c478bd9Sstevel@tonic-gate 	name = cptr - (len+2);
264*7c478bd9Sstevel@tonic-gate 
265*7c478bd9Sstevel@tonic-gate 	for (p = name; *p != '\0'; p++)
266*7c478bd9Sstevel@tonic-gate 		if (!isprint(*p))
267*7c478bd9Sstevel@tonic-gate 			return (NULL);
268*7c478bd9Sstevel@tonic-gate 
269*7c478bd9Sstevel@tonic-gate 	if ((p - name) != len)
270*7c478bd9Sstevel@tonic-gate 		return (NULL);
271*7c478bd9Sstevel@tonic-gate 
272*7c478bd9Sstevel@tonic-gate 	return (name);
273*7c478bd9Sstevel@tonic-gate }
274*7c478bd9Sstevel@tonic-gate 
275*7c478bd9Sstevel@tonic-gate void
276*7c478bd9Sstevel@tonic-gate header(fcode_env_t *env, char *name, int len, flag_t flag)
277*7c478bd9Sstevel@tonic-gate {
278*7c478bd9Sstevel@tonic-gate 	char *strptr;
279*7c478bd9Sstevel@tonic-gate 	flag_t *fptr;
280*7c478bd9Sstevel@tonic-gate 	acf_t dptr;
281*7c478bd9Sstevel@tonic-gate 	extern void add_debug_acf(fcode_env_t *, acf_t);
282*7c478bd9Sstevel@tonic-gate 
283*7c478bd9Sstevel@tonic-gate 	/* Now form the entry in the dictionary */
284*7c478bd9Sstevel@tonic-gate 	token_roundup(env, "header");
285*7c478bd9Sstevel@tonic-gate 	dptr = (acf_t)HERE;
286*7c478bd9Sstevel@tonic-gate 	if (len) {
287*7c478bd9Sstevel@tonic-gate 		int bytes = len+2+sizeof (flag_t);
288*7c478bd9Sstevel@tonic-gate 		dptr = (acf_t)(TOKEN_ROUNDUP(HERE+bytes));
289*7c478bd9Sstevel@tonic-gate 		fptr = LINK_TO_FLAGS(dptr);
290*7c478bd9Sstevel@tonic-gate 		strptr = (char *)fptr - 1;
291*7c478bd9Sstevel@tonic-gate 		*strptr-- = len;
292*7c478bd9Sstevel@tonic-gate 		*strptr-- = 0;
293*7c478bd9Sstevel@tonic-gate 		while (len)
294*7c478bd9Sstevel@tonic-gate 			*strptr-- = name[--len];
295*7c478bd9Sstevel@tonic-gate 	} else {
296*7c478bd9Sstevel@tonic-gate 		dptr++;
297*7c478bd9Sstevel@tonic-gate 		fptr = LINK_TO_FLAGS(dptr);
298*7c478bd9Sstevel@tonic-gate 		flag |= FLAG_NONAME;
299*7c478bd9Sstevel@tonic-gate 	}
300*7c478bd9Sstevel@tonic-gate 	*fptr = flag;
301*7c478bd9Sstevel@tonic-gate 	*dptr = *((acf_t)env->current);
302*7c478bd9Sstevel@tonic-gate 	env->lastlink = dptr++;
303*7c478bd9Sstevel@tonic-gate 	set_here(env, (uchar_t *)dptr, "header");
304*7c478bd9Sstevel@tonic-gate 
305*7c478bd9Sstevel@tonic-gate 	if (name_is_debugged(env, name)) {
306*7c478bd9Sstevel@tonic-gate 		log_message(MSG_INFO, "Turning debug on for %s\n", name);
307*7c478bd9Sstevel@tonic-gate 		add_debug_acf(env, LINK_TO_ACF(env->lastlink));
308*7c478bd9Sstevel@tonic-gate 	}
309*7c478bd9Sstevel@tonic-gate 	debug_msg(DEBUG_HEADER, "Define: '%s' @ %p\n", name, HERE);
310*7c478bd9Sstevel@tonic-gate }
311*7c478bd9Sstevel@tonic-gate 
312*7c478bd9Sstevel@tonic-gate void
313*7c478bd9Sstevel@tonic-gate token_common(fcode_env_t *env, int headered, int visible)
314*7c478bd9Sstevel@tonic-gate {
315*7c478bd9Sstevel@tonic-gate 	char namebuff[32];
316*7c478bd9Sstevel@tonic-gate 	int len, count, token;
317*7c478bd9Sstevel@tonic-gate 	char *strptr, c;
318*7c478bd9Sstevel@tonic-gate 
319*7c478bd9Sstevel@tonic-gate 	strptr = namebuff;
320*7c478bd9Sstevel@tonic-gate 	if (headered) {
321*7c478bd9Sstevel@tonic-gate 		len = next_bytecode(env);
322*7c478bd9Sstevel@tonic-gate 		for (count = 0; count < len; count++) {
323*7c478bd9Sstevel@tonic-gate 			c = next_bytecode(env);
324*7c478bd9Sstevel@tonic-gate 			if (count < sizeof (namebuff))
325*7c478bd9Sstevel@tonic-gate 				*strptr++ = c;
326*7c478bd9Sstevel@tonic-gate 		}
327*7c478bd9Sstevel@tonic-gate 	}
328*7c478bd9Sstevel@tonic-gate 
329*7c478bd9Sstevel@tonic-gate 	if (!visible)
330*7c478bd9Sstevel@tonic-gate 		len = 0;
331*7c478bd9Sstevel@tonic-gate 	*strptr = 0;
332*7c478bd9Sstevel@tonic-gate 	token = get_short(env);
333*7c478bd9Sstevel@tonic-gate 	env->last_token = token;
334*7c478bd9Sstevel@tonic-gate 
335*7c478bd9Sstevel@tonic-gate 	debug_msg(DEBUG_NEW_TOKEN, "Define %s token: '%s' (%x)\n",
336*7c478bd9Sstevel@tonic-gate 	    (visible ? "named" : "headerless"), namebuff, token);
337*7c478bd9Sstevel@tonic-gate 
338*7c478bd9Sstevel@tonic-gate 	header(env, namebuff, len, 0);
339*7c478bd9Sstevel@tonic-gate 	env->table[token].flags = 0;
340*7c478bd9Sstevel@tonic-gate 	if (len) {
341*7c478bd9Sstevel@tonic-gate 		env->table[token].name = MALLOC(len+1);
342*7c478bd9Sstevel@tonic-gate 		strncpy(env->table[token].name, namebuff, len);
343*7c478bd9Sstevel@tonic-gate 	} else {
344*7c478bd9Sstevel@tonic-gate 		env->table[token].name = NULL;
345*7c478bd9Sstevel@tonic-gate 	}
346*7c478bd9Sstevel@tonic-gate 	env->last_token = token;
347*7c478bd9Sstevel@tonic-gate }
348*7c478bd9Sstevel@tonic-gate 
349*7c478bd9Sstevel@tonic-gate void
350*7c478bd9Sstevel@tonic-gate named_token(fcode_env_t *env)
351*7c478bd9Sstevel@tonic-gate {
352*7c478bd9Sstevel@tonic-gate 	token_common(env, 1, env->fcode_debug);
353*7c478bd9Sstevel@tonic-gate }
354*7c478bd9Sstevel@tonic-gate 
355*7c478bd9Sstevel@tonic-gate void
356*7c478bd9Sstevel@tonic-gate external_token(fcode_env_t *env)
357*7c478bd9Sstevel@tonic-gate {
358*7c478bd9Sstevel@tonic-gate 	token_common(env, 1, 1);
359*7c478bd9Sstevel@tonic-gate }
360*7c478bd9Sstevel@tonic-gate 
361*7c478bd9Sstevel@tonic-gate void
362*7c478bd9Sstevel@tonic-gate new_token(fcode_env_t *env)
363*7c478bd9Sstevel@tonic-gate {
364*7c478bd9Sstevel@tonic-gate 	token_common(env, 0, 0);
365*7c478bd9Sstevel@tonic-gate }
366*7c478bd9Sstevel@tonic-gate 
367*7c478bd9Sstevel@tonic-gate void
368*7c478bd9Sstevel@tonic-gate offset16(fcode_env_t *env)
369*7c478bd9Sstevel@tonic-gate {
370*7c478bd9Sstevel@tonic-gate 	env->offset_incr = 2;
371*7c478bd9Sstevel@tonic-gate }
372*7c478bd9Sstevel@tonic-gate 
373*7c478bd9Sstevel@tonic-gate void
374*7c478bd9Sstevel@tonic-gate minus_one(fcode_env_t *env)
375*7c478bd9Sstevel@tonic-gate {
376*7c478bd9Sstevel@tonic-gate 	PUSH(DS, -1);
377*7c478bd9Sstevel@tonic-gate }
378*7c478bd9Sstevel@tonic-gate 
379*7c478bd9Sstevel@tonic-gate void
380*7c478bd9Sstevel@tonic-gate zero(fcode_env_t *env)
381*7c478bd9Sstevel@tonic-gate {
382*7c478bd9Sstevel@tonic-gate 	PUSH(DS, 0);
383*7c478bd9Sstevel@tonic-gate }
384*7c478bd9Sstevel@tonic-gate 
385*7c478bd9Sstevel@tonic-gate void
386*7c478bd9Sstevel@tonic-gate one(fcode_env_t *env)
387*7c478bd9Sstevel@tonic-gate {
388*7c478bd9Sstevel@tonic-gate 	PUSH(DS, 1);
389*7c478bd9Sstevel@tonic-gate }
390*7c478bd9Sstevel@tonic-gate 
391*7c478bd9Sstevel@tonic-gate void
392*7c478bd9Sstevel@tonic-gate two(fcode_env_t *env)
393*7c478bd9Sstevel@tonic-gate {
394*7c478bd9Sstevel@tonic-gate 	PUSH(DS, 2);
395*7c478bd9Sstevel@tonic-gate }
396*7c478bd9Sstevel@tonic-gate 
397*7c478bd9Sstevel@tonic-gate void
398*7c478bd9Sstevel@tonic-gate three(fcode_env_t *env)
399*7c478bd9Sstevel@tonic-gate {
400*7c478bd9Sstevel@tonic-gate 	PUSH(DS, 3);
401*7c478bd9Sstevel@tonic-gate }
402*7c478bd9Sstevel@tonic-gate 
403*7c478bd9Sstevel@tonic-gate void
404*7c478bd9Sstevel@tonic-gate version1(fcode_env_t *env)
405*7c478bd9Sstevel@tonic-gate {
406*7c478bd9Sstevel@tonic-gate 	env->fcode_incr = 1;
407*7c478bd9Sstevel@tonic-gate }
408*7c478bd9Sstevel@tonic-gate 
409*7c478bd9Sstevel@tonic-gate static void
410*7c478bd9Sstevel@tonic-gate start0(fcode_env_t *env)
411*7c478bd9Sstevel@tonic-gate {
412*7c478bd9Sstevel@tonic-gate 	env->fcode_incr = 1;
413*7c478bd9Sstevel@tonic-gate }
414*7c478bd9Sstevel@tonic-gate 
415*7c478bd9Sstevel@tonic-gate static void
416*7c478bd9Sstevel@tonic-gate start1(fcode_env_t *env)
417*7c478bd9Sstevel@tonic-gate {
418*7c478bd9Sstevel@tonic-gate 	env->fcode_incr = 1;
419*7c478bd9Sstevel@tonic-gate }
420*7c478bd9Sstevel@tonic-gate 
421*7c478bd9Sstevel@tonic-gate void
422*7c478bd9Sstevel@tonic-gate start2(fcode_env_t *env)
423*7c478bd9Sstevel@tonic-gate {
424*7c478bd9Sstevel@tonic-gate 	env->fcode_incr = 2;
425*7c478bd9Sstevel@tonic-gate }
426*7c478bd9Sstevel@tonic-gate 
427*7c478bd9Sstevel@tonic-gate static void
428*7c478bd9Sstevel@tonic-gate start4(fcode_env_t *env)
429*7c478bd9Sstevel@tonic-gate {
430*7c478bd9Sstevel@tonic-gate 	env->fcode_incr = 4;
431*7c478bd9Sstevel@tonic-gate }
432*7c478bd9Sstevel@tonic-gate 
433*7c478bd9Sstevel@tonic-gate int
434*7c478bd9Sstevel@tonic-gate check_fcode_header(char *fname, uchar_t *header, int len)
435*7c478bd9Sstevel@tonic-gate {
436*7c478bd9Sstevel@tonic-gate 	uint32_t length;
437*7c478bd9Sstevel@tonic-gate 	static char func_name[] = "check_fcode_header";
438*7c478bd9Sstevel@tonic-gate 
439*7c478bd9Sstevel@tonic-gate 	if (len <= 8) {
440*7c478bd9Sstevel@tonic-gate 		log_message(MSG_ERROR, "%s: '%s' fcode size (%d) <= 8\n",
441*7c478bd9Sstevel@tonic-gate 		    func_name, fname, len);
442*7c478bd9Sstevel@tonic-gate 		return (0);
443*7c478bd9Sstevel@tonic-gate 	}
444*7c478bd9Sstevel@tonic-gate 	if (header[0] != 0xf1 && header[0] != 0xfd) {
445*7c478bd9Sstevel@tonic-gate 		log_message(MSG_ERROR, "%s: '%s' header[0] is 0x%02x not"
446*7c478bd9Sstevel@tonic-gate 		    " 0xf1/0xfd\n", func_name, fname, header[0]);
447*7c478bd9Sstevel@tonic-gate 		return (0);
448*7c478bd9Sstevel@tonic-gate 	}
449*7c478bd9Sstevel@tonic-gate 	length = (header[4] << 24) | (header[5] << 16) | (header[6] << 8) |
450*7c478bd9Sstevel@tonic-gate 	    header[7];
451*7c478bd9Sstevel@tonic-gate 	if (length > len) {
452*7c478bd9Sstevel@tonic-gate 		log_message(MSG_ERROR, "%s: '%s' length (%d) >"
453*7c478bd9Sstevel@tonic-gate 		    " fcode size (%d)\n", func_name, fname, length, len);
454*7c478bd9Sstevel@tonic-gate 		return (0);
455*7c478bd9Sstevel@tonic-gate 	}
456*7c478bd9Sstevel@tonic-gate 	if (length < len) {
457*7c478bd9Sstevel@tonic-gate 		log_message(MSG_WARN, "%s: '%s' length (%d) <"
458*7c478bd9Sstevel@tonic-gate 		    " fcode size (%d)\n", func_name, fname, length, len);
459*7c478bd9Sstevel@tonic-gate 	}
460*7c478bd9Sstevel@tonic-gate 	return (1);
461*7c478bd9Sstevel@tonic-gate }
462*7c478bd9Sstevel@tonic-gate 
463*7c478bd9Sstevel@tonic-gate void
464*7c478bd9Sstevel@tonic-gate byte_load(fcode_env_t *env)
465*7c478bd9Sstevel@tonic-gate {
466*7c478bd9Sstevel@tonic-gate 	uchar_t	*fcode_buffer;
467*7c478bd9Sstevel@tonic-gate 	uchar_t	*fcode_ptr;
468*7c478bd9Sstevel@tonic-gate 	int	fcode_incr;
469*7c478bd9Sstevel@tonic-gate 	int	offset_incr;
470*7c478bd9Sstevel@tonic-gate 	int	fcode_xt;
471*7c478bd9Sstevel@tonic-gate 	int	interpretting;
472*7c478bd9Sstevel@tonic-gate 	int	depth;
473*7c478bd9Sstevel@tonic-gate 	int	length;
474*7c478bd9Sstevel@tonic-gate 	int	past_eob = 0;
475*7c478bd9Sstevel@tonic-gate 	int db;
476*7c478bd9Sstevel@tonic-gate 
477*7c478bd9Sstevel@tonic-gate 	/* save any existing interpret state */
478*7c478bd9Sstevel@tonic-gate 	fcode_buffer = env->fcode_buffer;
479*7c478bd9Sstevel@tonic-gate 	fcode_ptr = env->fcode_ptr;
480*7c478bd9Sstevel@tonic-gate 	fcode_incr = env->fcode_incr;
481*7c478bd9Sstevel@tonic-gate 	offset_incr  = env->offset_incr;
482*7c478bd9Sstevel@tonic-gate 	interpretting = env->interpretting;
483*7c478bd9Sstevel@tonic-gate 	depth = DEPTH-2;
484*7c478bd9Sstevel@tonic-gate 
485*7c478bd9Sstevel@tonic-gate 	/* Now init them */
486*7c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "byte-load");
487*7c478bd9Sstevel@tonic-gate 	fcode_xt = POP(DS);
488*7c478bd9Sstevel@tonic-gate 	env->fcode_ptr = env->fcode_buffer = (uchar_t *)POP(DS);
489*7c478bd9Sstevel@tonic-gate 	if (fcode_xt != 1) {
490*7c478bd9Sstevel@tonic-gate 		log_message(MSG_WARN, "byte-load: ignoring xt\n");
491*7c478bd9Sstevel@tonic-gate 	}
492*7c478bd9Sstevel@tonic-gate 
493*7c478bd9Sstevel@tonic-gate 	length = (env->fcode_buffer[4] << 24) | (env->fcode_buffer[5] << 16) |
494*7c478bd9Sstevel@tonic-gate 	    (env->fcode_buffer[6] << 8) | env->fcode_buffer[7];
495*7c478bd9Sstevel@tonic-gate 	if (!check_fcode_header("byte-load", env->fcode_ptr, length))
496*7c478bd9Sstevel@tonic-gate 		log_message(MSG_WARN, "byte-load: header NOT OK\n");
497*7c478bd9Sstevel@tonic-gate 
498*7c478bd9Sstevel@tonic-gate 	env->fcode_incr = 1;
499*7c478bd9Sstevel@tonic-gate 	env->offset_incr = 1;
500*7c478bd9Sstevel@tonic-gate 	env->interpretting = 1;
501*7c478bd9Sstevel@tonic-gate 	env->level = 0;
502*7c478bd9Sstevel@tonic-gate 
503*7c478bd9Sstevel@tonic-gate 	db = get_interpreter_debug_level() &
504*7c478bd9Sstevel@tonic-gate 	    (DEBUG_BYTELOAD_DS|DEBUG_BYTELOAD_RS|DEBUG_BYTELOAD_TOKENS);
505*7c478bd9Sstevel@tonic-gate 	debug_msg(db, "byte_load: %p, %d\n", env->fcode_buffer, fcode_xt);
506*7c478bd9Sstevel@tonic-gate 	debug_msg(db, "   header: %x, %x\n",
507*7c478bd9Sstevel@tonic-gate 	    env->fcode_buffer[0], env->fcode_buffer[1]);
508*7c478bd9Sstevel@tonic-gate 	debug_msg(db, "      crc: %x\n",
509*7c478bd9Sstevel@tonic-gate 	    (env->fcode_buffer[2]<<8)|(env->fcode_buffer[3]));
510*7c478bd9Sstevel@tonic-gate 	debug_msg(db, "   length: %x\n", length);
511*7c478bd9Sstevel@tonic-gate 	env->fcode_ptr += 8;
512*7c478bd9Sstevel@tonic-gate 
513*7c478bd9Sstevel@tonic-gate 	debug_msg(db, "Interpretting: %d\n", env->interpretting);
514*7c478bd9Sstevel@tonic-gate 
515*7c478bd9Sstevel@tonic-gate 	while (env->interpretting) {
516*7c478bd9Sstevel@tonic-gate 		int token;
517*7c478bd9Sstevel@tonic-gate 		fcode_token *entry;
518*7c478bd9Sstevel@tonic-gate 		acf_t apf;
519*7c478bd9Sstevel@tonic-gate 
520*7c478bd9Sstevel@tonic-gate 		if (!past_eob && env->fcode_ptr >= env->fcode_buffer + length) {
521*7c478bd9Sstevel@tonic-gate 			log_message(MSG_WARN, "byte-load: past EOB\n");
522*7c478bd9Sstevel@tonic-gate 			past_eob = 1;
523*7c478bd9Sstevel@tonic-gate 		}
524*7c478bd9Sstevel@tonic-gate 
525*7c478bd9Sstevel@tonic-gate 		env->last_fcode_ptr = env->fcode_ptr;
526*7c478bd9Sstevel@tonic-gate 		token = get_next_token(env);
527*7c478bd9Sstevel@tonic-gate 
528*7c478bd9Sstevel@tonic-gate 		entry = &env->table[token];
529*7c478bd9Sstevel@tonic-gate 		apf   = entry->apf;
530*7c478bd9Sstevel@tonic-gate 
531*7c478bd9Sstevel@tonic-gate 		DEBUGF(BYTELOAD_DS, output_data_stack(env, MSG_FC_DEBUG));
532*7c478bd9Sstevel@tonic-gate 		DEBUGF(BYTELOAD_RS, output_return_stack(env, 1, MSG_FC_DEBUG));
533*7c478bd9Sstevel@tonic-gate 		DEBUGF(BYTELOAD_TOKENS, log_message(MSG_FC_DEBUG,
534*7c478bd9Sstevel@tonic-gate 		    "%s: %04x %03x %s (%x)",
535*7c478bd9Sstevel@tonic-gate 		    ((env->state && (entry->flags & IMMEDIATE) == 0)) ?
536*7c478bd9Sstevel@tonic-gate 		    "Compile" : "Execute",
537*7c478bd9Sstevel@tonic-gate 		    env->last_fcode_ptr - env->fcode_buffer, token,
538*7c478bd9Sstevel@tonic-gate 		    entry->name ? entry->name : "???", entry->flags));
539*7c478bd9Sstevel@tonic-gate 		if (db)
540*7c478bd9Sstevel@tonic-gate 			log_message(MSG_FC_DEBUG, "\n");
541*7c478bd9Sstevel@tonic-gate 		if (apf) {
542*7c478bd9Sstevel@tonic-gate 			DEBUGF(TOKEN_USAGE, entry->usage++);
543*7c478bd9Sstevel@tonic-gate 			PUSH(DS, (fstack_t)apf);
544*7c478bd9Sstevel@tonic-gate 			if ((env->state) &&
545*7c478bd9Sstevel@tonic-gate 				((entry->flags & IMMEDIATE) == 0)) {
546*7c478bd9Sstevel@tonic-gate 				/* Compile in references */
547*7c478bd9Sstevel@tonic-gate 				compile_comma(env);
548*7c478bd9Sstevel@tonic-gate 			} else {
549*7c478bd9Sstevel@tonic-gate 				execute(env);
550*7c478bd9Sstevel@tonic-gate 			}
551*7c478bd9Sstevel@tonic-gate 		}
552*7c478bd9Sstevel@tonic-gate 	}
553*7c478bd9Sstevel@tonic-gate 	if (DEPTH != depth) {
554*7c478bd9Sstevel@tonic-gate 		log_message(MSG_ERROR, "FCODE has net stack change of %d\n",
555*7c478bd9Sstevel@tonic-gate 		    DEPTH-depth);
556*7c478bd9Sstevel@tonic-gate 	}
557*7c478bd9Sstevel@tonic-gate 	/* restore old state */
558*7c478bd9Sstevel@tonic-gate 	env->fcode_ptr		= fcode_ptr;
559*7c478bd9Sstevel@tonic-gate 	env->fcode_buffer	= fcode_buffer;
560*7c478bd9Sstevel@tonic-gate 	env->fcode_incr		= fcode_incr;
561*7c478bd9Sstevel@tonic-gate 	env->offset_incr	= offset_incr;
562*7c478bd9Sstevel@tonic-gate 	env->interpretting	= interpretting;
563*7c478bd9Sstevel@tonic-gate }
564*7c478bd9Sstevel@tonic-gate 
565*7c478bd9Sstevel@tonic-gate void
566*7c478bd9Sstevel@tonic-gate btick(fcode_env_t *env)
567*7c478bd9Sstevel@tonic-gate {
568*7c478bd9Sstevel@tonic-gate 	int token = get_next_token(env);
569*7c478bd9Sstevel@tonic-gate 
570*7c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)env->table[token].apf);
571*7c478bd9Sstevel@tonic-gate 	tick_literal(env);
572*7c478bd9Sstevel@tonic-gate }
573*7c478bd9Sstevel@tonic-gate 
574*7c478bd9Sstevel@tonic-gate static void
575*7c478bd9Sstevel@tonic-gate show_fcode_def(fcode_env_t *env, char *type)
576*7c478bd9Sstevel@tonic-gate {
577*7c478bd9Sstevel@tonic-gate 	int i = env->last_token;
578*7c478bd9Sstevel@tonic-gate 
579*7c478bd9Sstevel@tonic-gate 	if (get_interpreter_debug_level() & DEBUG_DUMP_TOKENS) {
580*7c478bd9Sstevel@tonic-gate 		if (env->table[i].name)
581*7c478bd9Sstevel@tonic-gate 			log_message(MSG_INFO, "%s: %s %03x %p\n", type,
582*7c478bd9Sstevel@tonic-gate 			    env->table[i].name, i, env->table[i].apf);
583*7c478bd9Sstevel@tonic-gate 		else
584*7c478bd9Sstevel@tonic-gate 			log_message(MSG_INFO, "%s: <noname> %03x %p\n", type, i,
585*7c478bd9Sstevel@tonic-gate 			    env->table[i].apf);
586*7c478bd9Sstevel@tonic-gate 	}
587*7c478bd9Sstevel@tonic-gate }
588*7c478bd9Sstevel@tonic-gate 
589*7c478bd9Sstevel@tonic-gate void
590*7c478bd9Sstevel@tonic-gate bcolon(fcode_env_t *env)
591*7c478bd9Sstevel@tonic-gate {
592*7c478bd9Sstevel@tonic-gate 	if (env->state == 0) {
593*7c478bd9Sstevel@tonic-gate 		env->table[env->last_token].apf = (acf_t)HERE;
594*7c478bd9Sstevel@tonic-gate 		env->table[env->last_token].flags = 0;
595*7c478bd9Sstevel@tonic-gate 		show_fcode_def(env, "bcolon");
596*7c478bd9Sstevel@tonic-gate 	}
597*7c478bd9Sstevel@tonic-gate 	env->state |= 1;
598*7c478bd9Sstevel@tonic-gate 	COMPILE_TOKEN(&do_colon);
599*7c478bd9Sstevel@tonic-gate }
600*7c478bd9Sstevel@tonic-gate 
601*7c478bd9Sstevel@tonic-gate void
602*7c478bd9Sstevel@tonic-gate bcreate(fcode_env_t *env)
603*7c478bd9Sstevel@tonic-gate {
604*7c478bd9Sstevel@tonic-gate 	env->table[env->last_token].apf = (acf_t)HERE;
605*7c478bd9Sstevel@tonic-gate 	show_fcode_def(env, "bcreate");
606*7c478bd9Sstevel@tonic-gate 	COMPILE_TOKEN(&do_create);
607*7c478bd9Sstevel@tonic-gate 	expose_acf(env, "<bcreate>");
608*7c478bd9Sstevel@tonic-gate }
609*7c478bd9Sstevel@tonic-gate 
610*7c478bd9Sstevel@tonic-gate void
611*7c478bd9Sstevel@tonic-gate get_token_name(fcode_env_t *env, int token, char **name, int *len)
612*7c478bd9Sstevel@tonic-gate {
613*7c478bd9Sstevel@tonic-gate 	*name = env->table[token].name;
614*7c478bd9Sstevel@tonic-gate 	if (*name) {
615*7c478bd9Sstevel@tonic-gate 		*len = strlen(*name);
616*7c478bd9Sstevel@tonic-gate 	} else
617*7c478bd9Sstevel@tonic-gate 		*len = 0;
618*7c478bd9Sstevel@tonic-gate }
619*7c478bd9Sstevel@tonic-gate 
620*7c478bd9Sstevel@tonic-gate void
621*7c478bd9Sstevel@tonic-gate bvalue(fcode_env_t *env)
622*7c478bd9Sstevel@tonic-gate {
623*7c478bd9Sstevel@tonic-gate 	env->table[env->last_token].apf = (acf_t)HERE;
624*7c478bd9Sstevel@tonic-gate 	show_fcode_def(env, "bvalue");
625*7c478bd9Sstevel@tonic-gate 	make_common_access(env, 0, 0, 1,
626*7c478bd9Sstevel@tonic-gate 	    env->instance_mode, &noop, &noop, &set_value_actions);
627*7c478bd9Sstevel@tonic-gate }
628*7c478bd9Sstevel@tonic-gate 
629*7c478bd9Sstevel@tonic-gate void
630*7c478bd9Sstevel@tonic-gate bvariable(fcode_env_t *env)
631*7c478bd9Sstevel@tonic-gate {
632*7c478bd9Sstevel@tonic-gate 	env->table[env->last_token].apf = (acf_t)HERE;
633*7c478bd9Sstevel@tonic-gate 	show_fcode_def(env, "bvariable");
634*7c478bd9Sstevel@tonic-gate 	PUSH(DS, 0);
635*7c478bd9Sstevel@tonic-gate 	make_common_access(env, 0, 0, 1,
636*7c478bd9Sstevel@tonic-gate 	    env->instance_mode, &instance_variable, &do_create, NULL);
637*7c478bd9Sstevel@tonic-gate }
638*7c478bd9Sstevel@tonic-gate 
639*7c478bd9Sstevel@tonic-gate void
640*7c478bd9Sstevel@tonic-gate bconstant(fcode_env_t *env)
641*7c478bd9Sstevel@tonic-gate {
642*7c478bd9Sstevel@tonic-gate 	env->table[env->last_token].apf = (acf_t)HERE;
643*7c478bd9Sstevel@tonic-gate 	show_fcode_def(env, "bconstant");
644*7c478bd9Sstevel@tonic-gate 	make_common_access(env, 0, 0, 1,
645*7c478bd9Sstevel@tonic-gate 	    env->instance_mode, &do_constant, &do_constant, NULL);
646*7c478bd9Sstevel@tonic-gate }
647*7c478bd9Sstevel@tonic-gate 
648*7c478bd9Sstevel@tonic-gate void
649*7c478bd9Sstevel@tonic-gate bdefer(fcode_env_t *env)
650*7c478bd9Sstevel@tonic-gate {
651*7c478bd9Sstevel@tonic-gate 	env->table[env->last_token].apf = (acf_t)HERE;
652*7c478bd9Sstevel@tonic-gate 	show_fcode_def(env, "bdefer");
653*7c478bd9Sstevel@tonic-gate 
654*7c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)&crash_ptr);
655*7c478bd9Sstevel@tonic-gate 	make_common_access(env, 0, 0, 1, env->instance_mode,
656*7c478bd9Sstevel@tonic-gate 	    &noop, &noop, &set_defer_actions);
657*7c478bd9Sstevel@tonic-gate }
658*7c478bd9Sstevel@tonic-gate 
659*7c478bd9Sstevel@tonic-gate void
660*7c478bd9Sstevel@tonic-gate bbuffer_colon(fcode_env_t *env)
661*7c478bd9Sstevel@tonic-gate {
662*7c478bd9Sstevel@tonic-gate 	env->table[env->last_token].apf = (acf_t)HERE;
663*7c478bd9Sstevel@tonic-gate 	show_fcode_def(env, "buffer:");
664*7c478bd9Sstevel@tonic-gate 	PUSH(DS, 0);
665*7c478bd9Sstevel@tonic-gate 	make_common_access(env, 0, 0, 2, env->instance_mode,
666*7c478bd9Sstevel@tonic-gate 	    &noop, &noop, &set_buffer_actions);
667*7c478bd9Sstevel@tonic-gate }
668*7c478bd9Sstevel@tonic-gate 
669*7c478bd9Sstevel@tonic-gate void
670*7c478bd9Sstevel@tonic-gate do_field(fcode_env_t *env)
671*7c478bd9Sstevel@tonic-gate {
672*7c478bd9Sstevel@tonic-gate 	fstack_t *d;
673*7c478bd9Sstevel@tonic-gate 
674*7c478bd9Sstevel@tonic-gate 	d = (fstack_t *)WA;
675*7c478bd9Sstevel@tonic-gate 	TOS += *d;
676*7c478bd9Sstevel@tonic-gate }
677*7c478bd9Sstevel@tonic-gate 
678*7c478bd9Sstevel@tonic-gate void
679*7c478bd9Sstevel@tonic-gate bfield(fcode_env_t *env)
680*7c478bd9Sstevel@tonic-gate {
681*7c478bd9Sstevel@tonic-gate 	env->table[env->last_token].apf = (acf_t)HERE;
682*7c478bd9Sstevel@tonic-gate 	show_fcode_def(env, "bfield");
683*7c478bd9Sstevel@tonic-gate 	COMPILE_TOKEN(&do_field);
684*7c478bd9Sstevel@tonic-gate 	over(env);
685*7c478bd9Sstevel@tonic-gate 	compile_comma(env);
686*7c478bd9Sstevel@tonic-gate 	add(env);
687*7c478bd9Sstevel@tonic-gate 	expose_acf(env, "<bfield>");
688*7c478bd9Sstevel@tonic-gate }
689*7c478bd9Sstevel@tonic-gate 
690*7c478bd9Sstevel@tonic-gate void
691*7c478bd9Sstevel@tonic-gate bto(fcode_env_t *env)
692*7c478bd9Sstevel@tonic-gate {
693*7c478bd9Sstevel@tonic-gate 	btick(env);
694*7c478bd9Sstevel@tonic-gate 
695*7c478bd9Sstevel@tonic-gate 	if (env->state) {
696*7c478bd9Sstevel@tonic-gate 		COMPILE_TOKEN(&to_ptr);
697*7c478bd9Sstevel@tonic-gate 	} else {
698*7c478bd9Sstevel@tonic-gate 		do_set_action(env);
699*7c478bd9Sstevel@tonic-gate 	}
700*7c478bd9Sstevel@tonic-gate }
701*7c478bd9Sstevel@tonic-gate 
702*7c478bd9Sstevel@tonic-gate void
703*7c478bd9Sstevel@tonic-gate get_token(fcode_env_t *env)
704*7c478bd9Sstevel@tonic-gate {
705*7c478bd9Sstevel@tonic-gate 	fstack_t tok;
706*7c478bd9Sstevel@tonic-gate 	fstack_t immediate = 0;
707*7c478bd9Sstevel@tonic-gate 
708*7c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "get-token");
709*7c478bd9Sstevel@tonic-gate 	tok = POP(DS);
710*7c478bd9Sstevel@tonic-gate 	tok &= MAX_FCODE;
711*7c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)env->table[tok].apf);
712*7c478bd9Sstevel@tonic-gate 	if (env->table[tok].flags & IMMEDIATE) 	immediate = 1;
713*7c478bd9Sstevel@tonic-gate 	PUSH(DS, immediate);
714*7c478bd9Sstevel@tonic-gate }
715*7c478bd9Sstevel@tonic-gate 
716*7c478bd9Sstevel@tonic-gate void
717*7c478bd9Sstevel@tonic-gate set_token(fcode_env_t *env)
718*7c478bd9Sstevel@tonic-gate {
719*7c478bd9Sstevel@tonic-gate 	fstack_t tok;
720*7c478bd9Sstevel@tonic-gate 	fstack_t immediate;
721*7c478bd9Sstevel@tonic-gate 	acf_t acf;
722*7c478bd9Sstevel@tonic-gate 
723*7c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 3, "set-token");
724*7c478bd9Sstevel@tonic-gate 	tok = POP(DS);
725*7c478bd9Sstevel@tonic-gate 	tok &= MAX_FCODE;
726*7c478bd9Sstevel@tonic-gate 	immediate = POP(DS);
727*7c478bd9Sstevel@tonic-gate 	acf = (acf_t)POP(DS);
728*7c478bd9Sstevel@tonic-gate 	if (immediate)
729*7c478bd9Sstevel@tonic-gate 		env->table[tok].flags |= IMMEDIATE;
730*7c478bd9Sstevel@tonic-gate 	else
731*7c478bd9Sstevel@tonic-gate 		env->table[tok].flags &= ~IMMEDIATE;
732*7c478bd9Sstevel@tonic-gate 	env->table[tok].apf = acf;
733*7c478bd9Sstevel@tonic-gate 	immediate = env->last_token;
734*7c478bd9Sstevel@tonic-gate 	env->last_token = tok;
735*7c478bd9Sstevel@tonic-gate 	show_fcode_def(env, "set_token");
736*7c478bd9Sstevel@tonic-gate 	env->last_token = immediate;
737*7c478bd9Sstevel@tonic-gate }
738*7c478bd9Sstevel@tonic-gate 
739*7c478bd9Sstevel@tonic-gate void
740*7c478bd9Sstevel@tonic-gate bof(fcode_env_t *env)
741*7c478bd9Sstevel@tonic-gate {
742*7c478bd9Sstevel@tonic-gate 	short offset = get_short(env);
743*7c478bd9Sstevel@tonic-gate 	branch_common(env, offset, 2, 0);
744*7c478bd9Sstevel@tonic-gate }
745*7c478bd9Sstevel@tonic-gate 
746*7c478bd9Sstevel@tonic-gate void
747*7c478bd9Sstevel@tonic-gate bcase(fcode_env_t *env)
748*7c478bd9Sstevel@tonic-gate {
749*7c478bd9Sstevel@tonic-gate 	env->level++;
750*7c478bd9Sstevel@tonic-gate 	set_temporary_compile(env);
751*7c478bd9Sstevel@tonic-gate 	PUSH(DS, 0);
752*7c478bd9Sstevel@tonic-gate }
753*7c478bd9Sstevel@tonic-gate 
754*7c478bd9Sstevel@tonic-gate void
755*7c478bd9Sstevel@tonic-gate bendcase(fcode_env_t *env)
756*7c478bd9Sstevel@tonic-gate {
757*7c478bd9Sstevel@tonic-gate 	COMPILE_TOKEN(env->table[0x46].apf);	/* Hack for now... */
758*7c478bd9Sstevel@tonic-gate 	while (TOS) {
759*7c478bd9Sstevel@tonic-gate 		bresolve(env);
760*7c478bd9Sstevel@tonic-gate 	}
761*7c478bd9Sstevel@tonic-gate 	(void) POP(DS);
762*7c478bd9Sstevel@tonic-gate 	env->level--;
763*7c478bd9Sstevel@tonic-gate 	temporary_execute(env);
764*7c478bd9Sstevel@tonic-gate }
765*7c478bd9Sstevel@tonic-gate 
766*7c478bd9Sstevel@tonic-gate void
767*7c478bd9Sstevel@tonic-gate bendof(fcode_env_t *env)
768*7c478bd9Sstevel@tonic-gate {
769*7c478bd9Sstevel@tonic-gate 	short offset = get_short(env);
770*7c478bd9Sstevel@tonic-gate 	branch_common(env, offset, 0, 1);
771*7c478bd9Sstevel@tonic-gate 	bresolve(env);
772*7c478bd9Sstevel@tonic-gate }
773*7c478bd9Sstevel@tonic-gate 
774*7c478bd9Sstevel@tonic-gate void
775*7c478bd9Sstevel@tonic-gate fcode_revision(fcode_env_t *env)
776*7c478bd9Sstevel@tonic-gate {
777*7c478bd9Sstevel@tonic-gate 	/* We are Version 3.0 */
778*7c478bd9Sstevel@tonic-gate 	PUSH(DS, 0x30000);
779*7c478bd9Sstevel@tonic-gate }
780*7c478bd9Sstevel@tonic-gate 
781*7c478bd9Sstevel@tonic-gate void
782*7c478bd9Sstevel@tonic-gate alloc_mem(fcode_env_t *env)
783*7c478bd9Sstevel@tonic-gate {
784*7c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "alloc-mem");
785*7c478bd9Sstevel@tonic-gate 	TOS = (fstack_t)MALLOC((size_t)TOS);
786*7c478bd9Sstevel@tonic-gate 	if (!TOS) {
787*7c478bd9Sstevel@tonic-gate 		throw_from_fclib(env, 1, "alloc-mem failed");
788*7c478bd9Sstevel@tonic-gate 	}
789*7c478bd9Sstevel@tonic-gate }
790*7c478bd9Sstevel@tonic-gate 
791*7c478bd9Sstevel@tonic-gate void
792*7c478bd9Sstevel@tonic-gate free_mem(fcode_env_t *env)
793*7c478bd9Sstevel@tonic-gate {
794*7c478bd9Sstevel@tonic-gate 	void *p;
795*7c478bd9Sstevel@tonic-gate 
796*7c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "free-mem");
797*7c478bd9Sstevel@tonic-gate 	(void) POP(DS);
798*7c478bd9Sstevel@tonic-gate 	p = (void *) POP(DS);
799*7c478bd9Sstevel@tonic-gate 	FREE(p);
800*7c478bd9Sstevel@tonic-gate }
801*7c478bd9Sstevel@tonic-gate 
802*7c478bd9Sstevel@tonic-gate void
803*7c478bd9Sstevel@tonic-gate parse_two_int(fcode_env_t *env)
804*7c478bd9Sstevel@tonic-gate {
805*7c478bd9Sstevel@tonic-gate 	uint_t lo, hi;
806*7c478bd9Sstevel@tonic-gate 	char *str;
807*7c478bd9Sstevel@tonic-gate 	int len;
808*7c478bd9Sstevel@tonic-gate 
809*7c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "parse-2int");
810*7c478bd9Sstevel@tonic-gate 	lo = 0;
811*7c478bd9Sstevel@tonic-gate 	hi = 0;
812*7c478bd9Sstevel@tonic-gate 	str = pop_a_string(env, &len);
813*7c478bd9Sstevel@tonic-gate 	if (len) {
814*7c478bd9Sstevel@tonic-gate 		if (sscanf(str, "%x,%x", &hi, &lo) != 2) {
815*7c478bd9Sstevel@tonic-gate 			throw_from_fclib(env, 1, "parse_2int");
816*7c478bd9Sstevel@tonic-gate 		}
817*7c478bd9Sstevel@tonic-gate 	}
818*7c478bd9Sstevel@tonic-gate 	PUSH(DS, lo);
819*7c478bd9Sstevel@tonic-gate 	PUSH(DS, hi);
820*7c478bd9Sstevel@tonic-gate }
821*7c478bd9Sstevel@tonic-gate 
822*7c478bd9Sstevel@tonic-gate void
823*7c478bd9Sstevel@tonic-gate left_parse_string(fcode_env_t *env)
824*7c478bd9Sstevel@tonic-gate {
825*7c478bd9Sstevel@tonic-gate 	char sep, *cptr, *lstr, *rstr;
826*7c478bd9Sstevel@tonic-gate 	int len, llen, rlen;
827*7c478bd9Sstevel@tonic-gate 
828*7c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 3, "left-parse-string");
829*7c478bd9Sstevel@tonic-gate 	sep = (char)POP(DS);
830*7c478bd9Sstevel@tonic-gate 	if (TOS == 0) {
831*7c478bd9Sstevel@tonic-gate 		two_dup(env);
832*7c478bd9Sstevel@tonic-gate 		return;
833*7c478bd9Sstevel@tonic-gate 	}
834*7c478bd9Sstevel@tonic-gate 	lstr = pop_a_string(env, &llen);
835*7c478bd9Sstevel@tonic-gate 	len = 0;
836*7c478bd9Sstevel@tonic-gate 	cptr = NULL;
837*7c478bd9Sstevel@tonic-gate 	while (len < llen) {
838*7c478bd9Sstevel@tonic-gate 		if (lstr[len] == sep) {
839*7c478bd9Sstevel@tonic-gate 			cptr = lstr+len;
840*7c478bd9Sstevel@tonic-gate 			break;
841*7c478bd9Sstevel@tonic-gate 		}
842*7c478bd9Sstevel@tonic-gate 		len++;
843*7c478bd9Sstevel@tonic-gate 	}
844*7c478bd9Sstevel@tonic-gate 	if (cptr != NULL) {
845*7c478bd9Sstevel@tonic-gate 		rstr = cptr+1;
846*7c478bd9Sstevel@tonic-gate 		rlen = lstr + llen - rstr;
847*7c478bd9Sstevel@tonic-gate 		llen = len;
848*7c478bd9Sstevel@tonic-gate 	} else {
849*7c478bd9Sstevel@tonic-gate 		rlen = 0;
850*7c478bd9Sstevel@tonic-gate 		rstr = lstr;
851*7c478bd9Sstevel@tonic-gate 	}
852*7c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)rstr);
853*7c478bd9Sstevel@tonic-gate 	PUSH(DS, rlen);
854*7c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)lstr);
855*7c478bd9Sstevel@tonic-gate 	PUSH(DS, llen);
856*7c478bd9Sstevel@tonic-gate }
857*7c478bd9Sstevel@tonic-gate 
858*7c478bd9Sstevel@tonic-gate /*
859*7c478bd9Sstevel@tonic-gate  * (is-user-word)  ( name-str name-len xt -- )
860*7c478bd9Sstevel@tonic-gate  */
861*7c478bd9Sstevel@tonic-gate void
862*7c478bd9Sstevel@tonic-gate is_user_word(fcode_env_t *env)
863*7c478bd9Sstevel@tonic-gate {
864*7c478bd9Sstevel@tonic-gate 	fstack_t xt;
865*7c478bd9Sstevel@tonic-gate 	char *name;
866*7c478bd9Sstevel@tonic-gate 	int len;
867*7c478bd9Sstevel@tonic-gate 
868*7c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 3, "(is-user-word)");
869*7c478bd9Sstevel@tonic-gate 	xt = POP(DS);
870*7c478bd9Sstevel@tonic-gate 	name = pop_a_string(env, &len);
871*7c478bd9Sstevel@tonic-gate 	header(env, name, len, 0);
872*7c478bd9Sstevel@tonic-gate 	COMPILE_TOKEN(&do_alias);
873*7c478bd9Sstevel@tonic-gate 	COMPILE_TOKEN(xt);
874*7c478bd9Sstevel@tonic-gate 	expose_acf(env, name);
875*7c478bd9Sstevel@tonic-gate }
876*7c478bd9Sstevel@tonic-gate 
877*7c478bd9Sstevel@tonic-gate void
878*7c478bd9Sstevel@tonic-gate f_error(fcode_env_t *env)
879*7c478bd9Sstevel@tonic-gate {
880*7c478bd9Sstevel@tonic-gate #if 0
881*7c478bd9Sstevel@tonic-gate 	env->interpretting = 0;
882*7c478bd9Sstevel@tonic-gate 	log_message(MSG_ERROR, "Uniplemented FCODE token encountered %x\n",
883*7c478bd9Sstevel@tonic-gate 	    env->last_fcode);
884*7c478bd9Sstevel@tonic-gate #else
885*7c478bd9Sstevel@tonic-gate 	forth_abort(env, "Unimplemented FCODE token: 0x%x\n", env->last_fcode);
886*7c478bd9Sstevel@tonic-gate #endif
887*7c478bd9Sstevel@tonic-gate }
888*7c478bd9Sstevel@tonic-gate 
889*7c478bd9Sstevel@tonic-gate static void
890*7c478bd9Sstevel@tonic-gate fcode_buffer_addr(fcode_env_t *env)
891*7c478bd9Sstevel@tonic-gate {
892*7c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)(env->fcode_buffer));
893*7c478bd9Sstevel@tonic-gate }
894*7c478bd9Sstevel@tonic-gate 
895*7c478bd9Sstevel@tonic-gate #pragma init(_init)
896*7c478bd9Sstevel@tonic-gate 
897*7c478bd9Sstevel@tonic-gate static void
898*7c478bd9Sstevel@tonic-gate _init(void)
899*7c478bd9Sstevel@tonic-gate {
900*7c478bd9Sstevel@tonic-gate 	fcode_env_t *env = initial_env;
901*7c478bd9Sstevel@tonic-gate 
902*7c478bd9Sstevel@tonic-gate 	ASSERT(env);
903*7c478bd9Sstevel@tonic-gate 	NOTICE;
904*7c478bd9Sstevel@tonic-gate 
905*7c478bd9Sstevel@tonic-gate 	P1275(0x000, DEFINER,	"end0",			end0);
906*7c478bd9Sstevel@tonic-gate 	P1275(0x010, DEFINER,	"b(lit)",		blit);
907*7c478bd9Sstevel@tonic-gate 	P1275(0x011, DEFINER,	"b(')",			btick);
908*7c478bd9Sstevel@tonic-gate 	P1275(0x012, DEFINER,	"b(\")",		bquote);
909*7c478bd9Sstevel@tonic-gate 	P1275(0x013, DEFINER,	"bbranch",		bbranch);
910*7c478bd9Sstevel@tonic-gate 	P1275(0x014, DEFINER,	"b?branch",		bqbranch);
911*7c478bd9Sstevel@tonic-gate 	P1275(0x015, DEFINER,	"b(loop)",		bloop);
912*7c478bd9Sstevel@tonic-gate 	P1275(0x016, DEFINER,	"b(+loop)",		bplusloop);
913*7c478bd9Sstevel@tonic-gate 	P1275(0x017, DEFINER,	"b(do)",		bdo);
914*7c478bd9Sstevel@tonic-gate 	P1275(0x018, DEFINER,	"b(?do)",		bqdo);
915*7c478bd9Sstevel@tonic-gate 	P1275(0x01b, DEFINER,	"b(leave)",		bleave);
916*7c478bd9Sstevel@tonic-gate 	P1275(0x01c, DEFINER,	"b(of)",		bof);
917*7c478bd9Sstevel@tonic-gate 
918*7c478bd9Sstevel@tonic-gate 	P1275(0x087, 0,		"fcode-revision",	fcode_revision);
919*7c478bd9Sstevel@tonic-gate 
920*7c478bd9Sstevel@tonic-gate 	P1275(0x08b, 0,		"alloc-mem",		alloc_mem);
921*7c478bd9Sstevel@tonic-gate 	P1275(0x08c, 0,		"free-mem",		free_mem);
922*7c478bd9Sstevel@tonic-gate 
923*7c478bd9Sstevel@tonic-gate 	P1275(0x0a4, 0,		"-1",			minus_one);
924*7c478bd9Sstevel@tonic-gate 	P1275(0x0a5, 0,		"0",			zero);
925*7c478bd9Sstevel@tonic-gate 	P1275(0x0a6, 0,		"1",			one);
926*7c478bd9Sstevel@tonic-gate 	P1275(0x0a7, 0,		"2",			two);
927*7c478bd9Sstevel@tonic-gate 	P1275(0x0a8, 0,		"3",			three);
928*7c478bd9Sstevel@tonic-gate 
929*7c478bd9Sstevel@tonic-gate 	P1275(0x0ae, 0,		"aligned",		aligned);
930*7c478bd9Sstevel@tonic-gate 	P1275(0x0b1, DEFINER,	"b(<mark)",		bmark);
931*7c478bd9Sstevel@tonic-gate 	P1275(0x0b2, DEFINER,	"b(>resolve)",		bresolve);
932*7c478bd9Sstevel@tonic-gate 	FCODE(0x0b3, 0,		"set-token-table",	fc_historical);
933*7c478bd9Sstevel@tonic-gate 	FCODE(0x0b4, 0,		"set-table",		fc_historical);
934*7c478bd9Sstevel@tonic-gate 	P1275(0x0b5, 0,		"new-token",		new_token);
935*7c478bd9Sstevel@tonic-gate 	P1275(0x0b6, 0,		"named-token",		named_token);
936*7c478bd9Sstevel@tonic-gate 	P1275(0x0b7, DEFINER,	"b(:)",			bcolon);
937*7c478bd9Sstevel@tonic-gate 	P1275(0x0b8, DEFINER,	"b(value)",		bvalue);
938*7c478bd9Sstevel@tonic-gate 	P1275(0x0b9, DEFINER,	"b(variable)",		bvariable);
939*7c478bd9Sstevel@tonic-gate 	P1275(0x0ba, DEFINER,	"b(constant)",		bconstant);
940*7c478bd9Sstevel@tonic-gate 	P1275(0x0bb, DEFINER,	"b(create)",		bcreate);
941*7c478bd9Sstevel@tonic-gate 	P1275(0x0bc, DEFINER,	"b(defer)",		bdefer);
942*7c478bd9Sstevel@tonic-gate 	P1275(0x0bd, 0,		"b(buffer:)",		bbuffer_colon);
943*7c478bd9Sstevel@tonic-gate 	P1275(0x0be, 0,		"b(field)",		bfield);
944*7c478bd9Sstevel@tonic-gate 	FCODE(0x0bf, 0,		"b(code)",		fc_historical);
945*7c478bd9Sstevel@tonic-gate 	P1275(0x0c0, IMMEDIATE,	"instance",		instance);
946*7c478bd9Sstevel@tonic-gate 
947*7c478bd9Sstevel@tonic-gate 	P1275(0x0c2, DEFINER,	"b(;)",			semi);
948*7c478bd9Sstevel@tonic-gate 	P1275(0x0c3, DEFINER,	"b(to)",		bto);
949*7c478bd9Sstevel@tonic-gate 	P1275(0x0c4, DEFINER,	"b(case)",		bcase);
950*7c478bd9Sstevel@tonic-gate 	P1275(0x0c5, DEFINER,	"b(endcase)",		bendcase);
951*7c478bd9Sstevel@tonic-gate 	P1275(0x0c6, DEFINER,	"b(endof)",		bendof);
952*7c478bd9Sstevel@tonic-gate 
953*7c478bd9Sstevel@tonic-gate 	P1275(0x0ca, 0,		"external-token",	external_token);
954*7c478bd9Sstevel@tonic-gate 	P1275(0x0cc, 0,		"offset16",		offset16);
955*7c478bd9Sstevel@tonic-gate 	P1275(0x0cd, 0,		"evaluate",		evaluate);
956*7c478bd9Sstevel@tonic-gate 
957*7c478bd9Sstevel@tonic-gate 	P1275(0x0da, 0,		"get-token",		get_token);
958*7c478bd9Sstevel@tonic-gate 	P1275(0x0db, 0,		"set-token",		set_token);
959*7c478bd9Sstevel@tonic-gate 
960*7c478bd9Sstevel@tonic-gate 	P1275(0x0f0, 0,		"start0",		start0);
961*7c478bd9Sstevel@tonic-gate 	P1275(0x0f1, 0,		"start1",		start1);
962*7c478bd9Sstevel@tonic-gate 	P1275(0x0f2, 0,		"start2",		start2);
963*7c478bd9Sstevel@tonic-gate 	P1275(0x0f3, 0,		"start4",		start4);
964*7c478bd9Sstevel@tonic-gate 
965*7c478bd9Sstevel@tonic-gate 	P1275(0x0fd, 0,		"version1",		version1);
966*7c478bd9Sstevel@tonic-gate 	FCODE(0x0fe, 0,		"4-byte-id",		fc_historical);
967*7c478bd9Sstevel@tonic-gate 
968*7c478bd9Sstevel@tonic-gate 	P1275(0x0ff, 0,		"end1",			end1);
969*7c478bd9Sstevel@tonic-gate 
970*7c478bd9Sstevel@tonic-gate 	/* Call it "old-dma-alloc" so no one gets confused */
971*7c478bd9Sstevel@tonic-gate 	FCODE(0x101, 0,		"old-dma-alloc",	fc_historical);
972*7c478bd9Sstevel@tonic-gate 
973*7c478bd9Sstevel@tonic-gate 	FCODE(0x104, 0,		"memmap",		fc_historical);
974*7c478bd9Sstevel@tonic-gate 	FCODE(0x105, 0,		"free-virtual",		fc_unimplemented);
975*7c478bd9Sstevel@tonic-gate 
976*7c478bd9Sstevel@tonic-gate 	FCODE(0x106, 0,		">physical",		fc_historical);
977*7c478bd9Sstevel@tonic-gate 
978*7c478bd9Sstevel@tonic-gate 	FCODE(0x10f, 0,		"my-params",		fc_historical);
979*7c478bd9Sstevel@tonic-gate 
980*7c478bd9Sstevel@tonic-gate 	P1275(0x11b, 0,		"parse-2int",		parse_two_int);
981*7c478bd9Sstevel@tonic-gate 
982*7c478bd9Sstevel@tonic-gate 	FCODE(0x122, 0,		"memory-test-suite",	fc_unimplemented);
983*7c478bd9Sstevel@tonic-gate 	FCODE(0x123, 0,		"group-code",		fc_historical);
984*7c478bd9Sstevel@tonic-gate 	FCODE(0x124, 0,		"mask",			fc_unimplemented);
985*7c478bd9Sstevel@tonic-gate 
986*7c478bd9Sstevel@tonic-gate 	FCODE(0x130, 0,		"map-low",		fc_unimplemented);
987*7c478bd9Sstevel@tonic-gate 	FCODE(0x131, 0,		"sbus-intr>cpu",	fc_unimplemented);
988*7c478bd9Sstevel@tonic-gate 
989*7c478bd9Sstevel@tonic-gate 	FCODE(0x170, 0,		"fb1-draw-character",	fc_historical);
990*7c478bd9Sstevel@tonic-gate 	FCODE(0x171, 0,		"fb1-reset-screen",	fc_historical);
991*7c478bd9Sstevel@tonic-gate 	FCODE(0x172, 0,		"fb1-toggle-cursor",	fc_historical);
992*7c478bd9Sstevel@tonic-gate 	FCODE(0x173, 0,		"fb1-erase-screen",	fc_historical);
993*7c478bd9Sstevel@tonic-gate 	FCODE(0x174, 0,		"fb1-blink-screen",	fc_historical);
994*7c478bd9Sstevel@tonic-gate 	FCODE(0x175, 0,		"fb1-invert-screen",	fc_historical);
995*7c478bd9Sstevel@tonic-gate 	FCODE(0x176, 0,		"fb1-insert-characters",	fc_historical);
996*7c478bd9Sstevel@tonic-gate 	FCODE(0x177, 0,		"fb1-delete-characters",	fc_historical);
997*7c478bd9Sstevel@tonic-gate 	FCODE(0x178, 0,		"fb1-insert-lines",	fc_historical);
998*7c478bd9Sstevel@tonic-gate 	FCODE(0x179, 0,		"fb1-delete-lines",	fc_historical);
999*7c478bd9Sstevel@tonic-gate 	FCODE(0x17a, 0,		"fb1-draw-logo",	fc_historical);
1000*7c478bd9Sstevel@tonic-gate 	FCODE(0x17b, 0,		"fb1-install",		fc_historical);
1001*7c478bd9Sstevel@tonic-gate 	FCODE(0x17c, 0,		"fb1-slide-up",		fc_historical);
1002*7c478bd9Sstevel@tonic-gate 
1003*7c478bd9Sstevel@tonic-gate 	FCODE(0x190, 0,		"VME-bus Support",	fc_obsolete);
1004*7c478bd9Sstevel@tonic-gate 	FCODE(0x191, 0,		"VME-bus Support",	fc_obsolete);
1005*7c478bd9Sstevel@tonic-gate 	FCODE(0x192, 0,		"VME-bus Support",	fc_obsolete);
1006*7c478bd9Sstevel@tonic-gate 	FCODE(0x193, 0,		"VME-bus Support",	fc_obsolete);
1007*7c478bd9Sstevel@tonic-gate 	FCODE(0x194, 0,		"VME-bus Support",	fc_obsolete);
1008*7c478bd9Sstevel@tonic-gate 	FCODE(0x195, 0,		"VME-bus Support",	fc_obsolete);
1009*7c478bd9Sstevel@tonic-gate 	FCODE(0x196, 0,		"VME-bus Support",	fc_obsolete);
1010*7c478bd9Sstevel@tonic-gate 
1011*7c478bd9Sstevel@tonic-gate 	FCODE(0x1a0, 0,		"return-buffer",	fc_historical);
1012*7c478bd9Sstevel@tonic-gate 	FCODE(0x1a1, 0,		"xmit-packet",		fc_historical);
1013*7c478bd9Sstevel@tonic-gate 	FCODE(0x1a2, 0,		"poll-packet",		fc_historical);
1014*7c478bd9Sstevel@tonic-gate 
1015*7c478bd9Sstevel@tonic-gate 	FCODE(0x210, 0,		"processor-type",	fc_historical);
1016*7c478bd9Sstevel@tonic-gate 	FCODE(0x211, 0,		"firmware-version",	fc_historical);
1017*7c478bd9Sstevel@tonic-gate 	FCODE(0x212, 0,		"fcode-version",	fc_historical);
1018*7c478bd9Sstevel@tonic-gate 
1019*7c478bd9Sstevel@tonic-gate 	FCODE(0x214, 0,		"(is-user-word)",	is_user_word);
1020*7c478bd9Sstevel@tonic-gate 	FCODE(0x215, 0,		"suspend-fcode",	fc_unimplemented);
1021*7c478bd9Sstevel@tonic-gate 
1022*7c478bd9Sstevel@tonic-gate 	FCODE(0x229, 0,		"adr-mask",		fc_historical);
1023*7c478bd9Sstevel@tonic-gate 
1024*7c478bd9Sstevel@tonic-gate 	FCODE(0x238, 0,		"probe",		fc_historical);
1025*7c478bd9Sstevel@tonic-gate 	FCODE(0x239, 0,		"probe-virtual",	fc_historical);
1026*7c478bd9Sstevel@tonic-gate 
1027*7c478bd9Sstevel@tonic-gate 	P1275(0x23e, 0,		"byte-load",		byte_load);
1028*7c478bd9Sstevel@tonic-gate 
1029*7c478bd9Sstevel@tonic-gate 	P1275(0x240, 0,		"left-parse-string",	left_parse_string);
1030*7c478bd9Sstevel@tonic-gate 	FORTH(0,		"fcode-buffer",		fcode_buffer_addr);
1031*7c478bd9Sstevel@tonic-gate }
1032