xref: /titanic_50/usr/src/lib/efcode/engine/forth.c (revision 3aa1cd26bc498bd7a8d002259dabfe984ccc90d1)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*3aa1cd26Sgovinda  * Common Development and Distribution License (the "License").
6*3aa1cd26Sgovinda  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*3aa1cd26Sgovinda  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*3aa1cd26Sgovinda  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #include <stdio.h>
297c478bd9Sstevel@tonic-gate #include <stdlib.h>
307c478bd9Sstevel@tonic-gate #include <string.h>
317c478bd9Sstevel@tonic-gate #include <stdarg.h>
327c478bd9Sstevel@tonic-gate #include <ctype.h>
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #include <fcode/private.h>
357c478bd9Sstevel@tonic-gate #include <fcode/log.h>
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate void (*semi_ptr)(fcode_env_t *env) = do_semi;
387c478bd9Sstevel@tonic-gate void (*does_ptr)(fcode_env_t *env) = install_does;
397c478bd9Sstevel@tonic-gate void (*quote_ptr)(fcode_env_t *env) = do_quote;
407c478bd9Sstevel@tonic-gate void (*blit_ptr)(fcode_env_t *env) = do_literal;
417c478bd9Sstevel@tonic-gate void (*tlit_ptr)(fcode_env_t *env) = do_literal;
427c478bd9Sstevel@tonic-gate void (*do_bdo_ptr)(fcode_env_t *env) = do_bdo;
437c478bd9Sstevel@tonic-gate void (*do_bqdo_ptr)(fcode_env_t *env) = do_bqdo;
447c478bd9Sstevel@tonic-gate void (*create_ptr)(fcode_env_t *env) = do_creator;
457c478bd9Sstevel@tonic-gate void (*do_leave_ptr)(fcode_env_t *env) = do_bleave;
467c478bd9Sstevel@tonic-gate void (*do_loop_ptr)(fcode_env_t *env) = do_bloop;
477c478bd9Sstevel@tonic-gate void (*do_ploop_ptr)(fcode_env_t *env) = do_bploop;
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate void unaligned_lstore(fcode_env_t *);
507c478bd9Sstevel@tonic-gate void unaligned_wstore(fcode_env_t *);
517c478bd9Sstevel@tonic-gate void unaligned_lfetch(fcode_env_t *);
527c478bd9Sstevel@tonic-gate void unaligned_wfetch(fcode_env_t *);
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate /* start with the simple maths functions */
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate void
add(fcode_env_t * env)587c478bd9Sstevel@tonic-gate add(fcode_env_t *env)
597c478bd9Sstevel@tonic-gate {
607c478bd9Sstevel@tonic-gate 	fstack_t d;
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "+");
637c478bd9Sstevel@tonic-gate 	d = POP(DS);
647c478bd9Sstevel@tonic-gate 	TOS += d;
657c478bd9Sstevel@tonic-gate }
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate void
subtract(fcode_env_t * env)687c478bd9Sstevel@tonic-gate subtract(fcode_env_t *env)
697c478bd9Sstevel@tonic-gate {
707c478bd9Sstevel@tonic-gate 	fstack_t d;
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "-");
737c478bd9Sstevel@tonic-gate 	d = POP(DS);
747c478bd9Sstevel@tonic-gate 	TOS -= d;
757c478bd9Sstevel@tonic-gate }
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate void
multiply(fcode_env_t * env)787c478bd9Sstevel@tonic-gate multiply(fcode_env_t *env)
797c478bd9Sstevel@tonic-gate {
807c478bd9Sstevel@tonic-gate 	fstack_t d;
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "*");
837c478bd9Sstevel@tonic-gate 	d = POP(DS);
847c478bd9Sstevel@tonic-gate 	TOS *= d;
857c478bd9Sstevel@tonic-gate }
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate void
slash_mod(fcode_env_t * env)887c478bd9Sstevel@tonic-gate slash_mod(fcode_env_t *env)
897c478bd9Sstevel@tonic-gate {
907c478bd9Sstevel@tonic-gate 	fstack_t d, o, t, rem;
917c478bd9Sstevel@tonic-gate 	int sign = 1;
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "/mod");
947c478bd9Sstevel@tonic-gate 	d = POP(DS);
957c478bd9Sstevel@tonic-gate 	o = t = POP(DS);
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate 	if (d == 0) {
987c478bd9Sstevel@tonic-gate 		throw_from_fclib(env, 1, "/mod divide by zero");
997c478bd9Sstevel@tonic-gate 	}
1007c478bd9Sstevel@tonic-gate 	sign = ((d ^ t) < 0);
1017c478bd9Sstevel@tonic-gate 	if (d < 0) {
1027c478bd9Sstevel@tonic-gate 		d = -d;
1037c478bd9Sstevel@tonic-gate 		if (sign) {
1047c478bd9Sstevel@tonic-gate 			t += (d-1);
1057c478bd9Sstevel@tonic-gate 		}
1067c478bd9Sstevel@tonic-gate 	}
1077c478bd9Sstevel@tonic-gate 	if (t < 0) {
1087c478bd9Sstevel@tonic-gate 		if (sign) {
1097c478bd9Sstevel@tonic-gate 			t -= (d-1);
1107c478bd9Sstevel@tonic-gate 		}
1117c478bd9Sstevel@tonic-gate 		t = -t;
1127c478bd9Sstevel@tonic-gate 	}
1137c478bd9Sstevel@tonic-gate 	t = t / d;
1147c478bd9Sstevel@tonic-gate 	if ((o ^ sign) < 0) {
1157c478bd9Sstevel@tonic-gate 		rem = (t * d) + o;
1167c478bd9Sstevel@tonic-gate 	} else {
1177c478bd9Sstevel@tonic-gate 		rem = o - (t*d);
1187c478bd9Sstevel@tonic-gate 	}
1197c478bd9Sstevel@tonic-gate 	if (sign) {
1207c478bd9Sstevel@tonic-gate 		t = -t;
1217c478bd9Sstevel@tonic-gate 	}
1227c478bd9Sstevel@tonic-gate 	PUSH(DS, rem);
1237c478bd9Sstevel@tonic-gate 	PUSH(DS, t);
1247c478bd9Sstevel@tonic-gate }
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate /*
1277c478bd9Sstevel@tonic-gate  * 'u/mod' Fcode implementation.
1287c478bd9Sstevel@tonic-gate  */
1297c478bd9Sstevel@tonic-gate void
uslash_mod(fcode_env_t * env)1307c478bd9Sstevel@tonic-gate uslash_mod(fcode_env_t *env)
1317c478bd9Sstevel@tonic-gate {
1327c478bd9Sstevel@tonic-gate 	u_lforth_t u1, u2;
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "u/mod");
1357c478bd9Sstevel@tonic-gate 	u2 = POP(DS);
1367c478bd9Sstevel@tonic-gate 	u1 = POP(DS);
1377c478bd9Sstevel@tonic-gate 
1387c478bd9Sstevel@tonic-gate 	if (u2 == 0)
1397c478bd9Sstevel@tonic-gate 		forth_abort(env, "u/mod: divide by zero");
1407c478bd9Sstevel@tonic-gate 	PUSH(DS, u1 % u2);
1417c478bd9Sstevel@tonic-gate 	PUSH(DS, u1 / u2);
1427c478bd9Sstevel@tonic-gate }
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate void
divide(fcode_env_t * env)1457c478bd9Sstevel@tonic-gate divide(fcode_env_t *env)
1467c478bd9Sstevel@tonic-gate {
1477c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "/");
1487c478bd9Sstevel@tonic-gate 	slash_mod(env);
1497c478bd9Sstevel@tonic-gate 	nip(env);
1507c478bd9Sstevel@tonic-gate }
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate void
mod(fcode_env_t * env)1537c478bd9Sstevel@tonic-gate mod(fcode_env_t *env)
1547c478bd9Sstevel@tonic-gate {
1557c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "mod");
1567c478bd9Sstevel@tonic-gate 	slash_mod(env);
1577c478bd9Sstevel@tonic-gate 	drop(env);
1587c478bd9Sstevel@tonic-gate }
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate void
and(fcode_env_t * env)1617c478bd9Sstevel@tonic-gate and(fcode_env_t *env)
1627c478bd9Sstevel@tonic-gate {
1637c478bd9Sstevel@tonic-gate 	fstack_t d;
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "and");
1667c478bd9Sstevel@tonic-gate 	d = POP(DS);
1677c478bd9Sstevel@tonic-gate 	TOS &= d;
1687c478bd9Sstevel@tonic-gate }
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate void
or(fcode_env_t * env)1717c478bd9Sstevel@tonic-gate or(fcode_env_t *env)
1727c478bd9Sstevel@tonic-gate {
1737c478bd9Sstevel@tonic-gate 	fstack_t d;
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "or");
1767c478bd9Sstevel@tonic-gate 	d = POP(DS);
1777c478bd9Sstevel@tonic-gate 	TOS |= d;
1787c478bd9Sstevel@tonic-gate }
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate void
xor(fcode_env_t * env)1817c478bd9Sstevel@tonic-gate xor(fcode_env_t *env)
1827c478bd9Sstevel@tonic-gate {
1837c478bd9Sstevel@tonic-gate 	fstack_t d;
1847c478bd9Sstevel@tonic-gate 
1857c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "xor");
1867c478bd9Sstevel@tonic-gate 	d = POP(DS);
1877c478bd9Sstevel@tonic-gate 	TOS ^= d;
1887c478bd9Sstevel@tonic-gate }
1897c478bd9Sstevel@tonic-gate 
1907c478bd9Sstevel@tonic-gate void
invert(fcode_env_t * env)1917c478bd9Sstevel@tonic-gate invert(fcode_env_t *env)
1927c478bd9Sstevel@tonic-gate {
1937c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "invert");
1947c478bd9Sstevel@tonic-gate 	TOS = ~TOS;
1957c478bd9Sstevel@tonic-gate }
1967c478bd9Sstevel@tonic-gate 
1977c478bd9Sstevel@tonic-gate void
lshift(fcode_env_t * env)1987c478bd9Sstevel@tonic-gate lshift(fcode_env_t *env)
1997c478bd9Sstevel@tonic-gate {
2007c478bd9Sstevel@tonic-gate 	fstack_t d;
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "lshift");
2037c478bd9Sstevel@tonic-gate 	d = POP(DS);
2047c478bd9Sstevel@tonic-gate 	TOS = TOS << d;
2057c478bd9Sstevel@tonic-gate }
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate void
rshift(fcode_env_t * env)2087c478bd9Sstevel@tonic-gate rshift(fcode_env_t *env)
2097c478bd9Sstevel@tonic-gate {
2107c478bd9Sstevel@tonic-gate 	fstack_t d;
2117c478bd9Sstevel@tonic-gate 
2127c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "rshift");
2137c478bd9Sstevel@tonic-gate 	d = POP(DS);
2147c478bd9Sstevel@tonic-gate 	TOS = ((ufstack_t)TOS) >> d;
2157c478bd9Sstevel@tonic-gate }
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate void
rshifta(fcode_env_t * env)2187c478bd9Sstevel@tonic-gate rshifta(fcode_env_t *env)
2197c478bd9Sstevel@tonic-gate {
2207c478bd9Sstevel@tonic-gate 	fstack_t d;
2217c478bd9Sstevel@tonic-gate 
2227c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, ">>a");
2237c478bd9Sstevel@tonic-gate 	d = POP(DS);
2247c478bd9Sstevel@tonic-gate 	TOS = ((s_lforth_t)TOS) >> d;
2257c478bd9Sstevel@tonic-gate }
2267c478bd9Sstevel@tonic-gate 
2277c478bd9Sstevel@tonic-gate void
negate(fcode_env_t * env)2287c478bd9Sstevel@tonic-gate negate(fcode_env_t *env)
2297c478bd9Sstevel@tonic-gate {
2307c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "negate");
2317c478bd9Sstevel@tonic-gate 	TOS = -TOS;
2327c478bd9Sstevel@tonic-gate }
2337c478bd9Sstevel@tonic-gate 
2347c478bd9Sstevel@tonic-gate void
f_abs(fcode_env_t * env)2357c478bd9Sstevel@tonic-gate f_abs(fcode_env_t *env)
2367c478bd9Sstevel@tonic-gate {
2377c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "abs");
2387c478bd9Sstevel@tonic-gate 	if (TOS < 0) TOS = -TOS;
2397c478bd9Sstevel@tonic-gate }
2407c478bd9Sstevel@tonic-gate 
2417c478bd9Sstevel@tonic-gate void
f_min(fcode_env_t * env)2427c478bd9Sstevel@tonic-gate f_min(fcode_env_t *env)
2437c478bd9Sstevel@tonic-gate {
2447c478bd9Sstevel@tonic-gate 	fstack_t d;
2457c478bd9Sstevel@tonic-gate 
2467c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "min");
2477c478bd9Sstevel@tonic-gate 	d = POP(DS);
2487c478bd9Sstevel@tonic-gate 	if (d < TOS)	TOS = d;
2497c478bd9Sstevel@tonic-gate }
2507c478bd9Sstevel@tonic-gate 
2517c478bd9Sstevel@tonic-gate void
f_max(fcode_env_t * env)2527c478bd9Sstevel@tonic-gate f_max(fcode_env_t *env)
2537c478bd9Sstevel@tonic-gate {
2547c478bd9Sstevel@tonic-gate 	fstack_t d;
2557c478bd9Sstevel@tonic-gate 
2567c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "max");
2577c478bd9Sstevel@tonic-gate 	d = POP(DS);
2587c478bd9Sstevel@tonic-gate 	if (d > TOS)	TOS = d;
2597c478bd9Sstevel@tonic-gate }
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate void
to_r(fcode_env_t * env)2627c478bd9Sstevel@tonic-gate to_r(fcode_env_t *env)
2637c478bd9Sstevel@tonic-gate {
2647c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, ">r");
2657c478bd9Sstevel@tonic-gate 	PUSH(RS, POP(DS));
2667c478bd9Sstevel@tonic-gate }
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate void
from_r(fcode_env_t * env)2697c478bd9Sstevel@tonic-gate from_r(fcode_env_t *env)
2707c478bd9Sstevel@tonic-gate {
2717c478bd9Sstevel@tonic-gate 	CHECK_RETURN_DEPTH(env, 1, "r>");
2727c478bd9Sstevel@tonic-gate 	PUSH(DS, POP(RS));
2737c478bd9Sstevel@tonic-gate }
2747c478bd9Sstevel@tonic-gate 
2757c478bd9Sstevel@tonic-gate void
rfetch(fcode_env_t * env)2767c478bd9Sstevel@tonic-gate rfetch(fcode_env_t *env)
2777c478bd9Sstevel@tonic-gate {
2787c478bd9Sstevel@tonic-gate 	CHECK_RETURN_DEPTH(env, 1, "r@");
2797c478bd9Sstevel@tonic-gate 	PUSH(DS, *RS);
2807c478bd9Sstevel@tonic-gate }
2817c478bd9Sstevel@tonic-gate 
2827c478bd9Sstevel@tonic-gate void
f_exit(fcode_env_t * env)2837c478bd9Sstevel@tonic-gate f_exit(fcode_env_t *env)
2847c478bd9Sstevel@tonic-gate {
2857c478bd9Sstevel@tonic-gate 	CHECK_RETURN_DEPTH(env, 1, "exit");
2867c478bd9Sstevel@tonic-gate 	IP = (token_t *)POP(RS);
2877c478bd9Sstevel@tonic-gate }
2887c478bd9Sstevel@tonic-gate 
2897c478bd9Sstevel@tonic-gate #define	COMPARE(cmp, rhs)	((((s_lforth_t)TOS) cmp((s_lforth_t)(rhs))) ? \
2907c478bd9Sstevel@tonic-gate 				    TRUE : FALSE)
2917c478bd9Sstevel@tonic-gate #define	UCOMPARE(cmp, rhs) 	((((u_lforth_t)TOS) cmp((u_lforth_t)(rhs))) ? \
2927c478bd9Sstevel@tonic-gate 				    TRUE : FALSE)
2937c478bd9Sstevel@tonic-gate #define	EQUALS		==
2947c478bd9Sstevel@tonic-gate #define	NOTEQUALS	!=
2957c478bd9Sstevel@tonic-gate #define	LESSTHAN	<
2967c478bd9Sstevel@tonic-gate #define	LESSEQUALS	<=
2977c478bd9Sstevel@tonic-gate #define	GREATERTHAN	>
2987c478bd9Sstevel@tonic-gate #define	GREATEREQUALS	>=
2997c478bd9Sstevel@tonic-gate 
3007c478bd9Sstevel@tonic-gate void
zero_equals(fcode_env_t * env)3017c478bd9Sstevel@tonic-gate zero_equals(fcode_env_t *env)
3027c478bd9Sstevel@tonic-gate {
3037c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "0=");
3047c478bd9Sstevel@tonic-gate 	TOS = COMPARE(EQUALS, 0);
3057c478bd9Sstevel@tonic-gate }
3067c478bd9Sstevel@tonic-gate 
3077c478bd9Sstevel@tonic-gate void
zero_not_equals(fcode_env_t * env)3087c478bd9Sstevel@tonic-gate zero_not_equals(fcode_env_t *env)
3097c478bd9Sstevel@tonic-gate {
3107c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "0<>");
3117c478bd9Sstevel@tonic-gate 	TOS = COMPARE(NOTEQUALS, 0);
3127c478bd9Sstevel@tonic-gate }
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate void
zero_less(fcode_env_t * env)3157c478bd9Sstevel@tonic-gate zero_less(fcode_env_t *env)
3167c478bd9Sstevel@tonic-gate {
3177c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "0<");
3187c478bd9Sstevel@tonic-gate 	TOS = COMPARE(LESSTHAN, 0);
3197c478bd9Sstevel@tonic-gate }
3207c478bd9Sstevel@tonic-gate 
3217c478bd9Sstevel@tonic-gate void
zero_less_equals(fcode_env_t * env)3227c478bd9Sstevel@tonic-gate zero_less_equals(fcode_env_t *env)
3237c478bd9Sstevel@tonic-gate {
3247c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "0<=");
3257c478bd9Sstevel@tonic-gate 	TOS = COMPARE(LESSEQUALS, 0);
3267c478bd9Sstevel@tonic-gate }
3277c478bd9Sstevel@tonic-gate 
3287c478bd9Sstevel@tonic-gate void
zero_greater(fcode_env_t * env)3297c478bd9Sstevel@tonic-gate zero_greater(fcode_env_t *env)
3307c478bd9Sstevel@tonic-gate {
3317c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "0>");
3327c478bd9Sstevel@tonic-gate 	TOS = COMPARE(GREATERTHAN, 0);
3337c478bd9Sstevel@tonic-gate }
3347c478bd9Sstevel@tonic-gate 
3357c478bd9Sstevel@tonic-gate void
zero_greater_equals(fcode_env_t * env)3367c478bd9Sstevel@tonic-gate zero_greater_equals(fcode_env_t *env)
3377c478bd9Sstevel@tonic-gate {
3387c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "0>=");
3397c478bd9Sstevel@tonic-gate 	TOS = COMPARE(GREATEREQUALS, 0);
3407c478bd9Sstevel@tonic-gate }
3417c478bd9Sstevel@tonic-gate 
3427c478bd9Sstevel@tonic-gate void
less(fcode_env_t * env)3437c478bd9Sstevel@tonic-gate less(fcode_env_t *env)
3447c478bd9Sstevel@tonic-gate {
3457c478bd9Sstevel@tonic-gate 	fstack_t d;
3467c478bd9Sstevel@tonic-gate 
3477c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "<");
3487c478bd9Sstevel@tonic-gate 	d = POP(DS);
3497c478bd9Sstevel@tonic-gate 	TOS = COMPARE(LESSTHAN, d);
3507c478bd9Sstevel@tonic-gate }
3517c478bd9Sstevel@tonic-gate 
3527c478bd9Sstevel@tonic-gate void
greater(fcode_env_t * env)3537c478bd9Sstevel@tonic-gate greater(fcode_env_t *env)
3547c478bd9Sstevel@tonic-gate {
3557c478bd9Sstevel@tonic-gate 	fstack_t d;
3567c478bd9Sstevel@tonic-gate 
3577c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, ">");
3587c478bd9Sstevel@tonic-gate 	d = POP(DS);
3597c478bd9Sstevel@tonic-gate 	TOS = COMPARE(GREATERTHAN, d);
3607c478bd9Sstevel@tonic-gate }
3617c478bd9Sstevel@tonic-gate 
3627c478bd9Sstevel@tonic-gate void
equals(fcode_env_t * env)3637c478bd9Sstevel@tonic-gate equals(fcode_env_t *env)
3647c478bd9Sstevel@tonic-gate {
3657c478bd9Sstevel@tonic-gate 	fstack_t d;
3667c478bd9Sstevel@tonic-gate 
3677c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "=");
3687c478bd9Sstevel@tonic-gate 	d = POP(DS);
3697c478bd9Sstevel@tonic-gate 	TOS = COMPARE(EQUALS, d);
3707c478bd9Sstevel@tonic-gate }
3717c478bd9Sstevel@tonic-gate 
3727c478bd9Sstevel@tonic-gate void
not_equals(fcode_env_t * env)3737c478bd9Sstevel@tonic-gate not_equals(fcode_env_t *env)
3747c478bd9Sstevel@tonic-gate {
3757c478bd9Sstevel@tonic-gate 	fstack_t d;
3767c478bd9Sstevel@tonic-gate 
3777c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "<>");
3787c478bd9Sstevel@tonic-gate 	d = POP(DS);
3797c478bd9Sstevel@tonic-gate 	TOS = COMPARE(NOTEQUALS, d);
3807c478bd9Sstevel@tonic-gate }
3817c478bd9Sstevel@tonic-gate 
3827c478bd9Sstevel@tonic-gate 
3837c478bd9Sstevel@tonic-gate void
unsign_greater(fcode_env_t * env)3847c478bd9Sstevel@tonic-gate unsign_greater(fcode_env_t *env)
3857c478bd9Sstevel@tonic-gate {
3867c478bd9Sstevel@tonic-gate 	ufstack_t d;
3877c478bd9Sstevel@tonic-gate 
3887c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "u>");
3897c478bd9Sstevel@tonic-gate 	d = POP(DS);
3907c478bd9Sstevel@tonic-gate 	TOS = UCOMPARE(GREATERTHAN, d);
3917c478bd9Sstevel@tonic-gate }
3927c478bd9Sstevel@tonic-gate 
3937c478bd9Sstevel@tonic-gate void
unsign_less_equals(fcode_env_t * env)3947c478bd9Sstevel@tonic-gate unsign_less_equals(fcode_env_t *env)
3957c478bd9Sstevel@tonic-gate {
3967c478bd9Sstevel@tonic-gate 	ufstack_t d;
3977c478bd9Sstevel@tonic-gate 
3987c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "u<=");
3997c478bd9Sstevel@tonic-gate 	d = POP(DS);
4007c478bd9Sstevel@tonic-gate 	TOS = UCOMPARE(LESSEQUALS, d);
4017c478bd9Sstevel@tonic-gate }
4027c478bd9Sstevel@tonic-gate 
4037c478bd9Sstevel@tonic-gate void
unsign_less(fcode_env_t * env)4047c478bd9Sstevel@tonic-gate unsign_less(fcode_env_t *env)
4057c478bd9Sstevel@tonic-gate {
4067c478bd9Sstevel@tonic-gate 	ufstack_t d;
4077c478bd9Sstevel@tonic-gate 
4087c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "u<");
4097c478bd9Sstevel@tonic-gate 	d = POP(DS);
4107c478bd9Sstevel@tonic-gate 	TOS = UCOMPARE(LESSTHAN, d);
4117c478bd9Sstevel@tonic-gate }
4127c478bd9Sstevel@tonic-gate 
4137c478bd9Sstevel@tonic-gate void
unsign_greater_equals(fcode_env_t * env)4147c478bd9Sstevel@tonic-gate unsign_greater_equals(fcode_env_t *env)
4157c478bd9Sstevel@tonic-gate {
4167c478bd9Sstevel@tonic-gate 	ufstack_t d;
4177c478bd9Sstevel@tonic-gate 
4187c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "u>=");
4197c478bd9Sstevel@tonic-gate 	d = POP(DS);
4207c478bd9Sstevel@tonic-gate 	TOS = UCOMPARE(GREATEREQUALS, d);
4217c478bd9Sstevel@tonic-gate }
4227c478bd9Sstevel@tonic-gate 
4237c478bd9Sstevel@tonic-gate void
greater_equals(fcode_env_t * env)4247c478bd9Sstevel@tonic-gate greater_equals(fcode_env_t *env)
4257c478bd9Sstevel@tonic-gate {
4267c478bd9Sstevel@tonic-gate 	fstack_t d;
4277c478bd9Sstevel@tonic-gate 
4287c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, ">=");
4297c478bd9Sstevel@tonic-gate 	d = POP(DS);
4307c478bd9Sstevel@tonic-gate 	TOS = COMPARE(GREATEREQUALS, d);
4317c478bd9Sstevel@tonic-gate }
4327c478bd9Sstevel@tonic-gate 
4337c478bd9Sstevel@tonic-gate void
less_equals(fcode_env_t * env)4347c478bd9Sstevel@tonic-gate less_equals(fcode_env_t *env)
4357c478bd9Sstevel@tonic-gate {
4367c478bd9Sstevel@tonic-gate 	fstack_t d;
4377c478bd9Sstevel@tonic-gate 
4387c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "<=");
4397c478bd9Sstevel@tonic-gate 	d = POP(DS);
4407c478bd9Sstevel@tonic-gate 	TOS = COMPARE(LESSEQUALS, d);
4417c478bd9Sstevel@tonic-gate }
4427c478bd9Sstevel@tonic-gate 
4437c478bd9Sstevel@tonic-gate void
between(fcode_env_t * env)4447c478bd9Sstevel@tonic-gate between(fcode_env_t *env)
4457c478bd9Sstevel@tonic-gate {
446*3aa1cd26Sgovinda 	u_lforth_t hi, lo;
4477c478bd9Sstevel@tonic-gate 
4487c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 3, "between");
449*3aa1cd26Sgovinda 	hi = (u_lforth_t)POP(DS);
450*3aa1cd26Sgovinda 	lo = (u_lforth_t)POP(DS);
451*3aa1cd26Sgovinda 	TOS = (((u_lforth_t)TOS >= lo) && ((u_lforth_t)TOS <= hi) ? -1 : 0);
4527c478bd9Sstevel@tonic-gate }
4537c478bd9Sstevel@tonic-gate 
4547c478bd9Sstevel@tonic-gate void
within(fcode_env_t * env)4557c478bd9Sstevel@tonic-gate within(fcode_env_t *env)
4567c478bd9Sstevel@tonic-gate {
457*3aa1cd26Sgovinda 	u_lforth_t lo, hi;
4587c478bd9Sstevel@tonic-gate 
4597c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 3, "within");
460*3aa1cd26Sgovinda 	hi = (u_lforth_t)POP(DS);
461*3aa1cd26Sgovinda 	lo = (u_lforth_t)POP(DS);
462*3aa1cd26Sgovinda 	TOS = ((((u_lforth_t)TOS >= lo) && ((u_lforth_t)TOS < hi)) ? -1 : 0);
4637c478bd9Sstevel@tonic-gate }
4647c478bd9Sstevel@tonic-gate 
4657c478bd9Sstevel@tonic-gate void
do_literal(fcode_env_t * env)4667c478bd9Sstevel@tonic-gate do_literal(fcode_env_t *env)
4677c478bd9Sstevel@tonic-gate {
4687c478bd9Sstevel@tonic-gate 	PUSH(DS, *IP);
4697c478bd9Sstevel@tonic-gate 	IP++;
4707c478bd9Sstevel@tonic-gate }
4717c478bd9Sstevel@tonic-gate 
4727c478bd9Sstevel@tonic-gate void
literal(fcode_env_t * env)4737c478bd9Sstevel@tonic-gate literal(fcode_env_t *env)
4747c478bd9Sstevel@tonic-gate {
4757c478bd9Sstevel@tonic-gate 	if (env->state) {
4767c478bd9Sstevel@tonic-gate 		COMPILE_TOKEN(&blit_ptr);
4777c478bd9Sstevel@tonic-gate 		compile_comma(env);
4787c478bd9Sstevel@tonic-gate 	}
4797c478bd9Sstevel@tonic-gate }
4807c478bd9Sstevel@tonic-gate 
4817c478bd9Sstevel@tonic-gate void
do_also(fcode_env_t * env)4827c478bd9Sstevel@tonic-gate do_also(fcode_env_t *env)
4837c478bd9Sstevel@tonic-gate {
4847c478bd9Sstevel@tonic-gate 	token_t *d = *ORDER;
4857c478bd9Sstevel@tonic-gate 
4867c478bd9Sstevel@tonic-gate 	if (env->order_depth < (MAX_ORDER - 1)) {
4877c478bd9Sstevel@tonic-gate 		env->order[++env->order_depth] = d;
4887c478bd9Sstevel@tonic-gate 		debug_msg(DEBUG_CONTEXT, "CONTEXT:also: %d/%p/%p\n",
4897c478bd9Sstevel@tonic-gate 		    env->order_depth, CONTEXT, env->current);
4907c478bd9Sstevel@tonic-gate 	} else
4917c478bd9Sstevel@tonic-gate 		log_message(MSG_WARN, "Vocabulary search order exceeds: %d\n",
4927c478bd9Sstevel@tonic-gate 		    MAX_ORDER);
4937c478bd9Sstevel@tonic-gate }
4947c478bd9Sstevel@tonic-gate 
4957c478bd9Sstevel@tonic-gate void
do_previous(fcode_env_t * env)4967c478bd9Sstevel@tonic-gate do_previous(fcode_env_t *env)
4977c478bd9Sstevel@tonic-gate {
4987c478bd9Sstevel@tonic-gate 	if (env->order_depth) {
4997c478bd9Sstevel@tonic-gate 		env->order_depth--;
5007c478bd9Sstevel@tonic-gate 		debug_msg(DEBUG_CONTEXT, "CONTEXT:previous: %d/%p/%p\n",
5017c478bd9Sstevel@tonic-gate 		    env->order_depth, CONTEXT, env->current);
5027c478bd9Sstevel@tonic-gate 	}
5037c478bd9Sstevel@tonic-gate }
5047c478bd9Sstevel@tonic-gate 
5057c478bd9Sstevel@tonic-gate #ifdef DEBUG
5067c478bd9Sstevel@tonic-gate void
do_order(fcode_env_t * env)5077c478bd9Sstevel@tonic-gate do_order(fcode_env_t *env)
5087c478bd9Sstevel@tonic-gate {
5097c478bd9Sstevel@tonic-gate 	int i;
5107c478bd9Sstevel@tonic-gate 
5117c478bd9Sstevel@tonic-gate 	log_message(MSG_INFO, "Order: Depth: %ld: ", env->order_depth);
5127c478bd9Sstevel@tonic-gate 	for (i = env->order_depth; i >= 0 && env->order[i]; i--)
5137c478bd9Sstevel@tonic-gate 		log_message(MSG_INFO, "%p ", (void *)env->order[i]);
5147c478bd9Sstevel@tonic-gate 	log_message(MSG_INFO, "\n");
5157c478bd9Sstevel@tonic-gate }
5167c478bd9Sstevel@tonic-gate #endif
5177c478bd9Sstevel@tonic-gate 
5187c478bd9Sstevel@tonic-gate void
noop(fcode_env_t * env)5197c478bd9Sstevel@tonic-gate noop(fcode_env_t *env)
5207c478bd9Sstevel@tonic-gate {
5217c478bd9Sstevel@tonic-gate 	/* what a waste of cycles */
5227c478bd9Sstevel@tonic-gate }
5237c478bd9Sstevel@tonic-gate 
5247c478bd9Sstevel@tonic-gate 
5257c478bd9Sstevel@tonic-gate #define	FW_PER_FL	(sizeof (lforth_t)/sizeof (wforth_t))
5267c478bd9Sstevel@tonic-gate 
5277c478bd9Sstevel@tonic-gate void
lwsplit(fcode_env_t * env)5287c478bd9Sstevel@tonic-gate lwsplit(fcode_env_t *env)
5297c478bd9Sstevel@tonic-gate {
5307c478bd9Sstevel@tonic-gate 	union {
5317c478bd9Sstevel@tonic-gate 		u_wforth_t l_wf[FW_PER_FL];
5327c478bd9Sstevel@tonic-gate 		u_lforth_t l_lf;
5337c478bd9Sstevel@tonic-gate 	} d;
5347c478bd9Sstevel@tonic-gate 	int i;
5357c478bd9Sstevel@tonic-gate 
5367c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "lwsplit");
5377c478bd9Sstevel@tonic-gate 	d.l_lf = POP(DS);
5387c478bd9Sstevel@tonic-gate 	for (i = 0; i < FW_PER_FL; i++)
5397c478bd9Sstevel@tonic-gate 		PUSH(DS, d.l_wf[(FW_PER_FL - 1) - i]);
5407c478bd9Sstevel@tonic-gate }
5417c478bd9Sstevel@tonic-gate 
5427c478bd9Sstevel@tonic-gate void
wljoin(fcode_env_t * env)5437c478bd9Sstevel@tonic-gate wljoin(fcode_env_t *env)
5447c478bd9Sstevel@tonic-gate {
5457c478bd9Sstevel@tonic-gate 	union {
5467c478bd9Sstevel@tonic-gate 		u_wforth_t l_wf[FW_PER_FL];
5477c478bd9Sstevel@tonic-gate 		u_lforth_t l_lf;
5487c478bd9Sstevel@tonic-gate 	} d;
5497c478bd9Sstevel@tonic-gate 	int i;
5507c478bd9Sstevel@tonic-gate 
5517c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, FW_PER_FL, "wljoin");
5527c478bd9Sstevel@tonic-gate 	for (i = 0; i < FW_PER_FL; i++)
5537c478bd9Sstevel@tonic-gate 		d.l_wf[i] = POP(DS);
5547c478bd9Sstevel@tonic-gate 	PUSH(DS, d.l_lf);
5557c478bd9Sstevel@tonic-gate }
5567c478bd9Sstevel@tonic-gate 
5577c478bd9Sstevel@tonic-gate void
lwflip(fcode_env_t * env)5587c478bd9Sstevel@tonic-gate lwflip(fcode_env_t *env)
5597c478bd9Sstevel@tonic-gate {
5607c478bd9Sstevel@tonic-gate 	union {
5617c478bd9Sstevel@tonic-gate 		u_wforth_t l_wf[FW_PER_FL];
5627c478bd9Sstevel@tonic-gate 		u_lforth_t l_lf;
5637c478bd9Sstevel@tonic-gate 	} d, c;
5647c478bd9Sstevel@tonic-gate 	int i;
5657c478bd9Sstevel@tonic-gate 
5667c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "lwflip");
5677c478bd9Sstevel@tonic-gate 	d.l_lf = POP(DS);
5687c478bd9Sstevel@tonic-gate 	for (i = 0; i < FW_PER_FL; i++)
5697c478bd9Sstevel@tonic-gate 		c.l_wf[i] = d.l_wf[(FW_PER_FL - 1) - i];
5707c478bd9Sstevel@tonic-gate 	PUSH(DS, c.l_lf);
5717c478bd9Sstevel@tonic-gate }
5727c478bd9Sstevel@tonic-gate 
5737c478bd9Sstevel@tonic-gate void
lbsplit(fcode_env_t * env)5747c478bd9Sstevel@tonic-gate lbsplit(fcode_env_t *env)
5757c478bd9Sstevel@tonic-gate {
5767c478bd9Sstevel@tonic-gate 	union {
5777c478bd9Sstevel@tonic-gate 		uchar_t l_bytes[sizeof (lforth_t)];
5787c478bd9Sstevel@tonic-gate 		u_lforth_t l_lf;
5797c478bd9Sstevel@tonic-gate 	} d;
5807c478bd9Sstevel@tonic-gate 	int i;
5817c478bd9Sstevel@tonic-gate 
5827c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "lbsplit");
5837c478bd9Sstevel@tonic-gate 	d.l_lf = POP(DS);
5847c478bd9Sstevel@tonic-gate 	for (i = 0; i < sizeof (lforth_t); i++)
5857c478bd9Sstevel@tonic-gate 		PUSH(DS, d.l_bytes[(sizeof (lforth_t) - 1) - i]);
5867c478bd9Sstevel@tonic-gate }
5877c478bd9Sstevel@tonic-gate 
5887c478bd9Sstevel@tonic-gate void
bljoin(fcode_env_t * env)5897c478bd9Sstevel@tonic-gate bljoin(fcode_env_t *env)
5907c478bd9Sstevel@tonic-gate {
5917c478bd9Sstevel@tonic-gate 	union {
5927c478bd9Sstevel@tonic-gate 		uchar_t l_bytes[sizeof (lforth_t)];
5937c478bd9Sstevel@tonic-gate 		u_lforth_t l_lf;
5947c478bd9Sstevel@tonic-gate 	} d;
5957c478bd9Sstevel@tonic-gate 	int i;
5967c478bd9Sstevel@tonic-gate 
5977c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, sizeof (lforth_t), "bljoin");
5987c478bd9Sstevel@tonic-gate 	for (i = 0; i < sizeof (lforth_t); i++)
5997c478bd9Sstevel@tonic-gate 		d.l_bytes[i] = POP(DS);
6007c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)d.l_lf);
6017c478bd9Sstevel@tonic-gate }
6027c478bd9Sstevel@tonic-gate 
6037c478bd9Sstevel@tonic-gate void
lbflip(fcode_env_t * env)6047c478bd9Sstevel@tonic-gate lbflip(fcode_env_t *env)
6057c478bd9Sstevel@tonic-gate {
6067c478bd9Sstevel@tonic-gate 	union {
6077c478bd9Sstevel@tonic-gate 		uchar_t l_bytes[sizeof (lforth_t)];
6087c478bd9Sstevel@tonic-gate 		u_lforth_t l_lf;
6097c478bd9Sstevel@tonic-gate 	} d, c;
6107c478bd9Sstevel@tonic-gate 	int i;
6117c478bd9Sstevel@tonic-gate 
6127c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "lbflip");
6137c478bd9Sstevel@tonic-gate 	d.l_lf = POP(DS);
6147c478bd9Sstevel@tonic-gate 	for (i = 0; i < sizeof (lforth_t); i++)
6157c478bd9Sstevel@tonic-gate 		c.l_bytes[i] = d.l_bytes[(sizeof (lforth_t) - 1) - i];
6167c478bd9Sstevel@tonic-gate 	PUSH(DS, c.l_lf);
6177c478bd9Sstevel@tonic-gate }
6187c478bd9Sstevel@tonic-gate 
6197c478bd9Sstevel@tonic-gate void
wbsplit(fcode_env_t * env)6207c478bd9Sstevel@tonic-gate wbsplit(fcode_env_t *env)
6217c478bd9Sstevel@tonic-gate {
6227c478bd9Sstevel@tonic-gate 	union {
6237c478bd9Sstevel@tonic-gate 		uchar_t w_bytes[sizeof (wforth_t)];
6247c478bd9Sstevel@tonic-gate 		u_wforth_t w_wf;
6257c478bd9Sstevel@tonic-gate 	} d;
6267c478bd9Sstevel@tonic-gate 	int i;
6277c478bd9Sstevel@tonic-gate 
6287c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "wbsplit");
6297c478bd9Sstevel@tonic-gate 	d.w_wf = POP(DS);
6307c478bd9Sstevel@tonic-gate 	for (i = 0; i < sizeof (wforth_t); i++)
6317c478bd9Sstevel@tonic-gate 		PUSH(DS, d.w_bytes[(sizeof (wforth_t) - 1) - i]);
6327c478bd9Sstevel@tonic-gate }
6337c478bd9Sstevel@tonic-gate 
6347c478bd9Sstevel@tonic-gate void
bwjoin(fcode_env_t * env)6357c478bd9Sstevel@tonic-gate bwjoin(fcode_env_t *env)
6367c478bd9Sstevel@tonic-gate {
6377c478bd9Sstevel@tonic-gate 	union {
6387c478bd9Sstevel@tonic-gate 		uchar_t w_bytes[sizeof (wforth_t)];
6397c478bd9Sstevel@tonic-gate 		u_wforth_t w_wf;
6407c478bd9Sstevel@tonic-gate 	} d;
6417c478bd9Sstevel@tonic-gate 	int i;
6427c478bd9Sstevel@tonic-gate 
6437c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, sizeof (wforth_t), "bwjoin");
6447c478bd9Sstevel@tonic-gate 	for (i = 0; i < sizeof (wforth_t); i++)
6457c478bd9Sstevel@tonic-gate 		d.w_bytes[i] = POP(DS);
6467c478bd9Sstevel@tonic-gate 	PUSH(DS, d.w_wf);
6477c478bd9Sstevel@tonic-gate }
6487c478bd9Sstevel@tonic-gate 
6497c478bd9Sstevel@tonic-gate void
wbflip(fcode_env_t * env)6507c478bd9Sstevel@tonic-gate wbflip(fcode_env_t *env)
6517c478bd9Sstevel@tonic-gate {
6527c478bd9Sstevel@tonic-gate 	union {
6537c478bd9Sstevel@tonic-gate 		uchar_t w_bytes[sizeof (wforth_t)];
6547c478bd9Sstevel@tonic-gate 		u_wforth_t w_wf;
6557c478bd9Sstevel@tonic-gate 	} c, d;
6567c478bd9Sstevel@tonic-gate 	int i;
6577c478bd9Sstevel@tonic-gate 
6587c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "wbflip");
6597c478bd9Sstevel@tonic-gate 	d.w_wf = POP(DS);
6607c478bd9Sstevel@tonic-gate 	for (i = 0; i < sizeof (wforth_t); i++)
6617c478bd9Sstevel@tonic-gate 		c.w_bytes[i] = d.w_bytes[(sizeof (wforth_t) - 1) - i];
6627c478bd9Sstevel@tonic-gate 	PUSH(DS, c.w_wf);
6637c478bd9Sstevel@tonic-gate }
6647c478bd9Sstevel@tonic-gate 
6657c478bd9Sstevel@tonic-gate void
upper_case(fcode_env_t * env)6667c478bd9Sstevel@tonic-gate upper_case(fcode_env_t *env)
6677c478bd9Sstevel@tonic-gate {
6687c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "upc");
6697c478bd9Sstevel@tonic-gate 	TOS = toupper(TOS);
6707c478bd9Sstevel@tonic-gate }
6717c478bd9Sstevel@tonic-gate 
6727c478bd9Sstevel@tonic-gate void
lower_case(fcode_env_t * env)6737c478bd9Sstevel@tonic-gate lower_case(fcode_env_t *env)
6747c478bd9Sstevel@tonic-gate {
6757c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "lcc");
6767c478bd9Sstevel@tonic-gate 	TOS = tolower(TOS);
6777c478bd9Sstevel@tonic-gate }
6787c478bd9Sstevel@tonic-gate 
6797c478bd9Sstevel@tonic-gate void
pack_str(fcode_env_t * env)6807c478bd9Sstevel@tonic-gate pack_str(fcode_env_t *env)
6817c478bd9Sstevel@tonic-gate {
6827c478bd9Sstevel@tonic-gate 	char *buf;
6837c478bd9Sstevel@tonic-gate 	size_t len;
6847c478bd9Sstevel@tonic-gate 	char *str;
6857c478bd9Sstevel@tonic-gate 
6867c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 3, "pack");
6877c478bd9Sstevel@tonic-gate 	buf = (char *)POP(DS);
6887c478bd9Sstevel@tonic-gate 	len = (size_t)POP(DS);
6897c478bd9Sstevel@tonic-gate 	str = (char *)TOS;
6907c478bd9Sstevel@tonic-gate 	TOS = (fstack_t)buf;
6917c478bd9Sstevel@tonic-gate 	*buf++ = (uchar_t)len;
6927c478bd9Sstevel@tonic-gate 	strncpy(buf, str, (len&0xff));
6937c478bd9Sstevel@tonic-gate }
6947c478bd9Sstevel@tonic-gate 
6957c478bd9Sstevel@tonic-gate void
count_str(fcode_env_t * env)6967c478bd9Sstevel@tonic-gate count_str(fcode_env_t *env)
6977c478bd9Sstevel@tonic-gate {
6987c478bd9Sstevel@tonic-gate 	uchar_t *len;
6997c478bd9Sstevel@tonic-gate 
7007c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "count");
7017c478bd9Sstevel@tonic-gate 	len = (uchar_t *)TOS;
7027c478bd9Sstevel@tonic-gate 	TOS += 1;
7037c478bd9Sstevel@tonic-gate 	PUSH(DS, *len);
7047c478bd9Sstevel@tonic-gate }
7057c478bd9Sstevel@tonic-gate 
7067c478bd9Sstevel@tonic-gate void
to_body(fcode_env_t * env)7077c478bd9Sstevel@tonic-gate to_body(fcode_env_t *env)
7087c478bd9Sstevel@tonic-gate {
7097c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, ">body");
7107c478bd9Sstevel@tonic-gate 	TOS = (fstack_t)(((acf_t)TOS)+1);
7117c478bd9Sstevel@tonic-gate }
7127c478bd9Sstevel@tonic-gate 
7137c478bd9Sstevel@tonic-gate void
to_acf(fcode_env_t * env)7147c478bd9Sstevel@tonic-gate to_acf(fcode_env_t *env)
7157c478bd9Sstevel@tonic-gate {
7167c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "body>");
7177c478bd9Sstevel@tonic-gate 	TOS = (fstack_t)(((acf_t)TOS)-1);
7187c478bd9Sstevel@tonic-gate }
7197c478bd9Sstevel@tonic-gate 
7207c478bd9Sstevel@tonic-gate /*
7217c478bd9Sstevel@tonic-gate  * 'unloop' Fcode implementation, drop 3 loop ctrl elements off return stack.
7227c478bd9Sstevel@tonic-gate  */
7237c478bd9Sstevel@tonic-gate static void
unloop(fcode_env_t * env)7247c478bd9Sstevel@tonic-gate unloop(fcode_env_t *env)
7257c478bd9Sstevel@tonic-gate {
7267c478bd9Sstevel@tonic-gate 	CHECK_RETURN_DEPTH(env, 3, "unloop");
7277c478bd9Sstevel@tonic-gate 	RS -= 3;
7287c478bd9Sstevel@tonic-gate }
7297c478bd9Sstevel@tonic-gate 
7307c478bd9Sstevel@tonic-gate /*
7317c478bd9Sstevel@tonic-gate  * 'um*' Fcode implementation.
7327c478bd9Sstevel@tonic-gate  */
7337c478bd9Sstevel@tonic-gate static void
um_multiply(fcode_env_t * env)7347c478bd9Sstevel@tonic-gate um_multiply(fcode_env_t *env)
7357c478bd9Sstevel@tonic-gate {
7367c478bd9Sstevel@tonic-gate 	ufstack_t u1, u2;
7377c478bd9Sstevel@tonic-gate 	dforth_t d;
7387c478bd9Sstevel@tonic-gate 
7397c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "um*");
7407c478bd9Sstevel@tonic-gate 	u1 = POP(DS);
7417c478bd9Sstevel@tonic-gate 	u2 = POP(DS);
7427c478bd9Sstevel@tonic-gate 	d = u1 * u2;
7437c478bd9Sstevel@tonic-gate 	push_double(env, d);
7447c478bd9Sstevel@tonic-gate }
7457c478bd9Sstevel@tonic-gate 
7467c478bd9Sstevel@tonic-gate /*
7477c478bd9Sstevel@tonic-gate  * um/mod (d.lo d.hi u -- urem uquot)
7487c478bd9Sstevel@tonic-gate  */
7497c478bd9Sstevel@tonic-gate static void
um_slash_mod(fcode_env_t * env)7507c478bd9Sstevel@tonic-gate um_slash_mod(fcode_env_t *env)
7517c478bd9Sstevel@tonic-gate {
7527c478bd9Sstevel@tonic-gate 	u_dforth_t d;
7537c478bd9Sstevel@tonic-gate 	uint32_t u, urem, uquot;
7547c478bd9Sstevel@tonic-gate 
7557c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 3, "um/mod");
7567c478bd9Sstevel@tonic-gate 	u = (uint32_t)POP(DS);
7577c478bd9Sstevel@tonic-gate 	d = pop_double(env);
7587c478bd9Sstevel@tonic-gate 	urem = d % u;
7597c478bd9Sstevel@tonic-gate 	uquot = d / u;
7607c478bd9Sstevel@tonic-gate 	PUSH(DS, urem);
7617c478bd9Sstevel@tonic-gate 	PUSH(DS, uquot);
7627c478bd9Sstevel@tonic-gate }
7637c478bd9Sstevel@tonic-gate 
7647c478bd9Sstevel@tonic-gate /*
7657c478bd9Sstevel@tonic-gate  * d+ (d1.lo d1.hi d2.lo d2.hi -- dsum.lo dsum.hi)
7667c478bd9Sstevel@tonic-gate  */
7677c478bd9Sstevel@tonic-gate static void
d_plus(fcode_env_t * env)7687c478bd9Sstevel@tonic-gate d_plus(fcode_env_t *env)
7697c478bd9Sstevel@tonic-gate {
7707c478bd9Sstevel@tonic-gate 	dforth_t d1, d2;
7717c478bd9Sstevel@tonic-gate 
7727c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 4, "d+");
7737c478bd9Sstevel@tonic-gate 	d2 = pop_double(env);
7747c478bd9Sstevel@tonic-gate 	d1 = pop_double(env);
7757c478bd9Sstevel@tonic-gate 	d1 += d2;
7767c478bd9Sstevel@tonic-gate 	push_double(env, d1);
7777c478bd9Sstevel@tonic-gate }
7787c478bd9Sstevel@tonic-gate 
7797c478bd9Sstevel@tonic-gate /*
7807c478bd9Sstevel@tonic-gate  * d- (d1.lo d1.hi d2.lo d2.hi -- ddif.lo ddif.hi)
7817c478bd9Sstevel@tonic-gate  */
7827c478bd9Sstevel@tonic-gate static void
d_minus(fcode_env_t * env)7837c478bd9Sstevel@tonic-gate d_minus(fcode_env_t *env)
7847c478bd9Sstevel@tonic-gate {
7857c478bd9Sstevel@tonic-gate 	dforth_t d1, d2;
7867c478bd9Sstevel@tonic-gate 
7877c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 4, "d-");
7887c478bd9Sstevel@tonic-gate 	d2 = pop_double(env);
7897c478bd9Sstevel@tonic-gate 	d1 = pop_double(env);
7907c478bd9Sstevel@tonic-gate 	d1 -= d2;
7917c478bd9Sstevel@tonic-gate 	push_double(env, d1);
7927c478bd9Sstevel@tonic-gate }
7937c478bd9Sstevel@tonic-gate 
7947c478bd9Sstevel@tonic-gate void
set_here(fcode_env_t * env,uchar_t * new_here,char * where)7957c478bd9Sstevel@tonic-gate set_here(fcode_env_t *env, uchar_t *new_here, char *where)
7967c478bd9Sstevel@tonic-gate {
7977c478bd9Sstevel@tonic-gate 	if (new_here < HERE) {
7987c478bd9Sstevel@tonic-gate 		if (strcmp(where, "temporary_execute")) {
7997c478bd9Sstevel@tonic-gate 			/*
8007c478bd9Sstevel@tonic-gate 			 * Other than temporary_execute, no one should set
8017c478bd9Sstevel@tonic-gate 			 * here backwards.
8027c478bd9Sstevel@tonic-gate 			 */
8037c478bd9Sstevel@tonic-gate 			log_message(MSG_WARN, "Warning: set_here(%s) back: old:"
8047c478bd9Sstevel@tonic-gate 			    " %p new: %p\n", where, HERE, new_here);
8057c478bd9Sstevel@tonic-gate 		}
8067c478bd9Sstevel@tonic-gate 	}
8077c478bd9Sstevel@tonic-gate 	if (new_here >= env->base + dict_size)
8087c478bd9Sstevel@tonic-gate 		forth_abort(env, "Here (%p) set past dictionary end (%p)",
8097c478bd9Sstevel@tonic-gate 		    new_here, env->base + dict_size);
8107c478bd9Sstevel@tonic-gate 	HERE = new_here;
8117c478bd9Sstevel@tonic-gate }
8127c478bd9Sstevel@tonic-gate 
8137c478bd9Sstevel@tonic-gate static void
unaligned_store(fcode_env_t * env)8147c478bd9Sstevel@tonic-gate unaligned_store(fcode_env_t *env)
8157c478bd9Sstevel@tonic-gate {
8167c478bd9Sstevel@tonic-gate 	extern void unaligned_xstore(fcode_env_t *);
8177c478bd9Sstevel@tonic-gate 
8187c478bd9Sstevel@tonic-gate 	if (sizeof (fstack_t) == sizeof (lforth_t))
8197c478bd9Sstevel@tonic-gate 		unaligned_lstore(env);
8207c478bd9Sstevel@tonic-gate 	else
8217c478bd9Sstevel@tonic-gate 		unaligned_xstore(env);
8227c478bd9Sstevel@tonic-gate }
8237c478bd9Sstevel@tonic-gate 
8247c478bd9Sstevel@tonic-gate static void
unaligned_fetch(fcode_env_t * env)8257c478bd9Sstevel@tonic-gate unaligned_fetch(fcode_env_t *env)
8267c478bd9Sstevel@tonic-gate {
8277c478bd9Sstevel@tonic-gate 	extern void unaligned_xfetch(fcode_env_t *);
8287c478bd9Sstevel@tonic-gate 
8297c478bd9Sstevel@tonic-gate 	if (sizeof (fstack_t) == sizeof (lforth_t))
8307c478bd9Sstevel@tonic-gate 		unaligned_lfetch(env);
8317c478bd9Sstevel@tonic-gate 	else
8327c478bd9Sstevel@tonic-gate 		unaligned_xfetch(env);
8337c478bd9Sstevel@tonic-gate }
8347c478bd9Sstevel@tonic-gate 
8357c478bd9Sstevel@tonic-gate void
comma(fcode_env_t * env)8367c478bd9Sstevel@tonic-gate comma(fcode_env_t *env)
8377c478bd9Sstevel@tonic-gate {
8387c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, ",");
8397c478bd9Sstevel@tonic-gate 	DEBUGF(COMMA, dump_comma(env, ","));
8407c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)HERE);
8417c478bd9Sstevel@tonic-gate 	unaligned_store(env);
8427c478bd9Sstevel@tonic-gate 	set_here(env, HERE + sizeof (fstack_t), "comma");
8437c478bd9Sstevel@tonic-gate }
8447c478bd9Sstevel@tonic-gate 
8457c478bd9Sstevel@tonic-gate void
lcomma(fcode_env_t * env)8467c478bd9Sstevel@tonic-gate lcomma(fcode_env_t *env)
8477c478bd9Sstevel@tonic-gate {
8487c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "l,");
8497c478bd9Sstevel@tonic-gate 	DEBUGF(COMMA, dump_comma(env, "l,"));
8507c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)HERE);
8517c478bd9Sstevel@tonic-gate 	unaligned_lstore(env);
8527c478bd9Sstevel@tonic-gate 	set_here(env, HERE + sizeof (u_lforth_t), "lcomma");
8537c478bd9Sstevel@tonic-gate }
8547c478bd9Sstevel@tonic-gate 
8557c478bd9Sstevel@tonic-gate void
wcomma(fcode_env_t * env)8567c478bd9Sstevel@tonic-gate wcomma(fcode_env_t *env)
8577c478bd9Sstevel@tonic-gate {
8587c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "w,");
8597c478bd9Sstevel@tonic-gate 	DEBUGF(COMMA, dump_comma(env, "w,"));
8607c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)HERE);
8617c478bd9Sstevel@tonic-gate 	unaligned_wstore(env);
8627c478bd9Sstevel@tonic-gate 	set_here(env, HERE + sizeof (u_wforth_t), "wcomma");
8637c478bd9Sstevel@tonic-gate }
8647c478bd9Sstevel@tonic-gate 
8657c478bd9Sstevel@tonic-gate void
ccomma(fcode_env_t * env)8667c478bd9Sstevel@tonic-gate ccomma(fcode_env_t *env)
8677c478bd9Sstevel@tonic-gate {
8687c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "c,");
8697c478bd9Sstevel@tonic-gate 	DEBUGF(COMMA, dump_comma(env, "c,"));
8707c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)HERE);
8717c478bd9Sstevel@tonic-gate 	cstore(env);
8727c478bd9Sstevel@tonic-gate 	set_here(env, HERE + sizeof (uchar_t), "ccomma");
8737c478bd9Sstevel@tonic-gate }
8747c478bd9Sstevel@tonic-gate 
8757c478bd9Sstevel@tonic-gate void
token_roundup(fcode_env_t * env,char * where)8767c478bd9Sstevel@tonic-gate token_roundup(fcode_env_t *env, char *where)
8777c478bd9Sstevel@tonic-gate {
8787c478bd9Sstevel@tonic-gate 	if ((((token_t)HERE) & (sizeof (token_t) - 1)) != 0) {
8797c478bd9Sstevel@tonic-gate 		set_here(env, (uchar_t *)TOKEN_ROUNDUP(HERE), where);
8807c478bd9Sstevel@tonic-gate 	}
8817c478bd9Sstevel@tonic-gate }
8827c478bd9Sstevel@tonic-gate 
8837c478bd9Sstevel@tonic-gate void
compile_comma(fcode_env_t * env)8847c478bd9Sstevel@tonic-gate compile_comma(fcode_env_t *env)
8857c478bd9Sstevel@tonic-gate {
8867c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "compile,");
8877c478bd9Sstevel@tonic-gate 	DEBUGF(COMMA, dump_comma(env, "compile,"));
8887c478bd9Sstevel@tonic-gate 	token_roundup(env, "compile,");
8897c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)HERE);
8907c478bd9Sstevel@tonic-gate 	unaligned_store(env);
8917c478bd9Sstevel@tonic-gate 	set_here(env, HERE + sizeof (fstack_t), "compile,");
8927c478bd9Sstevel@tonic-gate }
8937c478bd9Sstevel@tonic-gate 
8947c478bd9Sstevel@tonic-gate void
unaligned_lfetch(fcode_env_t * env)8957c478bd9Sstevel@tonic-gate unaligned_lfetch(fcode_env_t *env)
8967c478bd9Sstevel@tonic-gate {
8977c478bd9Sstevel@tonic-gate 	fstack_t addr;
8987c478bd9Sstevel@tonic-gate 	int i;
8997c478bd9Sstevel@tonic-gate 
9007c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "unaligned-l@");
9017c478bd9Sstevel@tonic-gate 	addr = POP(DS);
9027c478bd9Sstevel@tonic-gate 	for (i = 0; i < sizeof (lforth_t); i++, addr++) {
9037c478bd9Sstevel@tonic-gate 		PUSH(DS, addr);
9047c478bd9Sstevel@tonic-gate 		cfetch(env);
9057c478bd9Sstevel@tonic-gate 	}
9067c478bd9Sstevel@tonic-gate 	bljoin(env);
9077c478bd9Sstevel@tonic-gate 	lbflip(env);
9087c478bd9Sstevel@tonic-gate }
9097c478bd9Sstevel@tonic-gate 
9107c478bd9Sstevel@tonic-gate void
unaligned_lstore(fcode_env_t * env)9117c478bd9Sstevel@tonic-gate unaligned_lstore(fcode_env_t *env)
9127c478bd9Sstevel@tonic-gate {
9137c478bd9Sstevel@tonic-gate 	fstack_t addr;
9147c478bd9Sstevel@tonic-gate 	int i;
9157c478bd9Sstevel@tonic-gate 
9167c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "unaligned-l!");
9177c478bd9Sstevel@tonic-gate 	addr = POP(DS);
9187c478bd9Sstevel@tonic-gate 	lbsplit(env);
9197c478bd9Sstevel@tonic-gate 	for (i = 0; i < sizeof (lforth_t); i++, addr++) {
9207c478bd9Sstevel@tonic-gate 		PUSH(DS, addr);
9217c478bd9Sstevel@tonic-gate 		cstore(env);
9227c478bd9Sstevel@tonic-gate 	}
9237c478bd9Sstevel@tonic-gate }
9247c478bd9Sstevel@tonic-gate 
9257c478bd9Sstevel@tonic-gate void
unaligned_wfetch(fcode_env_t * env)9267c478bd9Sstevel@tonic-gate unaligned_wfetch(fcode_env_t *env)
9277c478bd9Sstevel@tonic-gate {
9287c478bd9Sstevel@tonic-gate 	fstack_t addr;
9297c478bd9Sstevel@tonic-gate 	int i;
9307c478bd9Sstevel@tonic-gate 
9317c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "unaligned-w@");
9327c478bd9Sstevel@tonic-gate 	addr = POP(DS);
9337c478bd9Sstevel@tonic-gate 	for (i = 0; i < sizeof (wforth_t); i++, addr++) {
9347c478bd9Sstevel@tonic-gate 		PUSH(DS, addr);
9357c478bd9Sstevel@tonic-gate 		cfetch(env);
9367c478bd9Sstevel@tonic-gate 	}
9377c478bd9Sstevel@tonic-gate 	bwjoin(env);
9387c478bd9Sstevel@tonic-gate 	wbflip(env);
9397c478bd9Sstevel@tonic-gate }
9407c478bd9Sstevel@tonic-gate 
9417c478bd9Sstevel@tonic-gate void
unaligned_wstore(fcode_env_t * env)9427c478bd9Sstevel@tonic-gate unaligned_wstore(fcode_env_t *env)
9437c478bd9Sstevel@tonic-gate {
9447c478bd9Sstevel@tonic-gate 	fstack_t addr;
9457c478bd9Sstevel@tonic-gate 	int i;
9467c478bd9Sstevel@tonic-gate 
9477c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "unaligned-w!");
9487c478bd9Sstevel@tonic-gate 	addr = POP(DS);
9497c478bd9Sstevel@tonic-gate 	wbsplit(env);
9507c478bd9Sstevel@tonic-gate 	for (i = 0; i < sizeof (wforth_t); i++, addr++) {
9517c478bd9Sstevel@tonic-gate 		PUSH(DS, addr);
9527c478bd9Sstevel@tonic-gate 		cstore(env);
9537c478bd9Sstevel@tonic-gate 	}
9547c478bd9Sstevel@tonic-gate }
9557c478bd9Sstevel@tonic-gate 
9567c478bd9Sstevel@tonic-gate /*
9577c478bd9Sstevel@tonic-gate  * 'lbflips' Fcode implementation.
9587c478bd9Sstevel@tonic-gate  */
9597c478bd9Sstevel@tonic-gate static void
lbflips(fcode_env_t * env)9607c478bd9Sstevel@tonic-gate lbflips(fcode_env_t *env)
9617c478bd9Sstevel@tonic-gate {
9627c478bd9Sstevel@tonic-gate 	fstack_t len, addr;
9637c478bd9Sstevel@tonic-gate 	int i;
9647c478bd9Sstevel@tonic-gate 
9657c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "lbflips");
9667c478bd9Sstevel@tonic-gate 	len = POP(DS);
9677c478bd9Sstevel@tonic-gate 	addr = POP(DS);
9687c478bd9Sstevel@tonic-gate 	for (i = 0; i < len; i += sizeof (lforth_t),
9697c478bd9Sstevel@tonic-gate 	    addr += sizeof (lforth_t)) {
9707c478bd9Sstevel@tonic-gate 		PUSH(DS, addr);
9717c478bd9Sstevel@tonic-gate 		unaligned_lfetch(env);
9727c478bd9Sstevel@tonic-gate 		lbflip(env);
9737c478bd9Sstevel@tonic-gate 		PUSH(DS, addr);
9747c478bd9Sstevel@tonic-gate 		unaligned_lstore(env);
9757c478bd9Sstevel@tonic-gate 	}
9767c478bd9Sstevel@tonic-gate }
9777c478bd9Sstevel@tonic-gate 
9787c478bd9Sstevel@tonic-gate /*
9797c478bd9Sstevel@tonic-gate  * 'wbflips' Fcode implementation.
9807c478bd9Sstevel@tonic-gate  */
9817c478bd9Sstevel@tonic-gate static void
wbflips(fcode_env_t * env)9827c478bd9Sstevel@tonic-gate wbflips(fcode_env_t *env)
9837c478bd9Sstevel@tonic-gate {
9847c478bd9Sstevel@tonic-gate 	fstack_t len, addr;
9857c478bd9Sstevel@tonic-gate 	int i;
9867c478bd9Sstevel@tonic-gate 
9877c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "wbflips");
9887c478bd9Sstevel@tonic-gate 	len = POP(DS);
9897c478bd9Sstevel@tonic-gate 	addr = POP(DS);
9907c478bd9Sstevel@tonic-gate 	for (i = 0; i < len; i += sizeof (wforth_t),
9917c478bd9Sstevel@tonic-gate 	    addr += sizeof (wforth_t)) {
9927c478bd9Sstevel@tonic-gate 		PUSH(DS, addr);
9937c478bd9Sstevel@tonic-gate 		unaligned_wfetch(env);
9947c478bd9Sstevel@tonic-gate 		wbflip(env);
9957c478bd9Sstevel@tonic-gate 		PUSH(DS, addr);
9967c478bd9Sstevel@tonic-gate 		unaligned_wstore(env);
9977c478bd9Sstevel@tonic-gate 	}
9987c478bd9Sstevel@tonic-gate }
9997c478bd9Sstevel@tonic-gate 
10007c478bd9Sstevel@tonic-gate /*
10017c478bd9Sstevel@tonic-gate  * 'lwflips' Fcode implementation.
10027c478bd9Sstevel@tonic-gate  */
10037c478bd9Sstevel@tonic-gate static void
lwflips(fcode_env_t * env)10047c478bd9Sstevel@tonic-gate lwflips(fcode_env_t *env)
10057c478bd9Sstevel@tonic-gate {
10067c478bd9Sstevel@tonic-gate 	fstack_t len, addr;
10077c478bd9Sstevel@tonic-gate 	int i;
10087c478bd9Sstevel@tonic-gate 
10097c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "lwflips");
10107c478bd9Sstevel@tonic-gate 	len = POP(DS);
10117c478bd9Sstevel@tonic-gate 	addr = POP(DS);
10127c478bd9Sstevel@tonic-gate 	for (i = 0; i < len; i += sizeof (lforth_t),
10137c478bd9Sstevel@tonic-gate 	    addr += sizeof (lforth_t)) {
10147c478bd9Sstevel@tonic-gate 		PUSH(DS, addr);
10157c478bd9Sstevel@tonic-gate 		unaligned_lfetch(env);
10167c478bd9Sstevel@tonic-gate 		lwflip(env);
10177c478bd9Sstevel@tonic-gate 		PUSH(DS, addr);
10187c478bd9Sstevel@tonic-gate 		unaligned_lstore(env);
10197c478bd9Sstevel@tonic-gate 	}
10207c478bd9Sstevel@tonic-gate }
10217c478bd9Sstevel@tonic-gate 
10227c478bd9Sstevel@tonic-gate void
base(fcode_env_t * env)10237c478bd9Sstevel@tonic-gate base(fcode_env_t *env)
10247c478bd9Sstevel@tonic-gate {
10257c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)&env->num_base);
10267c478bd9Sstevel@tonic-gate }
10277c478bd9Sstevel@tonic-gate 
10287c478bd9Sstevel@tonic-gate void
dot_s(fcode_env_t * env)10297c478bd9Sstevel@tonic-gate dot_s(fcode_env_t *env)
10307c478bd9Sstevel@tonic-gate {
10317c478bd9Sstevel@tonic-gate 	output_data_stack(env, MSG_INFO);
10327c478bd9Sstevel@tonic-gate }
10337c478bd9Sstevel@tonic-gate 
10347c478bd9Sstevel@tonic-gate void
state(fcode_env_t * env)10357c478bd9Sstevel@tonic-gate state(fcode_env_t *env)
10367c478bd9Sstevel@tonic-gate {
10377c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)&env->state);
10387c478bd9Sstevel@tonic-gate }
10397c478bd9Sstevel@tonic-gate 
10407c478bd9Sstevel@tonic-gate int
is_digit(char digit,int num_base,fstack_t * dptr)10417c478bd9Sstevel@tonic-gate is_digit(char digit, int num_base, fstack_t *dptr)
10427c478bd9Sstevel@tonic-gate {
10437c478bd9Sstevel@tonic-gate 	int error = 0;
10447c478bd9Sstevel@tonic-gate 	char base;
10457c478bd9Sstevel@tonic-gate 
10467c478bd9Sstevel@tonic-gate 	if (num_base < 10) {
10477c478bd9Sstevel@tonic-gate 		base = '0' + (num_base-1);
10487c478bd9Sstevel@tonic-gate 	} else {
10497c478bd9Sstevel@tonic-gate 		base = 'a' + (num_base - 10);
10507c478bd9Sstevel@tonic-gate 	}
10517c478bd9Sstevel@tonic-gate 
10527c478bd9Sstevel@tonic-gate 	*dptr = 0;
10537c478bd9Sstevel@tonic-gate 	if (digit > '9') digit |= 0x20;
10547c478bd9Sstevel@tonic-gate 	if (((digit < '0') || (digit > base)) ||
10557c478bd9Sstevel@tonic-gate 	    ((digit > '9') && (digit < 'a') && (num_base > 10)))
10567c478bd9Sstevel@tonic-gate 		error = 1;
10577c478bd9Sstevel@tonic-gate 	else {
10587c478bd9Sstevel@tonic-gate 		if (digit <= '9')
10597c478bd9Sstevel@tonic-gate 			digit -= '0';
10607c478bd9Sstevel@tonic-gate 		else
10617c478bd9Sstevel@tonic-gate 			digit = digit - 'a' + 10;
10627c478bd9Sstevel@tonic-gate 		*dptr = digit;
10637c478bd9Sstevel@tonic-gate 	}
10647c478bd9Sstevel@tonic-gate 	return (error);
10657c478bd9Sstevel@tonic-gate }
10667c478bd9Sstevel@tonic-gate 
10677c478bd9Sstevel@tonic-gate void
dollar_number(fcode_env_t * env)10687c478bd9Sstevel@tonic-gate dollar_number(fcode_env_t *env)
10697c478bd9Sstevel@tonic-gate {
10707c478bd9Sstevel@tonic-gate 	char *buf;
10717c478bd9Sstevel@tonic-gate 	fstack_t value;
10727c478bd9Sstevel@tonic-gate 	int len, sign = 1, error = 0;
10737c478bd9Sstevel@tonic-gate 
10747c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "$number");
10757c478bd9Sstevel@tonic-gate 	buf = pop_a_string(env, &len);
10767c478bd9Sstevel@tonic-gate 	if (*buf == '-') {
10777c478bd9Sstevel@tonic-gate 		sign = -1;
10787c478bd9Sstevel@tonic-gate 		buf++;
10797c478bd9Sstevel@tonic-gate 		len--;
10807c478bd9Sstevel@tonic-gate 	}
10817c478bd9Sstevel@tonic-gate 	value = 0;
10827c478bd9Sstevel@tonic-gate 	while (len-- && !error) {
10837c478bd9Sstevel@tonic-gate 		fstack_t digit;
10847c478bd9Sstevel@tonic-gate 
10857c478bd9Sstevel@tonic-gate 		if (*buf == '.') {
10867c478bd9Sstevel@tonic-gate 			buf++;
10877c478bd9Sstevel@tonic-gate 			continue;
10887c478bd9Sstevel@tonic-gate 		}
10897c478bd9Sstevel@tonic-gate 		value *= env->num_base;
10907c478bd9Sstevel@tonic-gate 		error = is_digit(*buf++, env->num_base, &digit);
10917c478bd9Sstevel@tonic-gate 		value += digit;
10927c478bd9Sstevel@tonic-gate 	}
10937c478bd9Sstevel@tonic-gate 	if (error) {
10947c478bd9Sstevel@tonic-gate 		PUSH(DS, -1);
10957c478bd9Sstevel@tonic-gate 	} else {
10967c478bd9Sstevel@tonic-gate 		value *= sign;
10977c478bd9Sstevel@tonic-gate 		PUSH(DS, value);
10987c478bd9Sstevel@tonic-gate 		PUSH(DS, 0);
10997c478bd9Sstevel@tonic-gate 	}
11007c478bd9Sstevel@tonic-gate }
11017c478bd9Sstevel@tonic-gate 
11027c478bd9Sstevel@tonic-gate void
digit(fcode_env_t * env)11037c478bd9Sstevel@tonic-gate digit(fcode_env_t *env)
11047c478bd9Sstevel@tonic-gate {
11057c478bd9Sstevel@tonic-gate 	fstack_t base;
11067c478bd9Sstevel@tonic-gate 	fstack_t value;
11077c478bd9Sstevel@tonic-gate 
11087c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "digit");
11097c478bd9Sstevel@tonic-gate 	base = POP(DS);
11107c478bd9Sstevel@tonic-gate 	if (is_digit(TOS, base, &value))
11117c478bd9Sstevel@tonic-gate 		PUSH(DS, 0);
11127c478bd9Sstevel@tonic-gate 	else {
11137c478bd9Sstevel@tonic-gate 		TOS = value;
11147c478bd9Sstevel@tonic-gate 		PUSH(DS, -1);
11157c478bd9Sstevel@tonic-gate 	}
11167c478bd9Sstevel@tonic-gate }
11177c478bd9Sstevel@tonic-gate 
11187c478bd9Sstevel@tonic-gate void
space(fcode_env_t * env)11197c478bd9Sstevel@tonic-gate space(fcode_env_t *env)
11207c478bd9Sstevel@tonic-gate {
11217c478bd9Sstevel@tonic-gate 	PUSH(DS, ' ');
11227c478bd9Sstevel@tonic-gate }
11237c478bd9Sstevel@tonic-gate 
11247c478bd9Sstevel@tonic-gate void
backspace(fcode_env_t * env)11257c478bd9Sstevel@tonic-gate backspace(fcode_env_t *env)
11267c478bd9Sstevel@tonic-gate {
11277c478bd9Sstevel@tonic-gate 	PUSH(DS, '\b');
11287c478bd9Sstevel@tonic-gate }
11297c478bd9Sstevel@tonic-gate 
11307c478bd9Sstevel@tonic-gate void
bell(fcode_env_t * env)11317c478bd9Sstevel@tonic-gate bell(fcode_env_t *env)
11327c478bd9Sstevel@tonic-gate {
11337c478bd9Sstevel@tonic-gate 	PUSH(DS, '\a');
11347c478bd9Sstevel@tonic-gate }
11357c478bd9Sstevel@tonic-gate 
11367c478bd9Sstevel@tonic-gate void
fc_bounds(fcode_env_t * env)11377c478bd9Sstevel@tonic-gate fc_bounds(fcode_env_t *env)
11387c478bd9Sstevel@tonic-gate {
11397c478bd9Sstevel@tonic-gate 	fstack_t lo, hi;
11407c478bd9Sstevel@tonic-gate 
11417c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "bounds");
11427c478bd9Sstevel@tonic-gate 	lo = DS[-1];
11437c478bd9Sstevel@tonic-gate 	hi = TOS;
11447c478bd9Sstevel@tonic-gate 	DS[-1] = lo+hi;
11457c478bd9Sstevel@tonic-gate 	TOS = lo;
11467c478bd9Sstevel@tonic-gate }
11477c478bd9Sstevel@tonic-gate 
11487c478bd9Sstevel@tonic-gate void
here(fcode_env_t * env)11497c478bd9Sstevel@tonic-gate here(fcode_env_t *env)
11507c478bd9Sstevel@tonic-gate {
11517c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)HERE);
11527c478bd9Sstevel@tonic-gate }
11537c478bd9Sstevel@tonic-gate 
11547c478bd9Sstevel@tonic-gate void
aligned(fcode_env_t * env)11557c478bd9Sstevel@tonic-gate aligned(fcode_env_t *env)
11567c478bd9Sstevel@tonic-gate {
11577c478bd9Sstevel@tonic-gate 	ufstack_t a;
11587c478bd9Sstevel@tonic-gate 
11597c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "aligned");
11607c478bd9Sstevel@tonic-gate 	a = (TOS & (sizeof (lforth_t) - 1));
11617c478bd9Sstevel@tonic-gate 	if (a)
11627c478bd9Sstevel@tonic-gate 		TOS += (sizeof (lforth_t) - a);
11637c478bd9Sstevel@tonic-gate }
11647c478bd9Sstevel@tonic-gate 
11657c478bd9Sstevel@tonic-gate void
instance(fcode_env_t * env)11667c478bd9Sstevel@tonic-gate instance(fcode_env_t *env)
11677c478bd9Sstevel@tonic-gate {
11687c478bd9Sstevel@tonic-gate 	env->instance_mode |= 1;
11697c478bd9Sstevel@tonic-gate }
11707c478bd9Sstevel@tonic-gate 
11717c478bd9Sstevel@tonic-gate void
semi(fcode_env_t * env)11727c478bd9Sstevel@tonic-gate semi(fcode_env_t *env)
11737c478bd9Sstevel@tonic-gate {
11747c478bd9Sstevel@tonic-gate 
11757c478bd9Sstevel@tonic-gate 	env->state &= ~1;
11767c478bd9Sstevel@tonic-gate 	COMPILE_TOKEN(&semi_ptr);
11777c478bd9Sstevel@tonic-gate 
11787c478bd9Sstevel@tonic-gate 	/*
11797c478bd9Sstevel@tonic-gate 	 * check if we need to supress expose action;
11807c478bd9Sstevel@tonic-gate 	 * If so this is an internal word and has no link field
11817c478bd9Sstevel@tonic-gate 	 * or it is a temporary compile
11827c478bd9Sstevel@tonic-gate 	 */
11837c478bd9Sstevel@tonic-gate 
11847c478bd9Sstevel@tonic-gate 	if (env->state == 0) {
11857c478bd9Sstevel@tonic-gate 		expose_acf(env, "<semi>");
11867c478bd9Sstevel@tonic-gate 	}
11877c478bd9Sstevel@tonic-gate 	if (env->state & 8) {
11887c478bd9Sstevel@tonic-gate 		env->state ^= 8;
11897c478bd9Sstevel@tonic-gate 	}
11907c478bd9Sstevel@tonic-gate }
11917c478bd9Sstevel@tonic-gate 
11927c478bd9Sstevel@tonic-gate void
do_create(fcode_env_t * env)11937c478bd9Sstevel@tonic-gate do_create(fcode_env_t *env)
11947c478bd9Sstevel@tonic-gate {
11957c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)WA);
11967c478bd9Sstevel@tonic-gate }
11977c478bd9Sstevel@tonic-gate 
11987c478bd9Sstevel@tonic-gate void
drop(fcode_env_t * env)11997c478bd9Sstevel@tonic-gate drop(fcode_env_t *env)
12007c478bd9Sstevel@tonic-gate {
12017c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "drop");
12027c478bd9Sstevel@tonic-gate 	(void) POP(DS);
12037c478bd9Sstevel@tonic-gate }
12047c478bd9Sstevel@tonic-gate 
12057c478bd9Sstevel@tonic-gate void
f_dup(fcode_env_t * env)12067c478bd9Sstevel@tonic-gate f_dup(fcode_env_t *env)
12077c478bd9Sstevel@tonic-gate {
12087c478bd9Sstevel@tonic-gate 	fstack_t d;
12097c478bd9Sstevel@tonic-gate 
12107c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "dup");
12117c478bd9Sstevel@tonic-gate 	d = TOS;
12127c478bd9Sstevel@tonic-gate 	PUSH(DS, d);
12137c478bd9Sstevel@tonic-gate }
12147c478bd9Sstevel@tonic-gate 
12157c478bd9Sstevel@tonic-gate void
over(fcode_env_t * env)12167c478bd9Sstevel@tonic-gate over(fcode_env_t *env)
12177c478bd9Sstevel@tonic-gate {
12187c478bd9Sstevel@tonic-gate 	fstack_t d;
12197c478bd9Sstevel@tonic-gate 
12207c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "over");
12217c478bd9Sstevel@tonic-gate 	d = DS[-1];
12227c478bd9Sstevel@tonic-gate 	PUSH(DS, d);
12237c478bd9Sstevel@tonic-gate }
12247c478bd9Sstevel@tonic-gate 
12257c478bd9Sstevel@tonic-gate void
swap(fcode_env_t * env)12267c478bd9Sstevel@tonic-gate swap(fcode_env_t *env)
12277c478bd9Sstevel@tonic-gate {
12287c478bd9Sstevel@tonic-gate 	fstack_t d;
12297c478bd9Sstevel@tonic-gate 
12307c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "swap");
12317c478bd9Sstevel@tonic-gate 	d = DS[-1];
12327c478bd9Sstevel@tonic-gate 	DS[-1] = DS[0];
12337c478bd9Sstevel@tonic-gate 	DS[0]  = d;
12347c478bd9Sstevel@tonic-gate }
12357c478bd9Sstevel@tonic-gate 
12367c478bd9Sstevel@tonic-gate 
12377c478bd9Sstevel@tonic-gate void
rot(fcode_env_t * env)12387c478bd9Sstevel@tonic-gate rot(fcode_env_t *env)
12397c478bd9Sstevel@tonic-gate {
12407c478bd9Sstevel@tonic-gate 	fstack_t d;
12417c478bd9Sstevel@tonic-gate 
12427c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 3, "rot");
12437c478bd9Sstevel@tonic-gate 	d = DS[-2];
12447c478bd9Sstevel@tonic-gate 	DS[-2] = DS[-1];
12457c478bd9Sstevel@tonic-gate 	DS[-1] = TOS;
12467c478bd9Sstevel@tonic-gate 	TOS    = d;
12477c478bd9Sstevel@tonic-gate }
12487c478bd9Sstevel@tonic-gate 
12497c478bd9Sstevel@tonic-gate void
minus_rot(fcode_env_t * env)12507c478bd9Sstevel@tonic-gate minus_rot(fcode_env_t *env)
12517c478bd9Sstevel@tonic-gate {
12527c478bd9Sstevel@tonic-gate 	fstack_t d;
12537c478bd9Sstevel@tonic-gate 
12547c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 3, "-rot");
12557c478bd9Sstevel@tonic-gate 	d = TOS;
12567c478bd9Sstevel@tonic-gate 	TOS    = DS[-1];
12577c478bd9Sstevel@tonic-gate 	DS[-1] = DS[-2];
12587c478bd9Sstevel@tonic-gate 	DS[-2] = d;
12597c478bd9Sstevel@tonic-gate }
12607c478bd9Sstevel@tonic-gate 
12617c478bd9Sstevel@tonic-gate void
tuck(fcode_env_t * env)12627c478bd9Sstevel@tonic-gate tuck(fcode_env_t *env)
12637c478bd9Sstevel@tonic-gate {
12647c478bd9Sstevel@tonic-gate 	fstack_t d;
12657c478bd9Sstevel@tonic-gate 
12667c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "tuck");
12677c478bd9Sstevel@tonic-gate 	d = TOS;
12687c478bd9Sstevel@tonic-gate 	swap(env);
12697c478bd9Sstevel@tonic-gate 	PUSH(DS, d);
12707c478bd9Sstevel@tonic-gate }
12717c478bd9Sstevel@tonic-gate 
12727c478bd9Sstevel@tonic-gate void
nip(fcode_env_t * env)12737c478bd9Sstevel@tonic-gate nip(fcode_env_t *env)
12747c478bd9Sstevel@tonic-gate {
12757c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "nip");
12767c478bd9Sstevel@tonic-gate 	swap(env);
12777c478bd9Sstevel@tonic-gate 	drop(env);
12787c478bd9Sstevel@tonic-gate }
12797c478bd9Sstevel@tonic-gate 
12807c478bd9Sstevel@tonic-gate void
qdup(fcode_env_t * env)12817c478bd9Sstevel@tonic-gate qdup(fcode_env_t *env)
12827c478bd9Sstevel@tonic-gate {
12837c478bd9Sstevel@tonic-gate 	fstack_t d;
12847c478bd9Sstevel@tonic-gate 
12857c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "?dup");
12867c478bd9Sstevel@tonic-gate 	d = TOS;
12877c478bd9Sstevel@tonic-gate 	if (d)
12887c478bd9Sstevel@tonic-gate 		PUSH(DS, d);
12897c478bd9Sstevel@tonic-gate }
12907c478bd9Sstevel@tonic-gate 
12917c478bd9Sstevel@tonic-gate void
depth(fcode_env_t * env)12927c478bd9Sstevel@tonic-gate depth(fcode_env_t *env)
12937c478bd9Sstevel@tonic-gate {
12947c478bd9Sstevel@tonic-gate 	fstack_t d;
12957c478bd9Sstevel@tonic-gate 
12967c478bd9Sstevel@tonic-gate 	d =  DS - env->ds0;
12977c478bd9Sstevel@tonic-gate 	PUSH(DS, d);
12987c478bd9Sstevel@tonic-gate }
12997c478bd9Sstevel@tonic-gate 
13007c478bd9Sstevel@tonic-gate void
pick(fcode_env_t * env)13017c478bd9Sstevel@tonic-gate pick(fcode_env_t *env)
13027c478bd9Sstevel@tonic-gate {
13037c478bd9Sstevel@tonic-gate 	fstack_t p;
13047c478bd9Sstevel@tonic-gate 
13057c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "pick");
13067c478bd9Sstevel@tonic-gate 	p = POP(DS);
13077c478bd9Sstevel@tonic-gate 	if (p < 0 || p >= (env->ds - env->ds0))
13087c478bd9Sstevel@tonic-gate 		forth_abort(env, "pick: invalid pick value: %d\n", (int)p);
13097c478bd9Sstevel@tonic-gate 	p = DS[-p];
13107c478bd9Sstevel@tonic-gate 	PUSH(DS, p);
13117c478bd9Sstevel@tonic-gate }
13127c478bd9Sstevel@tonic-gate 
13137c478bd9Sstevel@tonic-gate void
roll(fcode_env_t * env)13147c478bd9Sstevel@tonic-gate roll(fcode_env_t *env)
13157c478bd9Sstevel@tonic-gate {
13167c478bd9Sstevel@tonic-gate 	fstack_t d, r;
13177c478bd9Sstevel@tonic-gate 
13187c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "roll");
13197c478bd9Sstevel@tonic-gate 	r = POP(DS);
13207c478bd9Sstevel@tonic-gate 	if (r <= 0 || r >= (env->ds - env->ds0))
13217c478bd9Sstevel@tonic-gate 		forth_abort(env, "roll: invalid roll value: %d\n", (int)r);
13227c478bd9Sstevel@tonic-gate 
13237c478bd9Sstevel@tonic-gate 	d = DS[-r];
13247c478bd9Sstevel@tonic-gate 	while (r) {
13257c478bd9Sstevel@tonic-gate 		DS[-r] = DS[ -(r-1) ];
13267c478bd9Sstevel@tonic-gate 		r--;
13277c478bd9Sstevel@tonic-gate 	}
13287c478bd9Sstevel@tonic-gate 	TOS = d;
13297c478bd9Sstevel@tonic-gate }
13307c478bd9Sstevel@tonic-gate 
13317c478bd9Sstevel@tonic-gate void
two_drop(fcode_env_t * env)13327c478bd9Sstevel@tonic-gate two_drop(fcode_env_t *env)
13337c478bd9Sstevel@tonic-gate {
13347c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "2drop");
13357c478bd9Sstevel@tonic-gate 	DS -= 2;
13367c478bd9Sstevel@tonic-gate }
13377c478bd9Sstevel@tonic-gate 
13387c478bd9Sstevel@tonic-gate void
two_dup(fcode_env_t * env)13397c478bd9Sstevel@tonic-gate two_dup(fcode_env_t *env)
13407c478bd9Sstevel@tonic-gate {
13417c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "2dup");
13427c478bd9Sstevel@tonic-gate 	DS[1] = DS[-1];
13437c478bd9Sstevel@tonic-gate 	DS[2] = TOS;
13447c478bd9Sstevel@tonic-gate 	DS += 2;
13457c478bd9Sstevel@tonic-gate }
13467c478bd9Sstevel@tonic-gate 
13477c478bd9Sstevel@tonic-gate void
two_over(fcode_env_t * env)13487c478bd9Sstevel@tonic-gate two_over(fcode_env_t *env)
13497c478bd9Sstevel@tonic-gate {
13507c478bd9Sstevel@tonic-gate 	fstack_t a, b;
13517c478bd9Sstevel@tonic-gate 
13527c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 4, "2over");
13537c478bd9Sstevel@tonic-gate 	a = DS[-3];
13547c478bd9Sstevel@tonic-gate 	b = DS[-2];
13557c478bd9Sstevel@tonic-gate 	PUSH(DS, a);
13567c478bd9Sstevel@tonic-gate 	PUSH(DS, b);
13577c478bd9Sstevel@tonic-gate }
13587c478bd9Sstevel@tonic-gate 
13597c478bd9Sstevel@tonic-gate void
two_swap(fcode_env_t * env)13607c478bd9Sstevel@tonic-gate two_swap(fcode_env_t *env)
13617c478bd9Sstevel@tonic-gate {
13627c478bd9Sstevel@tonic-gate 	fstack_t a, b;
13637c478bd9Sstevel@tonic-gate 
13647c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 4, "2swap");
13657c478bd9Sstevel@tonic-gate 	a = DS[-3];
13667c478bd9Sstevel@tonic-gate 	b = DS[-2];
13677c478bd9Sstevel@tonic-gate 	DS[-3] = DS[-1];
13687c478bd9Sstevel@tonic-gate 	DS[-2] = TOS;
13697c478bd9Sstevel@tonic-gate 	DS[-1] = a;
13707c478bd9Sstevel@tonic-gate 	TOS    = b;
13717c478bd9Sstevel@tonic-gate }
13727c478bd9Sstevel@tonic-gate 
13737c478bd9Sstevel@tonic-gate void
two_rot(fcode_env_t * env)13747c478bd9Sstevel@tonic-gate two_rot(fcode_env_t *env)
13757c478bd9Sstevel@tonic-gate {
13767c478bd9Sstevel@tonic-gate 	fstack_t a, b;
13777c478bd9Sstevel@tonic-gate 
13787c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 6, "2rot");
13797c478bd9Sstevel@tonic-gate 	a = DS[-5];
13807c478bd9Sstevel@tonic-gate 	b = DS[-4];
13817c478bd9Sstevel@tonic-gate 	DS[-5] = DS[-3];
13827c478bd9Sstevel@tonic-gate 	DS[-4] = DS[-2];
13837c478bd9Sstevel@tonic-gate 	DS[-3] = DS[-1];
13847c478bd9Sstevel@tonic-gate 	DS[-2] = TOS;
13857c478bd9Sstevel@tonic-gate 	DS[-1] = a;
13867c478bd9Sstevel@tonic-gate 	TOS    = b;
13877c478bd9Sstevel@tonic-gate }
13887c478bd9Sstevel@tonic-gate 
13897c478bd9Sstevel@tonic-gate void
two_slash(fcode_env_t * env)13907c478bd9Sstevel@tonic-gate two_slash(fcode_env_t *env)
13917c478bd9Sstevel@tonic-gate {
13927c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "2/");
13937c478bd9Sstevel@tonic-gate 	TOS = TOS >> 1;
13947c478bd9Sstevel@tonic-gate }
13957c478bd9Sstevel@tonic-gate 
13967c478bd9Sstevel@tonic-gate void
utwo_slash(fcode_env_t * env)13977c478bd9Sstevel@tonic-gate utwo_slash(fcode_env_t *env)
13987c478bd9Sstevel@tonic-gate {
13997c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "u2/");
14007c478bd9Sstevel@tonic-gate 	TOS = (ufstack_t)((ufstack_t)TOS) >> 1;
14017c478bd9Sstevel@tonic-gate }
14027c478bd9Sstevel@tonic-gate 
14037c478bd9Sstevel@tonic-gate void
two_times(fcode_env_t * env)14047c478bd9Sstevel@tonic-gate two_times(fcode_env_t *env)
14057c478bd9Sstevel@tonic-gate {
14067c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "2*");
14077c478bd9Sstevel@tonic-gate 	TOS = (ufstack_t)((ufstack_t)TOS) << 1;
14087c478bd9Sstevel@tonic-gate }
14097c478bd9Sstevel@tonic-gate 
14107c478bd9Sstevel@tonic-gate void
slash_c(fcode_env_t * env)14117c478bd9Sstevel@tonic-gate slash_c(fcode_env_t *env)
14127c478bd9Sstevel@tonic-gate {
14137c478bd9Sstevel@tonic-gate 	PUSH(DS, sizeof (char));
14147c478bd9Sstevel@tonic-gate }
14157c478bd9Sstevel@tonic-gate 
14167c478bd9Sstevel@tonic-gate void
slash_w(fcode_env_t * env)14177c478bd9Sstevel@tonic-gate slash_w(fcode_env_t *env)
14187c478bd9Sstevel@tonic-gate {
14197c478bd9Sstevel@tonic-gate 	PUSH(DS, sizeof (wforth_t));
14207c478bd9Sstevel@tonic-gate }
14217c478bd9Sstevel@tonic-gate 
14227c478bd9Sstevel@tonic-gate void
slash_l(fcode_env_t * env)14237c478bd9Sstevel@tonic-gate slash_l(fcode_env_t *env)
14247c478bd9Sstevel@tonic-gate {
14257c478bd9Sstevel@tonic-gate 	PUSH(DS, sizeof (lforth_t));
14267c478bd9Sstevel@tonic-gate }
14277c478bd9Sstevel@tonic-gate 
14287c478bd9Sstevel@tonic-gate void
slash_n(fcode_env_t * env)14297c478bd9Sstevel@tonic-gate slash_n(fcode_env_t *env)
14307c478bd9Sstevel@tonic-gate {
14317c478bd9Sstevel@tonic-gate 	PUSH(DS, sizeof (fstack_t));
14327c478bd9Sstevel@tonic-gate }
14337c478bd9Sstevel@tonic-gate 
14347c478bd9Sstevel@tonic-gate void
ca_plus(fcode_env_t * env)14357c478bd9Sstevel@tonic-gate ca_plus(fcode_env_t *env)
14367c478bd9Sstevel@tonic-gate {
14377c478bd9Sstevel@tonic-gate 	fstack_t d;
14387c478bd9Sstevel@tonic-gate 
14397c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "ca+");
14407c478bd9Sstevel@tonic-gate 	d = POP(DS);
14417c478bd9Sstevel@tonic-gate 	TOS += d * sizeof (char);
14427c478bd9Sstevel@tonic-gate }
14437c478bd9Sstevel@tonic-gate 
14447c478bd9Sstevel@tonic-gate void
wa_plus(fcode_env_t * env)14457c478bd9Sstevel@tonic-gate wa_plus(fcode_env_t *env)
14467c478bd9Sstevel@tonic-gate {
14477c478bd9Sstevel@tonic-gate 	fstack_t d;
14487c478bd9Sstevel@tonic-gate 
14497c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "wa+");
14507c478bd9Sstevel@tonic-gate 	d = POP(DS);
14517c478bd9Sstevel@tonic-gate 	TOS += d * sizeof (wforth_t);
14527c478bd9Sstevel@tonic-gate }
14537c478bd9Sstevel@tonic-gate 
14547c478bd9Sstevel@tonic-gate void
la_plus(fcode_env_t * env)14557c478bd9Sstevel@tonic-gate la_plus(fcode_env_t *env)
14567c478bd9Sstevel@tonic-gate {
14577c478bd9Sstevel@tonic-gate 	fstack_t d;
14587c478bd9Sstevel@tonic-gate 
14597c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "la+");
14607c478bd9Sstevel@tonic-gate 	d = POP(DS);
14617c478bd9Sstevel@tonic-gate 	TOS += d * sizeof (lforth_t);
14627c478bd9Sstevel@tonic-gate }
14637c478bd9Sstevel@tonic-gate 
14647c478bd9Sstevel@tonic-gate void
na_plus(fcode_env_t * env)14657c478bd9Sstevel@tonic-gate na_plus(fcode_env_t *env)
14667c478bd9Sstevel@tonic-gate {
14677c478bd9Sstevel@tonic-gate 	fstack_t d;
14687c478bd9Sstevel@tonic-gate 
14697c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "na+");
14707c478bd9Sstevel@tonic-gate 	d = POP(DS);
14717c478bd9Sstevel@tonic-gate 	TOS += d * sizeof (fstack_t);
14727c478bd9Sstevel@tonic-gate }
14737c478bd9Sstevel@tonic-gate 
14747c478bd9Sstevel@tonic-gate void
char_plus(fcode_env_t * env)14757c478bd9Sstevel@tonic-gate char_plus(fcode_env_t *env)
14767c478bd9Sstevel@tonic-gate {
14777c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "char+");
14787c478bd9Sstevel@tonic-gate 	TOS += sizeof (char);
14797c478bd9Sstevel@tonic-gate }
14807c478bd9Sstevel@tonic-gate 
14817c478bd9Sstevel@tonic-gate void
wa1_plus(fcode_env_t * env)14827c478bd9Sstevel@tonic-gate wa1_plus(fcode_env_t *env)
14837c478bd9Sstevel@tonic-gate {
14847c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "wa1+");
14857c478bd9Sstevel@tonic-gate 	TOS += sizeof (wforth_t);
14867c478bd9Sstevel@tonic-gate }
14877c478bd9Sstevel@tonic-gate 
14887c478bd9Sstevel@tonic-gate void
la1_plus(fcode_env_t * env)14897c478bd9Sstevel@tonic-gate la1_plus(fcode_env_t *env)
14907c478bd9Sstevel@tonic-gate {
14917c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "la1+");
14927c478bd9Sstevel@tonic-gate 	TOS += sizeof (lforth_t);
14937c478bd9Sstevel@tonic-gate }
14947c478bd9Sstevel@tonic-gate 
14957c478bd9Sstevel@tonic-gate void
cell_plus(fcode_env_t * env)14967c478bd9Sstevel@tonic-gate cell_plus(fcode_env_t *env)
14977c478bd9Sstevel@tonic-gate {
14987c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "cell+");
14997c478bd9Sstevel@tonic-gate 	TOS += sizeof (fstack_t);
15007c478bd9Sstevel@tonic-gate }
15017c478bd9Sstevel@tonic-gate 
15027c478bd9Sstevel@tonic-gate void
do_chars(fcode_env_t * env)15037c478bd9Sstevel@tonic-gate do_chars(fcode_env_t *env)
15047c478bd9Sstevel@tonic-gate {
15057c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "chars");
15067c478bd9Sstevel@tonic-gate }
15077c478bd9Sstevel@tonic-gate 
15087c478bd9Sstevel@tonic-gate void
slash_w_times(fcode_env_t * env)15097c478bd9Sstevel@tonic-gate slash_w_times(fcode_env_t *env)
15107c478bd9Sstevel@tonic-gate {
15117c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "/w*");
15127c478bd9Sstevel@tonic-gate 	TOS *= sizeof (wforth_t);
15137c478bd9Sstevel@tonic-gate }
15147c478bd9Sstevel@tonic-gate 
15157c478bd9Sstevel@tonic-gate void
slash_l_times(fcode_env_t * env)15167c478bd9Sstevel@tonic-gate slash_l_times(fcode_env_t *env)
15177c478bd9Sstevel@tonic-gate {
15187c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "/l*");
15197c478bd9Sstevel@tonic-gate 	TOS *= sizeof (lforth_t);
15207c478bd9Sstevel@tonic-gate }
15217c478bd9Sstevel@tonic-gate 
15227c478bd9Sstevel@tonic-gate void
cells(fcode_env_t * env)15237c478bd9Sstevel@tonic-gate cells(fcode_env_t *env)
15247c478bd9Sstevel@tonic-gate {
15257c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "cells");
15267c478bd9Sstevel@tonic-gate 	TOS *= sizeof (fstack_t);
15277c478bd9Sstevel@tonic-gate }
15287c478bd9Sstevel@tonic-gate 
15297c478bd9Sstevel@tonic-gate void
do_on(fcode_env_t * env)15307c478bd9Sstevel@tonic-gate do_on(fcode_env_t *env)
15317c478bd9Sstevel@tonic-gate {
15327c478bd9Sstevel@tonic-gate 	variable_t *d;
15337c478bd9Sstevel@tonic-gate 
15347c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "on");
15357c478bd9Sstevel@tonic-gate 	d = (variable_t *)POP(DS);
15367c478bd9Sstevel@tonic-gate 	*d = -1;
15377c478bd9Sstevel@tonic-gate }
15387c478bd9Sstevel@tonic-gate 
15397c478bd9Sstevel@tonic-gate void
do_off(fcode_env_t * env)15407c478bd9Sstevel@tonic-gate do_off(fcode_env_t *env)
15417c478bd9Sstevel@tonic-gate {
15427c478bd9Sstevel@tonic-gate 	variable_t *d;
15437c478bd9Sstevel@tonic-gate 
15447c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "off");
15457c478bd9Sstevel@tonic-gate 	d = (variable_t *)POP(DS);
15467c478bd9Sstevel@tonic-gate 	*d = 0;
15477c478bd9Sstevel@tonic-gate }
15487c478bd9Sstevel@tonic-gate 
15497c478bd9Sstevel@tonic-gate void
fetch(fcode_env_t * env)15507c478bd9Sstevel@tonic-gate fetch(fcode_env_t *env)
15517c478bd9Sstevel@tonic-gate {
15527c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "@");
15537c478bd9Sstevel@tonic-gate 	TOS = *((variable_t *)TOS);
15547c478bd9Sstevel@tonic-gate }
15557c478bd9Sstevel@tonic-gate 
15567c478bd9Sstevel@tonic-gate void
lfetch(fcode_env_t * env)15577c478bd9Sstevel@tonic-gate lfetch(fcode_env_t *env)
15587c478bd9Sstevel@tonic-gate {
15597c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "l@");
15607c478bd9Sstevel@tonic-gate 	TOS = *((lforth_t *)TOS);
15617c478bd9Sstevel@tonic-gate }
15627c478bd9Sstevel@tonic-gate 
15637c478bd9Sstevel@tonic-gate void
wfetch(fcode_env_t * env)15647c478bd9Sstevel@tonic-gate wfetch(fcode_env_t *env)
15657c478bd9Sstevel@tonic-gate {
15667c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "w@");
15677c478bd9Sstevel@tonic-gate 	TOS = *((wforth_t *)TOS);
15687c478bd9Sstevel@tonic-gate }
15697c478bd9Sstevel@tonic-gate 
15707c478bd9Sstevel@tonic-gate void
swfetch(fcode_env_t * env)15717c478bd9Sstevel@tonic-gate swfetch(fcode_env_t *env)
15727c478bd9Sstevel@tonic-gate {
15737c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "<w@");
15747c478bd9Sstevel@tonic-gate 	TOS = *((s_wforth_t *)TOS);
15757c478bd9Sstevel@tonic-gate }
15767c478bd9Sstevel@tonic-gate 
15777c478bd9Sstevel@tonic-gate void
cfetch(fcode_env_t * env)15787c478bd9Sstevel@tonic-gate cfetch(fcode_env_t *env)
15797c478bd9Sstevel@tonic-gate {
15807c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "c@");
15817c478bd9Sstevel@tonic-gate 	TOS = *((uchar_t *)TOS);
15827c478bd9Sstevel@tonic-gate }
15837c478bd9Sstevel@tonic-gate 
15847c478bd9Sstevel@tonic-gate void
store(fcode_env_t * env)15857c478bd9Sstevel@tonic-gate store(fcode_env_t *env)
15867c478bd9Sstevel@tonic-gate {
15877c478bd9Sstevel@tonic-gate 	variable_t *dptr;
15887c478bd9Sstevel@tonic-gate 
15897c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "!");
15907c478bd9Sstevel@tonic-gate 	dptr = (variable_t *)POP(DS);
15917c478bd9Sstevel@tonic-gate 	*dptr = POP(DS);
15927c478bd9Sstevel@tonic-gate }
15937c478bd9Sstevel@tonic-gate 
15947c478bd9Sstevel@tonic-gate void
addstore(fcode_env_t * env)15957c478bd9Sstevel@tonic-gate addstore(fcode_env_t *env)
15967c478bd9Sstevel@tonic-gate {
15977c478bd9Sstevel@tonic-gate 	variable_t *dptr;
15987c478bd9Sstevel@tonic-gate 
15997c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "+!");
16007c478bd9Sstevel@tonic-gate 	dptr = (variable_t *)POP(DS);
16017c478bd9Sstevel@tonic-gate 	*dptr = POP(DS) + *dptr;
16027c478bd9Sstevel@tonic-gate }
16037c478bd9Sstevel@tonic-gate 
16047c478bd9Sstevel@tonic-gate void
lstore(fcode_env_t * env)16057c478bd9Sstevel@tonic-gate lstore(fcode_env_t *env)
16067c478bd9Sstevel@tonic-gate {
16077c478bd9Sstevel@tonic-gate 	lforth_t *dptr;
16087c478bd9Sstevel@tonic-gate 
16097c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "l!");
16107c478bd9Sstevel@tonic-gate 	dptr = (lforth_t *)POP(DS);
16117c478bd9Sstevel@tonic-gate 	*dptr = (lforth_t)POP(DS);
16127c478bd9Sstevel@tonic-gate }
16137c478bd9Sstevel@tonic-gate 
16147c478bd9Sstevel@tonic-gate void
wstore(fcode_env_t * env)16157c478bd9Sstevel@tonic-gate wstore(fcode_env_t *env)
16167c478bd9Sstevel@tonic-gate {
16177c478bd9Sstevel@tonic-gate 	wforth_t *dptr;
16187c478bd9Sstevel@tonic-gate 
16197c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "w!");
16207c478bd9Sstevel@tonic-gate 	dptr = (wforth_t *)POP(DS);
16217c478bd9Sstevel@tonic-gate 	*dptr = (wforth_t)POP(DS);
16227c478bd9Sstevel@tonic-gate }
16237c478bd9Sstevel@tonic-gate 
16247c478bd9Sstevel@tonic-gate void
cstore(fcode_env_t * env)16257c478bd9Sstevel@tonic-gate cstore(fcode_env_t *env)
16267c478bd9Sstevel@tonic-gate {
16277c478bd9Sstevel@tonic-gate 	uchar_t *dptr;
16287c478bd9Sstevel@tonic-gate 
16297c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "c!");
16307c478bd9Sstevel@tonic-gate 	dptr = (uchar_t *)POP(DS);
16317c478bd9Sstevel@tonic-gate 	*dptr = (uchar_t)POP(DS);
16327c478bd9Sstevel@tonic-gate }
16337c478bd9Sstevel@tonic-gate 
16347c478bd9Sstevel@tonic-gate void
two_fetch(fcode_env_t * env)16357c478bd9Sstevel@tonic-gate two_fetch(fcode_env_t *env)
16367c478bd9Sstevel@tonic-gate {
16377c478bd9Sstevel@tonic-gate 	variable_t *d;
16387c478bd9Sstevel@tonic-gate 
16397c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "2@");
16407c478bd9Sstevel@tonic-gate 	d = (variable_t *)POP(DS);
16417c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)(d + 1));
16427c478bd9Sstevel@tonic-gate 	unaligned_fetch(env);
16437c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)d);
16447c478bd9Sstevel@tonic-gate 	unaligned_fetch(env);
16457c478bd9Sstevel@tonic-gate }
16467c478bd9Sstevel@tonic-gate 
16477c478bd9Sstevel@tonic-gate void
two_store(fcode_env_t * env)16487c478bd9Sstevel@tonic-gate two_store(fcode_env_t *env)
16497c478bd9Sstevel@tonic-gate {
16507c478bd9Sstevel@tonic-gate 	variable_t *d;
16517c478bd9Sstevel@tonic-gate 
16527c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 3, "2!");
16537c478bd9Sstevel@tonic-gate 	d = (variable_t *)POP(DS);
16547c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)d);
16557c478bd9Sstevel@tonic-gate 	unaligned_store(env);
16567c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)(d + 1));
16577c478bd9Sstevel@tonic-gate 	unaligned_store(env);
16587c478bd9Sstevel@tonic-gate }
16597c478bd9Sstevel@tonic-gate 
16607c478bd9Sstevel@tonic-gate /*
16617c478bd9Sstevel@tonic-gate  * 'move' Fcode reimplemented in fcdriver to check for mapped addresses.
16627c478bd9Sstevel@tonic-gate  */
16637c478bd9Sstevel@tonic-gate void
fc_move(fcode_env_t * env)16647c478bd9Sstevel@tonic-gate fc_move(fcode_env_t *env)
16657c478bd9Sstevel@tonic-gate {
16667c478bd9Sstevel@tonic-gate 	void *dest, *src;
16677c478bd9Sstevel@tonic-gate 	size_t len;
16687c478bd9Sstevel@tonic-gate 
16697c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 3, "move");
16707c478bd9Sstevel@tonic-gate 	len  = (size_t)POP(DS);
16717c478bd9Sstevel@tonic-gate 	dest = (void *)POP(DS);
16727c478bd9Sstevel@tonic-gate 	src  = (void *)POP(DS);
16737c478bd9Sstevel@tonic-gate 
16747c478bd9Sstevel@tonic-gate 	memmove(dest, src, len);
16757c478bd9Sstevel@tonic-gate }
16767c478bd9Sstevel@tonic-gate 
16777c478bd9Sstevel@tonic-gate void
fc_fill(fcode_env_t * env)16787c478bd9Sstevel@tonic-gate fc_fill(fcode_env_t *env)
16797c478bd9Sstevel@tonic-gate {
16807c478bd9Sstevel@tonic-gate 	void *dest;
16817c478bd9Sstevel@tonic-gate 	uchar_t val;
16827c478bd9Sstevel@tonic-gate 	size_t len;
16837c478bd9Sstevel@tonic-gate 
16847c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 3, "fill");
16857c478bd9Sstevel@tonic-gate 	val  = (uchar_t)POP(DS);
16867c478bd9Sstevel@tonic-gate 	len  = (size_t)POP(DS);
16877c478bd9Sstevel@tonic-gate 	dest = (void *)POP(DS);
16887c478bd9Sstevel@tonic-gate 	memset(dest, val, len);
16897c478bd9Sstevel@tonic-gate }
16907c478bd9Sstevel@tonic-gate 
16917c478bd9Sstevel@tonic-gate void
fc_comp(fcode_env_t * env)16927c478bd9Sstevel@tonic-gate fc_comp(fcode_env_t *env)
16937c478bd9Sstevel@tonic-gate {
16947c478bd9Sstevel@tonic-gate 	char *str1, *str2;
16957c478bd9Sstevel@tonic-gate 	size_t len;
16967c478bd9Sstevel@tonic-gate 	int res;
16977c478bd9Sstevel@tonic-gate 
16987c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 3, "comp");
16997c478bd9Sstevel@tonic-gate 	len  = (size_t)POP(DS);
17007c478bd9Sstevel@tonic-gate 	str1 = (char *)POP(DS);
17017c478bd9Sstevel@tonic-gate 	str2 = (char *)POP(DS);
17027c478bd9Sstevel@tonic-gate 	res  = memcmp(str2, str1, len);
17037c478bd9Sstevel@tonic-gate 	if (res > 0)
17047c478bd9Sstevel@tonic-gate 		res = 1;
17057c478bd9Sstevel@tonic-gate 	else if (res < 0)
17067c478bd9Sstevel@tonic-gate 		res = -1;
17077c478bd9Sstevel@tonic-gate 	PUSH(DS, res);
17087c478bd9Sstevel@tonic-gate }
17097c478bd9Sstevel@tonic-gate 
17107c478bd9Sstevel@tonic-gate void
set_temporary_compile(fcode_env_t * env)17117c478bd9Sstevel@tonic-gate set_temporary_compile(fcode_env_t *env)
17127c478bd9Sstevel@tonic-gate {
17137c478bd9Sstevel@tonic-gate 	if (!env->state) {
17147c478bd9Sstevel@tonic-gate 		token_roundup(env, "set_temporary_compile");
17157c478bd9Sstevel@tonic-gate 		PUSH(RS, (fstack_t)HERE);
17167c478bd9Sstevel@tonic-gate 		env->state = 3;
17177c478bd9Sstevel@tonic-gate 		COMPILE_TOKEN(&do_colon);
17187c478bd9Sstevel@tonic-gate 	}
17197c478bd9Sstevel@tonic-gate }
17207c478bd9Sstevel@tonic-gate 
17217c478bd9Sstevel@tonic-gate void
bmark(fcode_env_t * env)17227c478bd9Sstevel@tonic-gate bmark(fcode_env_t *env)
17237c478bd9Sstevel@tonic-gate {
17247c478bd9Sstevel@tonic-gate 	set_temporary_compile(env);
17257c478bd9Sstevel@tonic-gate 	env->level++;
17267c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)HERE);
17277c478bd9Sstevel@tonic-gate }
17287c478bd9Sstevel@tonic-gate 
17297c478bd9Sstevel@tonic-gate void
temporary_execute(fcode_env_t * env)17307c478bd9Sstevel@tonic-gate temporary_execute(fcode_env_t *env)
17317c478bd9Sstevel@tonic-gate {
17327c478bd9Sstevel@tonic-gate 	uchar_t *saved_here;
17337c478bd9Sstevel@tonic-gate 
17347c478bd9Sstevel@tonic-gate 	if ((env->level == 0) && (env->state & 2)) {
17357c478bd9Sstevel@tonic-gate 		fstack_t d = POP(RS);
17367c478bd9Sstevel@tonic-gate 
17377c478bd9Sstevel@tonic-gate 		semi(env);
17387c478bd9Sstevel@tonic-gate 
17397c478bd9Sstevel@tonic-gate 		saved_here = HERE;
17407c478bd9Sstevel@tonic-gate 		/* execute the temporary definition */
17417c478bd9Sstevel@tonic-gate 		env->state &= ~2;
17427c478bd9Sstevel@tonic-gate 		PUSH(DS, d);
17437c478bd9Sstevel@tonic-gate 		execute(env);
17447c478bd9Sstevel@tonic-gate 
17457c478bd9Sstevel@tonic-gate 		/* now wind the dictionary back! */
17467c478bd9Sstevel@tonic-gate 		if (saved_here != HERE) {
17477c478bd9Sstevel@tonic-gate 			debug_msg(DEBUG_COMMA, "Ignoring set_here in"
17487c478bd9Sstevel@tonic-gate 			    " temporary_execute\n");
17497c478bd9Sstevel@tonic-gate 		} else
17507c478bd9Sstevel@tonic-gate 			set_here(env, (uchar_t *)d, "temporary_execute");
17517c478bd9Sstevel@tonic-gate 	}
17527c478bd9Sstevel@tonic-gate }
17537c478bd9Sstevel@tonic-gate 
17547c478bd9Sstevel@tonic-gate void
bresolve(fcode_env_t * env)17557c478bd9Sstevel@tonic-gate bresolve(fcode_env_t *env)
17567c478bd9Sstevel@tonic-gate {
17577c478bd9Sstevel@tonic-gate 	token_t *prev = (token_t *)POP(DS);
17587c478bd9Sstevel@tonic-gate 
17597c478bd9Sstevel@tonic-gate 	env->level--;
17607c478bd9Sstevel@tonic-gate 	*prev = (token_t)HERE;
17617c478bd9Sstevel@tonic-gate 	temporary_execute(env);
17627c478bd9Sstevel@tonic-gate }
17637c478bd9Sstevel@tonic-gate 
17647c478bd9Sstevel@tonic-gate #define	BRANCH_IP(ipp)	((token_t *)(*((token_t *)(ipp))))
17657c478bd9Sstevel@tonic-gate 
17667c478bd9Sstevel@tonic-gate void
do_bbranch(fcode_env_t * env)17677c478bd9Sstevel@tonic-gate do_bbranch(fcode_env_t *env)
17687c478bd9Sstevel@tonic-gate {
17697c478bd9Sstevel@tonic-gate 	IP = BRANCH_IP(IP);
17707c478bd9Sstevel@tonic-gate }
17717c478bd9Sstevel@tonic-gate 
17727c478bd9Sstevel@tonic-gate void
do_bqbranch(fcode_env_t * env)17737c478bd9Sstevel@tonic-gate do_bqbranch(fcode_env_t *env)
17747c478bd9Sstevel@tonic-gate {
17757c478bd9Sstevel@tonic-gate 	fstack_t flag;
17767c478bd9Sstevel@tonic-gate 
17777c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "b?branch");
17787c478bd9Sstevel@tonic-gate 	flag = POP(DS);
17797c478bd9Sstevel@tonic-gate 	if (flag) {
17807c478bd9Sstevel@tonic-gate 		IP++;
17817c478bd9Sstevel@tonic-gate 	} else {
17827c478bd9Sstevel@tonic-gate 		IP = BRANCH_IP(IP);
17837c478bd9Sstevel@tonic-gate 	}
17847c478bd9Sstevel@tonic-gate }
17857c478bd9Sstevel@tonic-gate 
17867c478bd9Sstevel@tonic-gate void
do_bofbranch(fcode_env_t * env)17877c478bd9Sstevel@tonic-gate do_bofbranch(fcode_env_t *env)
17887c478bd9Sstevel@tonic-gate {
17897c478bd9Sstevel@tonic-gate 	fstack_t d;
17907c478bd9Sstevel@tonic-gate 
17917c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "bofbranch");
17927c478bd9Sstevel@tonic-gate 	d = POP(DS);
17937c478bd9Sstevel@tonic-gate 	if (d == TOS) {
17947c478bd9Sstevel@tonic-gate 		(void) POP(DS);
17957c478bd9Sstevel@tonic-gate 		IP++;
17967c478bd9Sstevel@tonic-gate 	} else {
17977c478bd9Sstevel@tonic-gate 		IP = BRANCH_IP(IP);
17987c478bd9Sstevel@tonic-gate 	}
17997c478bd9Sstevel@tonic-gate }
18007c478bd9Sstevel@tonic-gate 
18017c478bd9Sstevel@tonic-gate void
do_bleave(fcode_env_t * env)18027c478bd9Sstevel@tonic-gate do_bleave(fcode_env_t *env)
18037c478bd9Sstevel@tonic-gate {
18047c478bd9Sstevel@tonic-gate 	CHECK_RETURN_DEPTH(env, 3, "do_bleave");
18057c478bd9Sstevel@tonic-gate 	(void) POP(RS);
18067c478bd9Sstevel@tonic-gate 	(void) POP(RS);
18077c478bd9Sstevel@tonic-gate 	IP = (token_t *)POP(RS);
18087c478bd9Sstevel@tonic-gate }
18097c478bd9Sstevel@tonic-gate 
18107c478bd9Sstevel@tonic-gate void
loop_inc(fcode_env_t * env,fstack_t inc)18117c478bd9Sstevel@tonic-gate loop_inc(fcode_env_t *env, fstack_t inc)
18127c478bd9Sstevel@tonic-gate {
18137c478bd9Sstevel@tonic-gate 	ufstack_t a;
18147c478bd9Sstevel@tonic-gate 
18157c478bd9Sstevel@tonic-gate 	CHECK_RETURN_DEPTH(env, 2, "loop_inc");
18167c478bd9Sstevel@tonic-gate 
18177c478bd9Sstevel@tonic-gate 	/*
18187c478bd9Sstevel@tonic-gate 	 * Note: end condition is when the sign bit of R[0] changes.
18197c478bd9Sstevel@tonic-gate 	 */
18207c478bd9Sstevel@tonic-gate 	a = RS[0];
18217c478bd9Sstevel@tonic-gate 	RS[0] += inc;
18227c478bd9Sstevel@tonic-gate 	if (((a ^ RS[0]) & SIGN_BIT) == 0) {
18237c478bd9Sstevel@tonic-gate 		IP = BRANCH_IP(IP);
18247c478bd9Sstevel@tonic-gate 	} else {
18257c478bd9Sstevel@tonic-gate 		do_bleave(env);
18267c478bd9Sstevel@tonic-gate 	}
18277c478bd9Sstevel@tonic-gate }
18287c478bd9Sstevel@tonic-gate 
18297c478bd9Sstevel@tonic-gate void
do_bloop(fcode_env_t * env)18307c478bd9Sstevel@tonic-gate do_bloop(fcode_env_t *env)
18317c478bd9Sstevel@tonic-gate {
18327c478bd9Sstevel@tonic-gate 	loop_inc(env, 1);
18337c478bd9Sstevel@tonic-gate }
18347c478bd9Sstevel@tonic-gate 
18357c478bd9Sstevel@tonic-gate void
do_bploop(fcode_env_t * env)18367c478bd9Sstevel@tonic-gate do_bploop(fcode_env_t *env)
18377c478bd9Sstevel@tonic-gate {
18387c478bd9Sstevel@tonic-gate 	fstack_t d;
18397c478bd9Sstevel@tonic-gate 
18407c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "+loop");
18417c478bd9Sstevel@tonic-gate 	d = POP(DS);
18427c478bd9Sstevel@tonic-gate 	loop_inc(env, d);
18437c478bd9Sstevel@tonic-gate }
18447c478bd9Sstevel@tonic-gate 
18457c478bd9Sstevel@tonic-gate void
loop_common(fcode_env_t * env,fstack_t ptr)18467c478bd9Sstevel@tonic-gate loop_common(fcode_env_t *env, fstack_t ptr)
18477c478bd9Sstevel@tonic-gate {
18487c478bd9Sstevel@tonic-gate 	short offset = get_short(env);
18497c478bd9Sstevel@tonic-gate 
18507c478bd9Sstevel@tonic-gate 	COMPILE_TOKEN(ptr);
18517c478bd9Sstevel@tonic-gate 	env->level--;
18527c478bd9Sstevel@tonic-gate 	compile_comma(env);
18537c478bd9Sstevel@tonic-gate 	bresolve(env);
18547c478bd9Sstevel@tonic-gate }
18557c478bd9Sstevel@tonic-gate 
18567c478bd9Sstevel@tonic-gate void
bloop(fcode_env_t * env)18577c478bd9Sstevel@tonic-gate bloop(fcode_env_t *env)
18587c478bd9Sstevel@tonic-gate {
18597c478bd9Sstevel@tonic-gate 	loop_common(env, (fstack_t)&do_loop_ptr);
18607c478bd9Sstevel@tonic-gate }
18617c478bd9Sstevel@tonic-gate 
18627c478bd9Sstevel@tonic-gate void
bplusloop(fcode_env_t * env)18637c478bd9Sstevel@tonic-gate bplusloop(fcode_env_t *env)
18647c478bd9Sstevel@tonic-gate {
18657c478bd9Sstevel@tonic-gate 	loop_common(env, (fstack_t)&do_ploop_ptr);
18667c478bd9Sstevel@tonic-gate }
18677c478bd9Sstevel@tonic-gate 
18687c478bd9Sstevel@tonic-gate void
common_do(fcode_env_t * env,fstack_t endpt,fstack_t start,fstack_t limit)18697c478bd9Sstevel@tonic-gate common_do(fcode_env_t *env, fstack_t endpt, fstack_t start, fstack_t limit)
18707c478bd9Sstevel@tonic-gate {
18717c478bd9Sstevel@tonic-gate 	ufstack_t i, l;
18727c478bd9Sstevel@tonic-gate 
18737c478bd9Sstevel@tonic-gate 	/*
18747c478bd9Sstevel@tonic-gate 	 * Same computation as OBP, sets up so that loop_inc will terminate
18757c478bd9Sstevel@tonic-gate 	 * when the sign bit of RS[0] changes.
18767c478bd9Sstevel@tonic-gate 	 */
18777c478bd9Sstevel@tonic-gate 	i = (start - limit) - SIGN_BIT;
18787c478bd9Sstevel@tonic-gate 	l  = limit + SIGN_BIT;
18797c478bd9Sstevel@tonic-gate 	PUSH(RS, endpt);
18807c478bd9Sstevel@tonic-gate 	PUSH(RS, l);
18817c478bd9Sstevel@tonic-gate 	PUSH(RS, i);
18827c478bd9Sstevel@tonic-gate }
18837c478bd9Sstevel@tonic-gate 
18847c478bd9Sstevel@tonic-gate void
do_bdo(fcode_env_t * env)18857c478bd9Sstevel@tonic-gate do_bdo(fcode_env_t *env)
18867c478bd9Sstevel@tonic-gate {
18877c478bd9Sstevel@tonic-gate 	fstack_t lo, hi;
18887c478bd9Sstevel@tonic-gate 	fstack_t endpt;
18897c478bd9Sstevel@tonic-gate 
18907c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "bdo");
18917c478bd9Sstevel@tonic-gate 	endpt = (fstack_t)BRANCH_IP(IP);
18927c478bd9Sstevel@tonic-gate 	IP++;
18937c478bd9Sstevel@tonic-gate 	lo = POP(DS);
18947c478bd9Sstevel@tonic-gate 	hi = POP(DS);
18957c478bd9Sstevel@tonic-gate 	common_do(env, endpt, lo, hi);
18967c478bd9Sstevel@tonic-gate }
18977c478bd9Sstevel@tonic-gate 
18987c478bd9Sstevel@tonic-gate void
do_bqdo(fcode_env_t * env)18997c478bd9Sstevel@tonic-gate do_bqdo(fcode_env_t *env)
19007c478bd9Sstevel@tonic-gate {
19017c478bd9Sstevel@tonic-gate 	fstack_t lo, hi;
19027c478bd9Sstevel@tonic-gate 	fstack_t endpt;
19037c478bd9Sstevel@tonic-gate 
19047c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "b?do");
19057c478bd9Sstevel@tonic-gate 	endpt = (fstack_t)BRANCH_IP(IP);
19067c478bd9Sstevel@tonic-gate 	IP++;
19077c478bd9Sstevel@tonic-gate 	lo = POP(DS);
19087c478bd9Sstevel@tonic-gate 	hi = POP(DS);
19097c478bd9Sstevel@tonic-gate 	if (lo == hi) {
19107c478bd9Sstevel@tonic-gate 		IP = (token_t *)endpt;
19117c478bd9Sstevel@tonic-gate 	} else {
19127c478bd9Sstevel@tonic-gate 		common_do(env, endpt, lo, hi);
19137c478bd9Sstevel@tonic-gate 	}
19147c478bd9Sstevel@tonic-gate }
19157c478bd9Sstevel@tonic-gate 
19167c478bd9Sstevel@tonic-gate void
compile_do_common(fcode_env_t * env,fstack_t ptr)19177c478bd9Sstevel@tonic-gate compile_do_common(fcode_env_t *env, fstack_t ptr)
19187c478bd9Sstevel@tonic-gate {
19197c478bd9Sstevel@tonic-gate 	set_temporary_compile(env);
19207c478bd9Sstevel@tonic-gate 	COMPILE_TOKEN(ptr);
19217c478bd9Sstevel@tonic-gate 	bmark(env);
19227c478bd9Sstevel@tonic-gate 	COMPILE_TOKEN(0);
19237c478bd9Sstevel@tonic-gate 	bmark(env);
19247c478bd9Sstevel@tonic-gate }
19257c478bd9Sstevel@tonic-gate 
19267c478bd9Sstevel@tonic-gate void
bdo(fcode_env_t * env)19277c478bd9Sstevel@tonic-gate bdo(fcode_env_t *env)
19287c478bd9Sstevel@tonic-gate {
19297c478bd9Sstevel@tonic-gate 	short offset = (short)get_short(env);
19307c478bd9Sstevel@tonic-gate 	compile_do_common(env, (fstack_t)&do_bdo_ptr);
19317c478bd9Sstevel@tonic-gate }
19327c478bd9Sstevel@tonic-gate 
19337c478bd9Sstevel@tonic-gate void
bqdo(fcode_env_t * env)19347c478bd9Sstevel@tonic-gate bqdo(fcode_env_t *env)
19357c478bd9Sstevel@tonic-gate {
19367c478bd9Sstevel@tonic-gate 	short offset = (short)get_short(env);
19377c478bd9Sstevel@tonic-gate 	compile_do_common(env, (fstack_t)&do_bqdo_ptr);
19387c478bd9Sstevel@tonic-gate }
19397c478bd9Sstevel@tonic-gate 
19407c478bd9Sstevel@tonic-gate void
loop_i(fcode_env_t * env)19417c478bd9Sstevel@tonic-gate loop_i(fcode_env_t *env)
19427c478bd9Sstevel@tonic-gate {
19437c478bd9Sstevel@tonic-gate 	fstack_t i;
19447c478bd9Sstevel@tonic-gate 
19457c478bd9Sstevel@tonic-gate 	CHECK_RETURN_DEPTH(env, 2, "i");
19467c478bd9Sstevel@tonic-gate 	i = RS[0] + RS[-1];
19477c478bd9Sstevel@tonic-gate 	PUSH(DS, i);
19487c478bd9Sstevel@tonic-gate }
19497c478bd9Sstevel@tonic-gate 
19507c478bd9Sstevel@tonic-gate void
loop_j(fcode_env_t * env)19517c478bd9Sstevel@tonic-gate loop_j(fcode_env_t *env)
19527c478bd9Sstevel@tonic-gate {
19537c478bd9Sstevel@tonic-gate 	fstack_t j;
19547c478bd9Sstevel@tonic-gate 
19557c478bd9Sstevel@tonic-gate 	CHECK_RETURN_DEPTH(env, 5, "j");
19567c478bd9Sstevel@tonic-gate 	j = RS[-3] + RS[-4];
19577c478bd9Sstevel@tonic-gate 	PUSH(DS, j);
19587c478bd9Sstevel@tonic-gate }
19597c478bd9Sstevel@tonic-gate 
19607c478bd9Sstevel@tonic-gate void
bleave(fcode_env_t * env)19617c478bd9Sstevel@tonic-gate bleave(fcode_env_t *env)
19627c478bd9Sstevel@tonic-gate {
19637c478bd9Sstevel@tonic-gate 
19647c478bd9Sstevel@tonic-gate 	if (env->state) {
19657c478bd9Sstevel@tonic-gate 		COMPILE_TOKEN(&do_leave_ptr);
19667c478bd9Sstevel@tonic-gate 	}
19677c478bd9Sstevel@tonic-gate }
19687c478bd9Sstevel@tonic-gate 
19697c478bd9Sstevel@tonic-gate void
push_string(fcode_env_t * env,char * str,int len)19707c478bd9Sstevel@tonic-gate push_string(fcode_env_t *env, char *str, int len)
19717c478bd9Sstevel@tonic-gate {
19727c478bd9Sstevel@tonic-gate #define	NSTRINGS	16
19737c478bd9Sstevel@tonic-gate 	static int string_count = 0;
19747c478bd9Sstevel@tonic-gate 	static int  buflen[NSTRINGS];
19757c478bd9Sstevel@tonic-gate 	static char *buffer[NSTRINGS];
19767c478bd9Sstevel@tonic-gate 	char *dest;
19777c478bd9Sstevel@tonic-gate 
19787c478bd9Sstevel@tonic-gate 	if (!len) {
19797c478bd9Sstevel@tonic-gate 		PUSH(DS, 0);
19807c478bd9Sstevel@tonic-gate 		PUSH(DS, 0);
19817c478bd9Sstevel@tonic-gate 		return;
19827c478bd9Sstevel@tonic-gate 	}
19837c478bd9Sstevel@tonic-gate 	if (len != buflen[string_count]) {
19847c478bd9Sstevel@tonic-gate 		if (buffer[string_count]) FREE(buffer[string_count]);
19857c478bd9Sstevel@tonic-gate 		buffer[ string_count ] = (char *)MALLOC(len+1);
19867c478bd9Sstevel@tonic-gate 		buflen[ string_count ] = len;
19877c478bd9Sstevel@tonic-gate 	}
19887c478bd9Sstevel@tonic-gate 	dest = buffer[ string_count++ ];
19897c478bd9Sstevel@tonic-gate 	string_count = string_count%NSTRINGS;
19907c478bd9Sstevel@tonic-gate 	memcpy(dest, str, len);
19917c478bd9Sstevel@tonic-gate 	*(dest+len) = 0;
19927c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)dest);
19937c478bd9Sstevel@tonic-gate 	PUSH(DS, len);
19947c478bd9Sstevel@tonic-gate #undef NSTRINGS
19957c478bd9Sstevel@tonic-gate }
19967c478bd9Sstevel@tonic-gate 
19977c478bd9Sstevel@tonic-gate void
parse_word(fcode_env_t * env)19987c478bd9Sstevel@tonic-gate parse_word(fcode_env_t *env)
19997c478bd9Sstevel@tonic-gate {
20007c478bd9Sstevel@tonic-gate 	int len = 0;
20017c478bd9Sstevel@tonic-gate 	char *next, *dest, *here = "";
20027c478bd9Sstevel@tonic-gate 
20037c478bd9Sstevel@tonic-gate 	if (env->input) {
20047c478bd9Sstevel@tonic-gate 		here = env->input->scanptr;
20057c478bd9Sstevel@tonic-gate 		while (*here == env->input->separator) here++;
20067c478bd9Sstevel@tonic-gate 		next = strchr(here, env->input->separator);
20077c478bd9Sstevel@tonic-gate 		if (next) {
20087c478bd9Sstevel@tonic-gate 			len = next - here;
20097c478bd9Sstevel@tonic-gate 			while (*next == env->input->separator) next++;
20107c478bd9Sstevel@tonic-gate 		} else {
20117c478bd9Sstevel@tonic-gate 			len = strlen(here);
20127c478bd9Sstevel@tonic-gate 			next = here + len;
20137c478bd9Sstevel@tonic-gate 		}
20147c478bd9Sstevel@tonic-gate 		env->input->scanptr = next;
20157c478bd9Sstevel@tonic-gate 	}
20167c478bd9Sstevel@tonic-gate 	push_string(env, here, len);
20177c478bd9Sstevel@tonic-gate }
20187c478bd9Sstevel@tonic-gate 
20197c478bd9Sstevel@tonic-gate void
install_does(fcode_env_t * env)20207c478bd9Sstevel@tonic-gate install_does(fcode_env_t *env)
20217c478bd9Sstevel@tonic-gate {
20227c478bd9Sstevel@tonic-gate 	token_t *dptr;
20237c478bd9Sstevel@tonic-gate 
20247c478bd9Sstevel@tonic-gate 	dptr  = (token_t *)LINK_TO_ACF(env->lastlink);
20257c478bd9Sstevel@tonic-gate 
20267c478bd9Sstevel@tonic-gate 	log_message(MSG_WARN, "install_does: Last acf at: %p\n", (void *)dptr);
20277c478bd9Sstevel@tonic-gate 
20287c478bd9Sstevel@tonic-gate 	*dptr = ((token_t)(IP+1)) | 1;
20297c478bd9Sstevel@tonic-gate }
20307c478bd9Sstevel@tonic-gate 
20317c478bd9Sstevel@tonic-gate void
does(fcode_env_t * env)20327c478bd9Sstevel@tonic-gate does(fcode_env_t *env)
20337c478bd9Sstevel@tonic-gate {
20347c478bd9Sstevel@tonic-gate 	token_t *dptr;
20357c478bd9Sstevel@tonic-gate 
20367c478bd9Sstevel@tonic-gate 	token_roundup(env, "does");
20377c478bd9Sstevel@tonic-gate 
20387c478bd9Sstevel@tonic-gate 	if (env->state) {
20397c478bd9Sstevel@tonic-gate 		COMPILE_TOKEN(&does_ptr);
20407c478bd9Sstevel@tonic-gate 		COMPILE_TOKEN(&semi_ptr);
20417c478bd9Sstevel@tonic-gate 	} else {
20427c478bd9Sstevel@tonic-gate 		dptr  = (token_t *)LINK_TO_ACF(env->lastlink);
20437c478bd9Sstevel@tonic-gate 		log_message(MSG_WARN, "does: Last acf at: %p\n", (void *)dptr);
20447c478bd9Sstevel@tonic-gate 		*dptr = ((token_t)(HERE)) | 1;
20457c478bd9Sstevel@tonic-gate 		env->state |= 1;
20467c478bd9Sstevel@tonic-gate 	}
20477c478bd9Sstevel@tonic-gate 	COMPILE_TOKEN(&do_colon);
20487c478bd9Sstevel@tonic-gate }
20497c478bd9Sstevel@tonic-gate 
20507c478bd9Sstevel@tonic-gate void
do_current(fcode_env_t * env)20517c478bd9Sstevel@tonic-gate do_current(fcode_env_t *env)
20527c478bd9Sstevel@tonic-gate {
20537c478bd9Sstevel@tonic-gate 	debug_msg(DEBUG_CONTEXT, "CONTEXT:pushing &CURRENT\n");
20547c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)&env->current);
20557c478bd9Sstevel@tonic-gate }
20567c478bd9Sstevel@tonic-gate 
20577c478bd9Sstevel@tonic-gate void
do_context(fcode_env_t * env)20587c478bd9Sstevel@tonic-gate do_context(fcode_env_t *env)
20597c478bd9Sstevel@tonic-gate {
20607c478bd9Sstevel@tonic-gate 	debug_msg(DEBUG_CONTEXT, "CONTEXT:pushing &CONTEXT\n");
20617c478bd9Sstevel@tonic-gate 	PUSH(DS, (fstack_t)&CONTEXT);
20627c478bd9Sstevel@tonic-gate }
20637c478bd9Sstevel@tonic-gate 
20647c478bd9Sstevel@tonic-gate void
do_definitions(fcode_env_t * env)20657c478bd9Sstevel@tonic-gate do_definitions(fcode_env_t *env)
20667c478bd9Sstevel@tonic-gate {
20677c478bd9Sstevel@tonic-gate 	env->current = CONTEXT;
20687c478bd9Sstevel@tonic-gate 	debug_msg(DEBUG_CONTEXT, "CONTEXT:definitions: %d/%p/%p\n",
20697c478bd9Sstevel@tonic-gate 	    env->order_depth, CONTEXT, env->current);
20707c478bd9Sstevel@tonic-gate }
20717c478bd9Sstevel@tonic-gate 
20727c478bd9Sstevel@tonic-gate void
make_header(fcode_env_t * env,int flags)20737c478bd9Sstevel@tonic-gate make_header(fcode_env_t *env, int flags)
20747c478bd9Sstevel@tonic-gate {
20757c478bd9Sstevel@tonic-gate 	int len;
20767c478bd9Sstevel@tonic-gate 	char *name;
20777c478bd9Sstevel@tonic-gate 
20787c478bd9Sstevel@tonic-gate 	name = parse_a_string(env, &len);
20797c478bd9Sstevel@tonic-gate 	header(env, name, len, flags);
20807c478bd9Sstevel@tonic-gate }
20817c478bd9Sstevel@tonic-gate 
20827c478bd9Sstevel@tonic-gate void
do_creator(fcode_env_t * env)20837c478bd9Sstevel@tonic-gate do_creator(fcode_env_t *env)
20847c478bd9Sstevel@tonic-gate {
20857c478bd9Sstevel@tonic-gate 	make_header(env, 0);
20867c478bd9Sstevel@tonic-gate 	COMPILE_TOKEN(&do_create);
20877c478bd9Sstevel@tonic-gate 	expose_acf(env, "<create>");
20887c478bd9Sstevel@tonic-gate }
20897c478bd9Sstevel@tonic-gate 
20907c478bd9Sstevel@tonic-gate void
create(fcode_env_t * env)20917c478bd9Sstevel@tonic-gate create(fcode_env_t *env)
20927c478bd9Sstevel@tonic-gate {
20937c478bd9Sstevel@tonic-gate 	if (env->state) {
20947c478bd9Sstevel@tonic-gate 		COMPILE_TOKEN(&create_ptr);
20957c478bd9Sstevel@tonic-gate 	} else
20967c478bd9Sstevel@tonic-gate 		do_creator(env);
20977c478bd9Sstevel@tonic-gate }
20987c478bd9Sstevel@tonic-gate 
20997c478bd9Sstevel@tonic-gate void
colon(fcode_env_t * env)21007c478bd9Sstevel@tonic-gate colon(fcode_env_t *env)
21017c478bd9Sstevel@tonic-gate {
21027c478bd9Sstevel@tonic-gate 	make_header(env, 0);
21037c478bd9Sstevel@tonic-gate 	env->state |= 1;
21047c478bd9Sstevel@tonic-gate 	COMPILE_TOKEN(&do_colon);
21057c478bd9Sstevel@tonic-gate }
21067c478bd9Sstevel@tonic-gate 
21077c478bd9Sstevel@tonic-gate void
recursive(fcode_env_t * env)21087c478bd9Sstevel@tonic-gate recursive(fcode_env_t *env)
21097c478bd9Sstevel@tonic-gate {
21107c478bd9Sstevel@tonic-gate 	expose_acf(env, "<recursive>");
21117c478bd9Sstevel@tonic-gate }
21127c478bd9Sstevel@tonic-gate 
21137c478bd9Sstevel@tonic-gate void
compile_string(fcode_env_t * env)21147c478bd9Sstevel@tonic-gate compile_string(fcode_env_t *env)
21157c478bd9Sstevel@tonic-gate {
21167c478bd9Sstevel@tonic-gate 	int len;
21177c478bd9Sstevel@tonic-gate 	uchar_t *str, *tostr;
21187c478bd9Sstevel@tonic-gate 
21197c478bd9Sstevel@tonic-gate 	COMPILE_TOKEN(&quote_ptr);
21207c478bd9Sstevel@tonic-gate 	len = POP(DS);
21217c478bd9Sstevel@tonic-gate 	str = (uchar_t *)POP(DS);
21227c478bd9Sstevel@tonic-gate 	tostr = HERE;
21237c478bd9Sstevel@tonic-gate 	*tostr++ = len;
21247c478bd9Sstevel@tonic-gate 	while (len--)
21257c478bd9Sstevel@tonic-gate 		*tostr++ = *str++;
21267c478bd9Sstevel@tonic-gate 	*tostr++ = '\0';
21277c478bd9Sstevel@tonic-gate 	set_here(env, tostr, "compile_string");
21287c478bd9Sstevel@tonic-gate 	token_roundup(env, "compile_string");
21297c478bd9Sstevel@tonic-gate }
21307c478bd9Sstevel@tonic-gate 
21317c478bd9Sstevel@tonic-gate void
run_quote(fcode_env_t * env)21327c478bd9Sstevel@tonic-gate run_quote(fcode_env_t *env)
21337c478bd9Sstevel@tonic-gate {
21347c478bd9Sstevel@tonic-gate 	char osep;
21357c478bd9Sstevel@tonic-gate 
21367c478bd9Sstevel@tonic-gate 	osep = env->input->separator;
21377c478bd9Sstevel@tonic-gate 	env->input->separator = '"';
21387c478bd9Sstevel@tonic-gate 	parse_word(env);
21397c478bd9Sstevel@tonic-gate 	env->input->separator = osep;
21407c478bd9Sstevel@tonic-gate 
21417c478bd9Sstevel@tonic-gate 	if (env->state) {
21427c478bd9Sstevel@tonic-gate 		compile_string(env);
21437c478bd9Sstevel@tonic-gate 	}
21447c478bd9Sstevel@tonic-gate }
21457c478bd9Sstevel@tonic-gate 
21467c478bd9Sstevel@tonic-gate void
does_vocabulary(fcode_env_t * env)21477c478bd9Sstevel@tonic-gate does_vocabulary(fcode_env_t *env)
21487c478bd9Sstevel@tonic-gate {
21497c478bd9Sstevel@tonic-gate 	CONTEXT = WA;
21507c478bd9Sstevel@tonic-gate 	debug_msg(DEBUG_CONTEXT, "CONTEXT:vocabulary: %d/%p/%p\n",
21517c478bd9Sstevel@tonic-gate 	    env->order_depth, CONTEXT, env->current);
21527c478bd9Sstevel@tonic-gate }
21537c478bd9Sstevel@tonic-gate 
21547c478bd9Sstevel@tonic-gate void
do_vocab(fcode_env_t * env)21557c478bd9Sstevel@tonic-gate do_vocab(fcode_env_t *env)
21567c478bd9Sstevel@tonic-gate {
21577c478bd9Sstevel@tonic-gate 	make_header(env, 0);
21587c478bd9Sstevel@tonic-gate 	COMPILE_TOKEN(does_vocabulary);
21597c478bd9Sstevel@tonic-gate 	PUSH(DS, 0);
21607c478bd9Sstevel@tonic-gate 	compile_comma(env);
21617c478bd9Sstevel@tonic-gate 	expose_acf(env, "<vocabulary>");
21627c478bd9Sstevel@tonic-gate }
21637c478bd9Sstevel@tonic-gate 
21647c478bd9Sstevel@tonic-gate void
do_forth(fcode_env_t * env)21657c478bd9Sstevel@tonic-gate do_forth(fcode_env_t *env)
21667c478bd9Sstevel@tonic-gate {
21677c478bd9Sstevel@tonic-gate 	CONTEXT = (token_t *)(&env->forth_voc_link);
21687c478bd9Sstevel@tonic-gate 	debug_msg(DEBUG_CONTEXT, "CONTEXT:forth: %d/%p/%p\n",
21697c478bd9Sstevel@tonic-gate 	    env->order_depth, CONTEXT, env->current);
21707c478bd9Sstevel@tonic-gate }
21717c478bd9Sstevel@tonic-gate 
21727c478bd9Sstevel@tonic-gate acf_t
voc_find(fcode_env_t * env)21737c478bd9Sstevel@tonic-gate voc_find(fcode_env_t *env)
21747c478bd9Sstevel@tonic-gate {
21757c478bd9Sstevel@tonic-gate 	token_t *voc;
21767c478bd9Sstevel@tonic-gate 	token_t *dptr;
21777c478bd9Sstevel@tonic-gate 	char *find_name, *name;
21787c478bd9Sstevel@tonic-gate 
21797c478bd9Sstevel@tonic-gate 	voc = (token_t *)POP(DS);
21807c478bd9Sstevel@tonic-gate 	find_name = pop_a_string(env, NULL);
21817c478bd9Sstevel@tonic-gate 
21827c478bd9Sstevel@tonic-gate 	for (dptr = (token_t *)(*voc); dptr; dptr = (token_t *)(*dptr)) {
21837c478bd9Sstevel@tonic-gate 		if ((name = get_name(dptr)) == NULL)
21847c478bd9Sstevel@tonic-gate 			continue;
21857c478bd9Sstevel@tonic-gate 		if (strcmp(find_name, name) == 0) {
21867c478bd9Sstevel@tonic-gate 			debug_msg(DEBUG_VOC_FIND, "%s -> %p\n", find_name,
21877c478bd9Sstevel@tonic-gate 			    LINK_TO_ACF(dptr));
21887c478bd9Sstevel@tonic-gate 			return (LINK_TO_ACF(dptr));
21897c478bd9Sstevel@tonic-gate 		}
21907c478bd9Sstevel@tonic-gate 	}
21917c478bd9Sstevel@tonic-gate 	debug_msg(DEBUG_VOC_FIND, "%s not found\n", find_name);
21927c478bd9Sstevel@tonic-gate 	return (NULL);
21937c478bd9Sstevel@tonic-gate }
21947c478bd9Sstevel@tonic-gate 
21957c478bd9Sstevel@tonic-gate void
dollar_find(fcode_env_t * env)21967c478bd9Sstevel@tonic-gate dollar_find(fcode_env_t *env)
21977c478bd9Sstevel@tonic-gate {
21987c478bd9Sstevel@tonic-gate 	acf_t acf = NULL;
21997c478bd9Sstevel@tonic-gate 	int i;
22007c478bd9Sstevel@tonic-gate 
22017c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "$find");
22027c478bd9Sstevel@tonic-gate 	for (i = env->order_depth; i >= 0 && env->order[i] && !acf; i--) {
22037c478bd9Sstevel@tonic-gate 		two_dup(env);
22047c478bd9Sstevel@tonic-gate 		PUSH(DS, (fstack_t)env->order[i]);
22057c478bd9Sstevel@tonic-gate 		acf = voc_find(env);
22067c478bd9Sstevel@tonic-gate 	}
22077c478bd9Sstevel@tonic-gate 	if (acf) {
22087c478bd9Sstevel@tonic-gate 		two_drop(env);
22097c478bd9Sstevel@tonic-gate 		PUSH(DS, (fstack_t)acf);
22107c478bd9Sstevel@tonic-gate 		PUSH(DS, TRUE);
22117c478bd9Sstevel@tonic-gate 	} else
22127c478bd9Sstevel@tonic-gate 		PUSH(DS, FALSE);
22137c478bd9Sstevel@tonic-gate }
22147c478bd9Sstevel@tonic-gate 
22157c478bd9Sstevel@tonic-gate void
interpret(fcode_env_t * env)22167c478bd9Sstevel@tonic-gate interpret(fcode_env_t *env)
22177c478bd9Sstevel@tonic-gate {
22187c478bd9Sstevel@tonic-gate 	char *name;
22197c478bd9Sstevel@tonic-gate 
22207c478bd9Sstevel@tonic-gate 	parse_word(env);
22217c478bd9Sstevel@tonic-gate 	while (TOS) {
22227c478bd9Sstevel@tonic-gate 		two_dup(env);
22237c478bd9Sstevel@tonic-gate 		dollar_find(env);
22247c478bd9Sstevel@tonic-gate 		if (TOS) {
22257c478bd9Sstevel@tonic-gate 			flag_t *flags;
22267c478bd9Sstevel@tonic-gate 
22277c478bd9Sstevel@tonic-gate 			drop(env);
22287c478bd9Sstevel@tonic-gate 			nip(env);
22297c478bd9Sstevel@tonic-gate 			nip(env);
22307c478bd9Sstevel@tonic-gate 			flags = LINK_TO_FLAGS(ACF_TO_LINK(TOS));
22317c478bd9Sstevel@tonic-gate 
22327c478bd9Sstevel@tonic-gate 			if ((env->state) &&
22337c478bd9Sstevel@tonic-gate 			    ((*flags & IMMEDIATE) == 0)) {
22347c478bd9Sstevel@tonic-gate 				/* Compile in references */
22357c478bd9Sstevel@tonic-gate 				compile_comma(env);
22367c478bd9Sstevel@tonic-gate 			} else {
22377c478bd9Sstevel@tonic-gate 				execute(env);
22387c478bd9Sstevel@tonic-gate 			}
22397c478bd9Sstevel@tonic-gate 		} else {
22407c478bd9Sstevel@tonic-gate 			int bad;
22417c478bd9Sstevel@tonic-gate 			drop(env);
22427c478bd9Sstevel@tonic-gate 			dollar_number(env);
22437c478bd9Sstevel@tonic-gate 			bad = POP(DS);
22447c478bd9Sstevel@tonic-gate 			if (bad) {
22457c478bd9Sstevel@tonic-gate 				two_dup(env);
22467c478bd9Sstevel@tonic-gate 				name = pop_a_string(env, NULL);
22477c478bd9Sstevel@tonic-gate 				log_message(MSG_INFO, "%s?\n", name);
22487c478bd9Sstevel@tonic-gate 				break;
22497c478bd9Sstevel@tonic-gate 			} else {
22507c478bd9Sstevel@tonic-gate 				nip(env);
22517c478bd9Sstevel@tonic-gate 				nip(env);
22527c478bd9Sstevel@tonic-gate 				literal(env);
22537c478bd9Sstevel@tonic-gate 			}
22547c478bd9Sstevel@tonic-gate 		}
22557c478bd9Sstevel@tonic-gate 		parse_word(env);
22567c478bd9Sstevel@tonic-gate 	}
22577c478bd9Sstevel@tonic-gate 	two_drop(env);
22587c478bd9Sstevel@tonic-gate }
22597c478bd9Sstevel@tonic-gate 
22607c478bd9Sstevel@tonic-gate void
evaluate(fcode_env_t * env)22617c478bd9Sstevel@tonic-gate evaluate(fcode_env_t *env)
22627c478bd9Sstevel@tonic-gate {
22637c478bd9Sstevel@tonic-gate 	input_typ *old_input = env->input;
22647c478bd9Sstevel@tonic-gate 	input_typ *eval_bufp = MALLOC(sizeof (input_typ));
22657c478bd9Sstevel@tonic-gate 
22667c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 2, "evaluate");
22677c478bd9Sstevel@tonic-gate 	eval_bufp->separator = ' ';
22687c478bd9Sstevel@tonic-gate 	eval_bufp->maxlen = POP(DS);
22697c478bd9Sstevel@tonic-gate 	eval_bufp->buffer = (char *)POP(DS);
22707c478bd9Sstevel@tonic-gate 	eval_bufp->scanptr = eval_bufp->buffer;
22717c478bd9Sstevel@tonic-gate 	env->input = eval_bufp;
22727c478bd9Sstevel@tonic-gate 	interpret(env);
22737c478bd9Sstevel@tonic-gate 	FREE(eval_bufp);
22747c478bd9Sstevel@tonic-gate 	env->input = old_input;
22757c478bd9Sstevel@tonic-gate }
22767c478bd9Sstevel@tonic-gate 
22777c478bd9Sstevel@tonic-gate void
make_common_access(fcode_env_t * env,char * name,int len,int ncells,int instance_mode,void (* acf_instance)(fcode_env_t * env),void (* acf_static)(fcode_env_t * env),void (* set_action)(fcode_env_t * env,int))22787c478bd9Sstevel@tonic-gate make_common_access(fcode_env_t *env,
22797c478bd9Sstevel@tonic-gate     char *name, int len,
22807c478bd9Sstevel@tonic-gate     int ncells,
22817c478bd9Sstevel@tonic-gate     int instance_mode,
22827c478bd9Sstevel@tonic-gate     void (*acf_instance)(fcode_env_t *env),
22837c478bd9Sstevel@tonic-gate     void (*acf_static)(fcode_env_t *env),
22847c478bd9Sstevel@tonic-gate     void (*set_action)(fcode_env_t *env, int))
22857c478bd9Sstevel@tonic-gate {
22867c478bd9Sstevel@tonic-gate 	if (instance_mode && !MYSELF) {
22877c478bd9Sstevel@tonic-gate 		system_message(env, "No instance context");
22887c478bd9Sstevel@tonic-gate 	}
22897c478bd9Sstevel@tonic-gate 
22907c478bd9Sstevel@tonic-gate 	debug_msg(DEBUG_ACTIONS, "make_common_access:%s '%s', %d\n",
22917c478bd9Sstevel@tonic-gate 	    (instance_mode ? "instance" : ""),
22927c478bd9Sstevel@tonic-gate 	    (name ? name : ""), ncells);
22937c478bd9Sstevel@tonic-gate 
22947c478bd9Sstevel@tonic-gate 	if (len)
22957c478bd9Sstevel@tonic-gate 		header(env, name, len, 0);
22967c478bd9Sstevel@tonic-gate 	if (instance_mode) {
22977c478bd9Sstevel@tonic-gate 		token_t *dptr;
22987c478bd9Sstevel@tonic-gate 		int offset;
22997c478bd9Sstevel@tonic-gate 
23007c478bd9Sstevel@tonic-gate 		COMPILE_TOKEN(acf_instance);
23017c478bd9Sstevel@tonic-gate 		dptr = alloc_instance_data(env, INIT_DATA, ncells, &offset);
23027c478bd9Sstevel@tonic-gate 		debug_msg(DEBUG_ACTIONS, "Data: %p, offset %d\n", (char *)dptr,
23037c478bd9Sstevel@tonic-gate 		    offset);
23047c478bd9Sstevel@tonic-gate 		PUSH(DS, offset);
23057c478bd9Sstevel@tonic-gate 		compile_comma(env);
23067c478bd9Sstevel@tonic-gate 		while (ncells--)
23077c478bd9Sstevel@tonic-gate 			*dptr++ = MYSELF->data[INIT_DATA][offset++] = POP(DS);
23087c478bd9Sstevel@tonic-gate 		env->instance_mode = 0;
23097c478bd9Sstevel@tonic-gate 	} else {
23107c478bd9Sstevel@tonic-gate 		COMPILE_TOKEN(acf_static);
23117c478bd9Sstevel@tonic-gate 		while (ncells--)
23127c478bd9Sstevel@tonic-gate 			compile_comma(env);
23137c478bd9Sstevel@tonic-gate 	}
23147c478bd9Sstevel@tonic-gate 	expose_acf(env, name);
23157c478bd9Sstevel@tonic-gate 	if (set_action)
23167c478bd9Sstevel@tonic-gate 		set_action(env, instance_mode);
23177c478bd9Sstevel@tonic-gate }
23187c478bd9Sstevel@tonic-gate 
23197c478bd9Sstevel@tonic-gate void
do_constant(fcode_env_t * env)23207c478bd9Sstevel@tonic-gate do_constant(fcode_env_t *env)
23217c478bd9Sstevel@tonic-gate {
23227c478bd9Sstevel@tonic-gate 	PUSH(DS, (variable_t)(*WA));
23237c478bd9Sstevel@tonic-gate }
23247c478bd9Sstevel@tonic-gate 
23257c478bd9Sstevel@tonic-gate void
do_crash(fcode_env_t * env)23267c478bd9Sstevel@tonic-gate do_crash(fcode_env_t *env)
23277c478bd9Sstevel@tonic-gate {
23287c478bd9Sstevel@tonic-gate 	forth_abort(env, "Unitialized defer");
23297c478bd9Sstevel@tonic-gate }
23307c478bd9Sstevel@tonic-gate 
23317c478bd9Sstevel@tonic-gate /*
23327c478bd9Sstevel@tonic-gate  * 'behavior' Fcode retrieve execution behavior for a defer word.
23337c478bd9Sstevel@tonic-gate  */
23347c478bd9Sstevel@tonic-gate static void
behavior(fcode_env_t * env)23357c478bd9Sstevel@tonic-gate behavior(fcode_env_t *env)
23367c478bd9Sstevel@tonic-gate {
23377c478bd9Sstevel@tonic-gate 	acf_t defer_xt;
23387c478bd9Sstevel@tonic-gate 	token_t token;
23397c478bd9Sstevel@tonic-gate 	acf_t contents_xt;
23407c478bd9Sstevel@tonic-gate 
23417c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "behavior");
23427c478bd9Sstevel@tonic-gate 	defer_xt = (acf_t)POP(DS);
23437c478bd9Sstevel@tonic-gate 	token = *defer_xt;
23447c478bd9Sstevel@tonic-gate 	contents_xt = (token_t *)(token & ~1);
23457c478bd9Sstevel@tonic-gate 	if ((token & 1) == 0 || *contents_xt != (token_t)&do_default_action)
23467c478bd9Sstevel@tonic-gate 		forth_abort(env, "behavior: bad xt: %p indir: %x/%p\n",
23477c478bd9Sstevel@tonic-gate 		    defer_xt, token & 1, *contents_xt);
23487c478bd9Sstevel@tonic-gate 	defer_xt++;
23497c478bd9Sstevel@tonic-gate 	PUSH(DS, *((variable_t *)defer_xt));
23507c478bd9Sstevel@tonic-gate }
23517c478bd9Sstevel@tonic-gate 
23527c478bd9Sstevel@tonic-gate void
fc_abort(fcode_env_t * env,char * type)23537c478bd9Sstevel@tonic-gate fc_abort(fcode_env_t *env, char *type)
23547c478bd9Sstevel@tonic-gate {
23557c478bd9Sstevel@tonic-gate 	forth_abort(env, "%s Fcode '%s' Executed", type,
23567c478bd9Sstevel@tonic-gate 	    acf_to_name(env, WA - 1));
23577c478bd9Sstevel@tonic-gate }
23587c478bd9Sstevel@tonic-gate 
23597c478bd9Sstevel@tonic-gate void
f_abort(fcode_env_t * env)23607c478bd9Sstevel@tonic-gate f_abort(fcode_env_t *env)
23617c478bd9Sstevel@tonic-gate {
23627c478bd9Sstevel@tonic-gate 	fc_abort(env, "Abort");
23637c478bd9Sstevel@tonic-gate }
23647c478bd9Sstevel@tonic-gate 
23657c478bd9Sstevel@tonic-gate /*
23667c478bd9Sstevel@tonic-gate  * Fcodes chosen not to support.
23677c478bd9Sstevel@tonic-gate  */
23687c478bd9Sstevel@tonic-gate void
fc_unimplemented(fcode_env_t * env)23697c478bd9Sstevel@tonic-gate fc_unimplemented(fcode_env_t *env)
23707c478bd9Sstevel@tonic-gate {
23717c478bd9Sstevel@tonic-gate 	fc_abort(env, "Unimplemented");
23727c478bd9Sstevel@tonic-gate }
23737c478bd9Sstevel@tonic-gate 
23747c478bd9Sstevel@tonic-gate /*
23757c478bd9Sstevel@tonic-gate  * Fcodes that are Obsolete per P1275-1994.
23767c478bd9Sstevel@tonic-gate  */
23777c478bd9Sstevel@tonic-gate void
fc_obsolete(fcode_env_t * env)23787c478bd9Sstevel@tonic-gate fc_obsolete(fcode_env_t *env)
23797c478bd9Sstevel@tonic-gate {
23807c478bd9Sstevel@tonic-gate 	fc_abort(env, "Obsolete");
23817c478bd9Sstevel@tonic-gate }
23827c478bd9Sstevel@tonic-gate 
23837c478bd9Sstevel@tonic-gate /*
23847c478bd9Sstevel@tonic-gate  * Fcodes that are Historical per P1275-1994
23857c478bd9Sstevel@tonic-gate  */
23867c478bd9Sstevel@tonic-gate void
fc_historical(fcode_env_t * env)23877c478bd9Sstevel@tonic-gate fc_historical(fcode_env_t *env)
23887c478bd9Sstevel@tonic-gate {
23897c478bd9Sstevel@tonic-gate 	fc_abort(env, "Historical");
23907c478bd9Sstevel@tonic-gate }
23917c478bd9Sstevel@tonic-gate 
23927c478bd9Sstevel@tonic-gate void
catch(fcode_env_t * env)23937c478bd9Sstevel@tonic-gate catch(fcode_env_t *env)
23947c478bd9Sstevel@tonic-gate {
23957c478bd9Sstevel@tonic-gate 	error_frame *new;
23967c478bd9Sstevel@tonic-gate 
23977c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "catch");
23987c478bd9Sstevel@tonic-gate 	new = MALLOC(sizeof (error_frame));
23997c478bd9Sstevel@tonic-gate 	new->ds		= DS-1;
24007c478bd9Sstevel@tonic-gate 	new->rs		= RS;
24017c478bd9Sstevel@tonic-gate 	new->myself	= MYSELF;
24027c478bd9Sstevel@tonic-gate 	new->next	= env->catch_frame;
24037c478bd9Sstevel@tonic-gate 	new->code	= 0;
24047c478bd9Sstevel@tonic-gate 	env->catch_frame = new;
24057c478bd9Sstevel@tonic-gate 	execute(env);
24067c478bd9Sstevel@tonic-gate 	PUSH(DS, new->code);
24077c478bd9Sstevel@tonic-gate 	env->catch_frame = new->next;
24087c478bd9Sstevel@tonic-gate 	FREE(new);
24097c478bd9Sstevel@tonic-gate }
24107c478bd9Sstevel@tonic-gate 
24117c478bd9Sstevel@tonic-gate void
throw_from_fclib(fcode_env_t * env,fstack_t errcode,char * fmt,...)24127c478bd9Sstevel@tonic-gate throw_from_fclib(fcode_env_t *env, fstack_t errcode, char *fmt, ...)
24137c478bd9Sstevel@tonic-gate {
24147c478bd9Sstevel@tonic-gate 	error_frame *efp;
24157c478bd9Sstevel@tonic-gate 	va_list ap;
24167c478bd9Sstevel@tonic-gate 	char msg[256];
24177c478bd9Sstevel@tonic-gate 
24187c478bd9Sstevel@tonic-gate 	va_start(ap, fmt);
24197c478bd9Sstevel@tonic-gate 	vsprintf(msg, fmt, ap);
24207c478bd9Sstevel@tonic-gate 
24217c478bd9Sstevel@tonic-gate 	if (errcode) {
24227c478bd9Sstevel@tonic-gate 
24237c478bd9Sstevel@tonic-gate 		env->last_error = errcode;
24247c478bd9Sstevel@tonic-gate 
24257c478bd9Sstevel@tonic-gate 		/*
24267c478bd9Sstevel@tonic-gate 		 * No catch frame set => fatal error
24277c478bd9Sstevel@tonic-gate 		 */
24287c478bd9Sstevel@tonic-gate 		efp = env->catch_frame;
24297c478bd9Sstevel@tonic-gate 		if (!efp)
24307c478bd9Sstevel@tonic-gate 			forth_abort(env, "%s: No catch frame", msg);
24317c478bd9Sstevel@tonic-gate 
24327c478bd9Sstevel@tonic-gate 		debug_msg(DEBUG_TRACING, "throw_from_fclib: throw: %s\n", msg);
24337c478bd9Sstevel@tonic-gate 
24347c478bd9Sstevel@tonic-gate 		/*
24357c478bd9Sstevel@tonic-gate 		 * Setting IP=0 will force the unwinding of the calls
24367c478bd9Sstevel@tonic-gate 		 * (see execute) which is how we will return (eventually)
24377c478bd9Sstevel@tonic-gate 		 * to the test in catch that follows 'execute'.
24387c478bd9Sstevel@tonic-gate 		 */
24397c478bd9Sstevel@tonic-gate 		DS		= efp->ds;
24407c478bd9Sstevel@tonic-gate 		RS		= efp->rs;
24417c478bd9Sstevel@tonic-gate 		MYSELF		= efp->myself;
24427c478bd9Sstevel@tonic-gate 		IP		= 0;
24437c478bd9Sstevel@tonic-gate 		efp->code	= errcode;
24447c478bd9Sstevel@tonic-gate 	}
24457c478bd9Sstevel@tonic-gate }
24467c478bd9Sstevel@tonic-gate 
24477c478bd9Sstevel@tonic-gate void
throw(fcode_env_t * env)24487c478bd9Sstevel@tonic-gate throw(fcode_env_t *env)
24497c478bd9Sstevel@tonic-gate {
24507c478bd9Sstevel@tonic-gate 	fstack_t t;
24517c478bd9Sstevel@tonic-gate 
24527c478bd9Sstevel@tonic-gate 	CHECK_DEPTH(env, 1, "throw");
24537c478bd9Sstevel@tonic-gate 	t = POP(DS);
24547c478bd9Sstevel@tonic-gate 	if (t >= -20 && t <= 20)
24557c478bd9Sstevel@tonic-gate 		throw_from_fclib(env, t, "throw Fcode errcode: 0x%x", (int)t);
24567c478bd9Sstevel@tonic-gate 	else {
24577c478bd9Sstevel@tonic-gate 		if (t)
24587c478bd9Sstevel@tonic-gate 			log_message(MSG_ERROR, "throw: errcode: 0x%x\n",
24597c478bd9Sstevel@tonic-gate 			    (int)t);
24607c478bd9Sstevel@tonic-gate 		throw_from_fclib(env, t, "throw Fcode err: %s", (char *)t);
24617c478bd9Sstevel@tonic-gate 	}
24627c478bd9Sstevel@tonic-gate }
24637c478bd9Sstevel@tonic-gate 
24647c478bd9Sstevel@tonic-gate void
tick_literal(fcode_env_t * env)24657c478bd9Sstevel@tonic-gate tick_literal(fcode_env_t *env)
24667c478bd9Sstevel@tonic-gate {
24677c478bd9Sstevel@tonic-gate 	if (env->state) {
24687c478bd9Sstevel@tonic-gate 		COMPILE_TOKEN(&tlit_ptr);
24697c478bd9Sstevel@tonic-gate 		compile_comma(env);
24707c478bd9Sstevel@tonic-gate 	}
24717c478bd9Sstevel@tonic-gate }
24727c478bd9Sstevel@tonic-gate 
24737c478bd9Sstevel@tonic-gate void
do_tick(fcode_env_t * env)24747c478bd9Sstevel@tonic-gate do_tick(fcode_env_t *env)
24757c478bd9Sstevel@tonic-gate {
24767c478bd9Sstevel@tonic-gate 	parse_word(env);
24777c478bd9Sstevel@tonic-gate 	dollar_find(env);
24787c478bd9Sstevel@tonic-gate 	invert(env);
24797c478bd9Sstevel@tonic-gate 	throw(env);
24807c478bd9Sstevel@tonic-gate 	tick_literal(env);
24817c478bd9Sstevel@tonic-gate }
24827c478bd9Sstevel@tonic-gate 
24837c478bd9Sstevel@tonic-gate void
bracket_tick(fcode_env_t * env)24847c478bd9Sstevel@tonic-gate bracket_tick(fcode_env_t *env)
24857c478bd9Sstevel@tonic-gate {
24867c478bd9Sstevel@tonic-gate 	do_tick(env);
24877c478bd9Sstevel@tonic-gate }
24887c478bd9Sstevel@tonic-gate 
24897c478bd9Sstevel@tonic-gate #pragma init(_init)
24907c478bd9Sstevel@tonic-gate 
24917c478bd9Sstevel@tonic-gate static void
_init(void)24927c478bd9Sstevel@tonic-gate _init(void)
24937c478bd9Sstevel@tonic-gate {
24947c478bd9Sstevel@tonic-gate 	fcode_env_t *env = initial_env;
24957c478bd9Sstevel@tonic-gate 
24967c478bd9Sstevel@tonic-gate 	NOTICE;
24977c478bd9Sstevel@tonic-gate 	ASSERT(env);
24987c478bd9Sstevel@tonic-gate 
24997c478bd9Sstevel@tonic-gate 	ANSI(0x019, 0,		"i",			loop_i);
25007c478bd9Sstevel@tonic-gate 	ANSI(0x01a, 0,		"j",			loop_j);
25017c478bd9Sstevel@tonic-gate 	ANSI(0x01d, 0,		"execute",		execute);
25027c478bd9Sstevel@tonic-gate 	ANSI(0x01e, 0,		"+",			add);
25037c478bd9Sstevel@tonic-gate 	ANSI(0x01f, 0,		"-",			subtract);
25047c478bd9Sstevel@tonic-gate 	ANSI(0x020, 0,		"*",			multiply);
25057c478bd9Sstevel@tonic-gate 	ANSI(0x021, 0,		"/",			divide);
25067c478bd9Sstevel@tonic-gate 	ANSI(0x022, 0,		"mod",			mod);
25077c478bd9Sstevel@tonic-gate 	FORTH(0,		"/mod",			slash_mod);
25087c478bd9Sstevel@tonic-gate 	ANSI(0x023, 0,		"and",			and);
25097c478bd9Sstevel@tonic-gate 	ANSI(0x024, 0,		"or",			or);
25107c478bd9Sstevel@tonic-gate 	ANSI(0x025, 0,		"xor",			xor);
25117c478bd9Sstevel@tonic-gate 	ANSI(0x026, 0,		"invert",		invert);
25127c478bd9Sstevel@tonic-gate 	ANSI(0x027, 0,		"lshift",		lshift);
25137c478bd9Sstevel@tonic-gate 	ANSI(0x028, 0,		"rshift",		rshift);
25147c478bd9Sstevel@tonic-gate 	ANSI(0x029, 0,		">>a",			rshifta);
25157c478bd9Sstevel@tonic-gate 	ANSI(0x02a, 0,		"/mod",			slash_mod);
25167c478bd9Sstevel@tonic-gate 	ANSI(0x02b, 0,		"u/mod",		uslash_mod);
25177c478bd9Sstevel@tonic-gate 	ANSI(0x02c, 0,		"negate",		negate);
25187c478bd9Sstevel@tonic-gate 	ANSI(0x02d, 0,		"abs",			f_abs);
25197c478bd9Sstevel@tonic-gate 	ANSI(0x02e, 0,		"min",			f_min);
25207c478bd9Sstevel@tonic-gate 	ANSI(0x02f, 0,		"max",			f_max);
25217c478bd9Sstevel@tonic-gate 	ANSI(0x030, 0,		">r",			to_r);
25227c478bd9Sstevel@tonic-gate 	ANSI(0x031, 0,		"r>",			from_r);
25237c478bd9Sstevel@tonic-gate 	ANSI(0x032, 0,		"r@",			rfetch);
25247c478bd9Sstevel@tonic-gate 	ANSI(0x033, 0,		"exit",			f_exit);
25257c478bd9Sstevel@tonic-gate 	ANSI(0x034, 0,		"0=",			zero_equals);
25267c478bd9Sstevel@tonic-gate 	ANSI(0x035, 0,		"0<>",			zero_not_equals);
25277c478bd9Sstevel@tonic-gate 	ANSI(0x036, 0,		"0<",			zero_less);
25287c478bd9Sstevel@tonic-gate 	ANSI(0x037, 0,		"0<=",			zero_less_equals);
25297c478bd9Sstevel@tonic-gate 	ANSI(0x038, 0,		"0>",			zero_greater);
25307c478bd9Sstevel@tonic-gate 	ANSI(0x039, 0,		"0>=",			zero_greater_equals);
25317c478bd9Sstevel@tonic-gate 	ANSI(0x03a, 0,		"<",			less);
25327c478bd9Sstevel@tonic-gate 	ANSI(0x03b, 0,		">",			greater);
25337c478bd9Sstevel@tonic-gate 	ANSI(0x03c, 0,		"=",			equals);
25347c478bd9Sstevel@tonic-gate 	ANSI(0x03d, 0,		"<>",			not_equals);
25357c478bd9Sstevel@tonic-gate 	ANSI(0x03e, 0,		"u>",			unsign_greater);
25367c478bd9Sstevel@tonic-gate 	ANSI(0x03f, 0,		"u<=",			unsign_less_equals);
25377c478bd9Sstevel@tonic-gate 	ANSI(0x040, 0,		"u<",			unsign_less);
25387c478bd9Sstevel@tonic-gate 	ANSI(0x041, 0,		"u>=",			unsign_greater_equals);
25397c478bd9Sstevel@tonic-gate 	ANSI(0x042, 0,		">=",			greater_equals);
25407c478bd9Sstevel@tonic-gate 	ANSI(0x043, 0,		"<=",			less_equals);
25417c478bd9Sstevel@tonic-gate 	ANSI(0x044, 0,		"between",		between);
25427c478bd9Sstevel@tonic-gate 	ANSI(0x045, 0,		"within",		within);
25437c478bd9Sstevel@tonic-gate 	ANSI(0x046, 0,		"drop",			drop);
25447c478bd9Sstevel@tonic-gate 	ANSI(0x047, 0,		"dup",			f_dup);
25457c478bd9Sstevel@tonic-gate 	ANSI(0x048, 0,		"over",			over);
25467c478bd9Sstevel@tonic-gate 	ANSI(0x049, 0,		"swap",			swap);
25477c478bd9Sstevel@tonic-gate 	ANSI(0x04a, 0,		"rot",			rot);
25487c478bd9Sstevel@tonic-gate 	ANSI(0x04b, 0,		"-rot",			minus_rot);
25497c478bd9Sstevel@tonic-gate 	ANSI(0x04c, 0,		"tuck",			tuck);
25507c478bd9Sstevel@tonic-gate 	ANSI(0x04d, 0,		"nip",			nip);
25517c478bd9Sstevel@tonic-gate 	ANSI(0x04e, 0,		"pick",			pick);
25527c478bd9Sstevel@tonic-gate 	ANSI(0x04f, 0,		"roll",			roll);
25537c478bd9Sstevel@tonic-gate 	ANSI(0x050, 0,		"?dup",			qdup);
25547c478bd9Sstevel@tonic-gate 	ANSI(0x051, 0,		"depth",		depth);
25557c478bd9Sstevel@tonic-gate 	ANSI(0x052, 0,		"2drop",		two_drop);
25567c478bd9Sstevel@tonic-gate 	ANSI(0x053, 0,		"2dup",			two_dup);
25577c478bd9Sstevel@tonic-gate 	ANSI(0x054, 0,		"2over",		two_over);
25587c478bd9Sstevel@tonic-gate 	ANSI(0x055, 0,		"2swap",		two_swap);
25597c478bd9Sstevel@tonic-gate 	ANSI(0x056, 0,		"2rot",			two_rot);
25607c478bd9Sstevel@tonic-gate 	ANSI(0x057, 0,		"2/",			two_slash);
25617c478bd9Sstevel@tonic-gate 	ANSI(0x058, 0,		"u2/",			utwo_slash);
25627c478bd9Sstevel@tonic-gate 	ANSI(0x059, 0,		"2*",			two_times);
25637c478bd9Sstevel@tonic-gate 	ANSI(0x05a, 0,		"/c",			slash_c);
25647c478bd9Sstevel@tonic-gate 	ANSI(0x05b, 0,		"/w",			slash_w);
25657c478bd9Sstevel@tonic-gate 	ANSI(0x05c, 0,		"/l",			slash_l);
25667c478bd9Sstevel@tonic-gate 	ANSI(0x05d, 0,		"/n",			slash_n);
25677c478bd9Sstevel@tonic-gate 	ANSI(0x05e, 0,		"ca+",			ca_plus);
25687c478bd9Sstevel@tonic-gate 	ANSI(0x05f, 0,		"wa+",			wa_plus);
25697c478bd9Sstevel@tonic-gate 	ANSI(0x060, 0,		"la+",			la_plus);
25707c478bd9Sstevel@tonic-gate 	ANSI(0x061, 0,		"na+",			na_plus);
25717c478bd9Sstevel@tonic-gate 	ANSI(0x062, 0,		"char+",		char_plus);
25727c478bd9Sstevel@tonic-gate 	ANSI(0x063, 0,		"wa1+",			wa1_plus);
25737c478bd9Sstevel@tonic-gate 	ANSI(0x064, 0,		"la1+",			la1_plus);
25747c478bd9Sstevel@tonic-gate 	ANSI(0x065, 0,		"cell+",		cell_plus);
25757c478bd9Sstevel@tonic-gate 	ANSI(0x066, 0,		"chars",		do_chars);
25767c478bd9Sstevel@tonic-gate 	ANSI(0x067, 0,		"/w*",			slash_w_times);
25777c478bd9Sstevel@tonic-gate 	ANSI(0x068, 0,		"/l*",			slash_l_times);
25787c478bd9Sstevel@tonic-gate 	ANSI(0x069, 0,		"cells",		cells);
25797c478bd9Sstevel@tonic-gate 	ANSI(0x06a, 0,		"on",			do_on);
25807c478bd9Sstevel@tonic-gate 	ANSI(0x06b, 0,		"off",			do_off);
25817c478bd9Sstevel@tonic-gate 	ANSI(0x06c, 0,		"+!",			addstore);
25827c478bd9Sstevel@tonic-gate 	ANSI(0x06d, 0,		"@",			fetch);
25837c478bd9Sstevel@tonic-gate 	ANSI(0x06e, 0,		"l@",			lfetch);
25847c478bd9Sstevel@tonic-gate 	ANSI(0x06f, 0,		"w@",			wfetch);
25857c478bd9Sstevel@tonic-gate 	ANSI(0x070, 0,		"<w@",			swfetch);
25867c478bd9Sstevel@tonic-gate 	ANSI(0x071, 0,		"c@",			cfetch);
25877c478bd9Sstevel@tonic-gate 	ANSI(0x072, 0,		"!",			store);
25887c478bd9Sstevel@tonic-gate 	ANSI(0x073, 0,		"l!",			lstore);
25897c478bd9Sstevel@tonic-gate 	ANSI(0x074, 0,		"w!",			wstore);
25907c478bd9Sstevel@tonic-gate 	ANSI(0x075, 0,		"c!",			cstore);
25917c478bd9Sstevel@tonic-gate 	ANSI(0x076, 0,		"2@",			two_fetch);
25927c478bd9Sstevel@tonic-gate 	ANSI(0x077, 0,		"2!",			two_store);
25937c478bd9Sstevel@tonic-gate 	ANSI(0x078, 0,		"move",			fc_move);
25947c478bd9Sstevel@tonic-gate 	ANSI(0x079, 0,		"fill",			fc_fill);
25957c478bd9Sstevel@tonic-gate 	ANSI(0x07a, 0,		"comp",			fc_comp);
25967c478bd9Sstevel@tonic-gate 	ANSI(0x07b, 0,		"noop",			noop);
25977c478bd9Sstevel@tonic-gate 	ANSI(0x07c, 0,		"lwsplit",		lwsplit);
25987c478bd9Sstevel@tonic-gate 	ANSI(0x07d, 0,		"wljoin",		wljoin);
25997c478bd9Sstevel@tonic-gate 	ANSI(0x07e, 0,		"lbsplit",		lbsplit);
26007c478bd9Sstevel@tonic-gate 	ANSI(0x07f, 0,		"bljoin",		bljoin);
26017c478bd9Sstevel@tonic-gate 	ANSI(0x080, 0,		"wbflip",		wbflip);
26027c478bd9Sstevel@tonic-gate 	ANSI(0x081, 0,		"upc",			upper_case);
26037c478bd9Sstevel@tonic-gate 	ANSI(0x082, 0,		"lcc",			lower_case);
26047c478bd9Sstevel@tonic-gate 	ANSI(0x083, 0,		"pack",			pack_str);
26057c478bd9Sstevel@tonic-gate 	ANSI(0x084, 0,		"count",		count_str);
26067c478bd9Sstevel@tonic-gate 	ANSI(0x085, 0,		"body>",		to_acf);
26077c478bd9Sstevel@tonic-gate 	ANSI(0x086, 0,		">body",		to_body);
26087c478bd9Sstevel@tonic-gate 
26097c478bd9Sstevel@tonic-gate 	ANSI(0x089, 0,		"unloop",		unloop);
26107c478bd9Sstevel@tonic-gate 
26117c478bd9Sstevel@tonic-gate 	ANSI(0x09f, 0,		".s",			dot_s);
26127c478bd9Sstevel@tonic-gate 	ANSI(0x0a0, 0,		"base",			base);
26137c478bd9Sstevel@tonic-gate 	FCODE(0x0a1, 0,		"convert",		fc_historical);
26147c478bd9Sstevel@tonic-gate 	ANSI(0x0a2, 0,		"$number",		dollar_number);
26157c478bd9Sstevel@tonic-gate 	ANSI(0x0a3, 0,		"digit",		digit);
26167c478bd9Sstevel@tonic-gate 
26177c478bd9Sstevel@tonic-gate 	ANSI(0x0a9, 0,		"bl",			space);
26187c478bd9Sstevel@tonic-gate 	ANSI(0x0aa, 0,		"bs",			backspace);
26197c478bd9Sstevel@tonic-gate 	ANSI(0x0ab, 0,		"bell",			bell);
26207c478bd9Sstevel@tonic-gate 	ANSI(0x0ac, 0,		"bounds",		fc_bounds);
26217c478bd9Sstevel@tonic-gate 	ANSI(0x0ad, 0,		"here",			here);
26227c478bd9Sstevel@tonic-gate 
26237c478bd9Sstevel@tonic-gate 	ANSI(0x0af, 0,		"wbsplit",		wbsplit);
26247c478bd9Sstevel@tonic-gate 	ANSI(0x0b0, 0,		"bwjoin",		bwjoin);
26257c478bd9Sstevel@tonic-gate 
26267c478bd9Sstevel@tonic-gate 	P1275(0x0cb, 0,		"$find",		dollar_find);
26277c478bd9Sstevel@tonic-gate 
26287c478bd9Sstevel@tonic-gate 	ANSI(0x0d0, 0,		"c,",			ccomma);
26297c478bd9Sstevel@tonic-gate 	ANSI(0x0d1, 0,		"w,",			wcomma);
26307c478bd9Sstevel@tonic-gate 	ANSI(0x0d2, 0,		"l,",			lcomma);
26317c478bd9Sstevel@tonic-gate 	ANSI(0x0d3, 0,		",",			comma);
26327c478bd9Sstevel@tonic-gate 	ANSI(0x0d4, 0,		"um*",			um_multiply);
26337c478bd9Sstevel@tonic-gate 	ANSI(0x0d5, 0,		"um/mod",		um_slash_mod);
26347c478bd9Sstevel@tonic-gate 
26357c478bd9Sstevel@tonic-gate 	ANSI(0x0d8, 0,		"d+",			d_plus);
26367c478bd9Sstevel@tonic-gate 	ANSI(0x0d9, 0,		"d-",			d_minus);
26377c478bd9Sstevel@tonic-gate 
26387c478bd9Sstevel@tonic-gate 	ANSI(0x0dc, 0,		"state",		state);
26397c478bd9Sstevel@tonic-gate 	ANSI(0x0de, 0,		"behavior",		behavior);
26407c478bd9Sstevel@tonic-gate 	ANSI(0x0dd, 0,		"compile,",		compile_comma);
26417c478bd9Sstevel@tonic-gate 
26427c478bd9Sstevel@tonic-gate 	ANSI(0x216, 0,		"abort",		f_abort);
26437c478bd9Sstevel@tonic-gate 	ANSI(0x217, 0,		"catch",		catch);
26447c478bd9Sstevel@tonic-gate 	ANSI(0x218, 0,		"throw",		throw);
26457c478bd9Sstevel@tonic-gate 
26467c478bd9Sstevel@tonic-gate 	ANSI(0x226, 0,		"lwflip",		lwflip);
26477c478bd9Sstevel@tonic-gate 	ANSI(0x227, 0,		"lbflip",		lbflip);
26487c478bd9Sstevel@tonic-gate 	ANSI(0x228, 0,		"lbflips",		lbflips);
26497c478bd9Sstevel@tonic-gate 
26507c478bd9Sstevel@tonic-gate 	ANSI(0x236, 0,		"wbflips",		wbflips);
26517c478bd9Sstevel@tonic-gate 	ANSI(0x237, 0,		"lwflips",		lwflips);
26527c478bd9Sstevel@tonic-gate 
26537c478bd9Sstevel@tonic-gate 	FORTH(0,		"forth",		do_forth);
26547c478bd9Sstevel@tonic-gate 	FORTH(0,		"current",		do_current);
26557c478bd9Sstevel@tonic-gate 	FORTH(0,		"context",		do_context);
26567c478bd9Sstevel@tonic-gate 	FORTH(0,		"definitions",		do_definitions);
26577c478bd9Sstevel@tonic-gate 	FORTH(0,		"vocabulary",		do_vocab);
26587c478bd9Sstevel@tonic-gate 	FORTH(IMMEDIATE,	":",			colon);
26597c478bd9Sstevel@tonic-gate 	FORTH(IMMEDIATE,	";",			semi);
26607c478bd9Sstevel@tonic-gate 	FORTH(IMMEDIATE,	"create",		create);
26617c478bd9Sstevel@tonic-gate 	FORTH(IMMEDIATE,	"does>",		does);
26627c478bd9Sstevel@tonic-gate 	FORTH(IMMEDIATE,	"recursive",		recursive);
26637c478bd9Sstevel@tonic-gate 	FORTH(0,		"parse-word",		parse_word);
26647c478bd9Sstevel@tonic-gate 	FORTH(IMMEDIATE,	"\"",			run_quote);
26657c478bd9Sstevel@tonic-gate 	FORTH(IMMEDIATE,	"order",		do_order);
26667c478bd9Sstevel@tonic-gate 	FORTH(IMMEDIATE,	"also",			do_also);
26677c478bd9Sstevel@tonic-gate 	FORTH(IMMEDIATE,	"previous",		do_previous);
26687c478bd9Sstevel@tonic-gate 	FORTH(IMMEDIATE,	"'",			do_tick);
26697c478bd9Sstevel@tonic-gate 	FORTH(IMMEDIATE,	"[']",			bracket_tick);
26707c478bd9Sstevel@tonic-gate 	FORTH(0,		"unaligned-l@",		unaligned_lfetch);
26717c478bd9Sstevel@tonic-gate 	FORTH(0,		"unaligned-l!",		unaligned_lstore);
26727c478bd9Sstevel@tonic-gate 	FORTH(0,		"unaligned-w@",		unaligned_wfetch);
26737c478bd9Sstevel@tonic-gate 	FORTH(0,		"unaligned-w!",		unaligned_wstore);
26747c478bd9Sstevel@tonic-gate }
2675