1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate *
4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate * with the License.
8*7c478bd9Sstevel@tonic-gate *
9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate *
14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate *
20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate * Copyright (c) 2000 by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate * All rights reserved.
25*7c478bd9Sstevel@tonic-gate */
26*7c478bd9Sstevel@tonic-gate
27*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
28*7c478bd9Sstevel@tonic-gate
29*7c478bd9Sstevel@tonic-gate #include <stdio.h>
30*7c478bd9Sstevel@tonic-gate #include <stdlib.h>
31*7c478bd9Sstevel@tonic-gate #include <string.h>
32*7c478bd9Sstevel@tonic-gate #include <fcode/private.h>
33*7c478bd9Sstevel@tonic-gate #include <fcdriver/fcdriver.h>
34*7c478bd9Sstevel@tonic-gate
35*7c478bd9Sstevel@tonic-gate #define LF_PER_XF (sizeof (xforth_t)/sizeof (lforth_t))
36*7c478bd9Sstevel@tonic-gate #define WF_PER_XF (sizeof (xforth_t)/sizeof (wforth_t))
37*7c478bd9Sstevel@tonic-gate
38*7c478bd9Sstevel@tonic-gate void unaligned_xfetch(fcode_env_t *);
39*7c478bd9Sstevel@tonic-gate void unaligned_xstore(fcode_env_t *);
40*7c478bd9Sstevel@tonic-gate static void xbsplit(fcode_env_t *);
41*7c478bd9Sstevel@tonic-gate
42*7c478bd9Sstevel@tonic-gate xforth_t
pop_xforth(fcode_env_t * env)43*7c478bd9Sstevel@tonic-gate pop_xforth(fcode_env_t *env)
44*7c478bd9Sstevel@tonic-gate {
45*7c478bd9Sstevel@tonic-gate if (sizeof (xforth_t) == sizeof (fstack_t))
46*7c478bd9Sstevel@tonic-gate return (POP(DS));
47*7c478bd9Sstevel@tonic-gate return ((xforth_t)pop_double(env));
48*7c478bd9Sstevel@tonic-gate }
49*7c478bd9Sstevel@tonic-gate
50*7c478bd9Sstevel@tonic-gate xforth_t
peek_xforth(fcode_env_t * env)51*7c478bd9Sstevel@tonic-gate peek_xforth(fcode_env_t *env)
52*7c478bd9Sstevel@tonic-gate {
53*7c478bd9Sstevel@tonic-gate xforth_t d;
54*7c478bd9Sstevel@tonic-gate
55*7c478bd9Sstevel@tonic-gate d = pop_xforth(env);
56*7c478bd9Sstevel@tonic-gate push_xforth(env, d);
57*7c478bd9Sstevel@tonic-gate return (d);
58*7c478bd9Sstevel@tonic-gate }
59*7c478bd9Sstevel@tonic-gate
60*7c478bd9Sstevel@tonic-gate void
push_xforth(fcode_env_t * env,xforth_t a)61*7c478bd9Sstevel@tonic-gate push_xforth(fcode_env_t *env, xforth_t a)
62*7c478bd9Sstevel@tonic-gate {
63*7c478bd9Sstevel@tonic-gate if (sizeof (xforth_t) == sizeof (fstack_t))
64*7c478bd9Sstevel@tonic-gate PUSH(DS, a);
65*7c478bd9Sstevel@tonic-gate else
66*7c478bd9Sstevel@tonic-gate push_double(env, (dforth_t)a);
67*7c478bd9Sstevel@tonic-gate }
68*7c478bd9Sstevel@tonic-gate
69*7c478bd9Sstevel@tonic-gate /*
70*7c478bd9Sstevel@tonic-gate * bxjoin ( b.lo b.2 b.3 b.4 b.5 b.6 b.7 b.hi -- o )
71*7c478bd9Sstevel@tonic-gate */
72*7c478bd9Sstevel@tonic-gate static void
bxjoin(fcode_env_t * env)73*7c478bd9Sstevel@tonic-gate bxjoin(fcode_env_t *env)
74*7c478bd9Sstevel@tonic-gate {
75*7c478bd9Sstevel@tonic-gate union {
76*7c478bd9Sstevel@tonic-gate uchar_t b_bytes[sizeof (xforth_t)];
77*7c478bd9Sstevel@tonic-gate xforth_t b_xf;
78*7c478bd9Sstevel@tonic-gate } b;
79*7c478bd9Sstevel@tonic-gate int i;
80*7c478bd9Sstevel@tonic-gate
81*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, sizeof (xforth_t), "bxjoin");
82*7c478bd9Sstevel@tonic-gate for (i = 0; i < sizeof (xforth_t); i++)
83*7c478bd9Sstevel@tonic-gate b.b_bytes[i] = POP(DS);
84*7c478bd9Sstevel@tonic-gate push_xforth(env, b.b_xf);
85*7c478bd9Sstevel@tonic-gate }
86*7c478bd9Sstevel@tonic-gate
87*7c478bd9Sstevel@tonic-gate /*
88*7c478bd9Sstevel@tonic-gate * <l@ ( qaddr -- n )
89*7c478bd9Sstevel@tonic-gate */
90*7c478bd9Sstevel@tonic-gate static void
lsfetch(fcode_env_t * env)91*7c478bd9Sstevel@tonic-gate lsfetch(fcode_env_t *env)
92*7c478bd9Sstevel@tonic-gate {
93*7c478bd9Sstevel@tonic-gate s_lforth_t *addr;
94*7c478bd9Sstevel@tonic-gate xforth_t a;
95*7c478bd9Sstevel@tonic-gate
96*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 1, "<l@");
97*7c478bd9Sstevel@tonic-gate addr = (s_lforth_t *)POP(DS);
98*7c478bd9Sstevel@tonic-gate a = *addr;
99*7c478bd9Sstevel@tonic-gate push_xforth(env, a);
100*7c478bd9Sstevel@tonic-gate }
101*7c478bd9Sstevel@tonic-gate
102*7c478bd9Sstevel@tonic-gate /*
103*7c478bd9Sstevel@tonic-gate * lxjoin ( quad.lo quad.hi -- o )
104*7c478bd9Sstevel@tonic-gate */
105*7c478bd9Sstevel@tonic-gate static void
lxjoin(fcode_env_t * env)106*7c478bd9Sstevel@tonic-gate lxjoin(fcode_env_t *env)
107*7c478bd9Sstevel@tonic-gate {
108*7c478bd9Sstevel@tonic-gate union {
109*7c478bd9Sstevel@tonic-gate lforth_t b_lf[LF_PER_XF];
110*7c478bd9Sstevel@tonic-gate xforth_t b_xf;
111*7c478bd9Sstevel@tonic-gate } b;
112*7c478bd9Sstevel@tonic-gate int i;
113*7c478bd9Sstevel@tonic-gate
114*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, LF_PER_XF, "lxjoin");
115*7c478bd9Sstevel@tonic-gate for (i = 0; i < LF_PER_XF; i++)
116*7c478bd9Sstevel@tonic-gate b.b_lf[i] = POP(DS);
117*7c478bd9Sstevel@tonic-gate push_xforth(env, b.b_xf);
118*7c478bd9Sstevel@tonic-gate }
119*7c478bd9Sstevel@tonic-gate
120*7c478bd9Sstevel@tonic-gate /*
121*7c478bd9Sstevel@tonic-gate * wxjoin ( w.lo w.2 w.3 w.hi -- o )
122*7c478bd9Sstevel@tonic-gate */
123*7c478bd9Sstevel@tonic-gate static void
wxjoin(fcode_env_t * env)124*7c478bd9Sstevel@tonic-gate wxjoin(fcode_env_t *env)
125*7c478bd9Sstevel@tonic-gate {
126*7c478bd9Sstevel@tonic-gate union {
127*7c478bd9Sstevel@tonic-gate wforth_t b_wf[WF_PER_XF];
128*7c478bd9Sstevel@tonic-gate xforth_t b_xf;
129*7c478bd9Sstevel@tonic-gate } b;
130*7c478bd9Sstevel@tonic-gate int i;
131*7c478bd9Sstevel@tonic-gate
132*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, WF_PER_XF, "wxjoin");
133*7c478bd9Sstevel@tonic-gate for (i = 0; i < WF_PER_XF; i++)
134*7c478bd9Sstevel@tonic-gate b.b_wf[i] = POP(DS);
135*7c478bd9Sstevel@tonic-gate push_xforth(env, b.b_xf);
136*7c478bd9Sstevel@tonic-gate }
137*7c478bd9Sstevel@tonic-gate
138*7c478bd9Sstevel@tonic-gate /*
139*7c478bd9Sstevel@tonic-gate * x, ( o -- )
140*7c478bd9Sstevel@tonic-gate */
141*7c478bd9Sstevel@tonic-gate static void
xcomma(fcode_env_t * env)142*7c478bd9Sstevel@tonic-gate xcomma(fcode_env_t *env)
143*7c478bd9Sstevel@tonic-gate {
144*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 1, "x,");
145*7c478bd9Sstevel@tonic-gate DEBUGF(COMMA, dump_comma(env, "x,"));
146*7c478bd9Sstevel@tonic-gate PUSH(DS, (fstack_t)HERE);
147*7c478bd9Sstevel@tonic-gate unaligned_xstore(env);
148*7c478bd9Sstevel@tonic-gate set_here(env, HERE + sizeof (xforth_t), "xcomma");
149*7c478bd9Sstevel@tonic-gate }
150*7c478bd9Sstevel@tonic-gate
151*7c478bd9Sstevel@tonic-gate /*
152*7c478bd9Sstevel@tonic-gate * x@ ( xaddr -- o )
153*7c478bd9Sstevel@tonic-gate */
154*7c478bd9Sstevel@tonic-gate void
xfetch(fcode_env_t * env)155*7c478bd9Sstevel@tonic-gate xfetch(fcode_env_t *env)
156*7c478bd9Sstevel@tonic-gate {
157*7c478bd9Sstevel@tonic-gate xforth_t *addr;
158*7c478bd9Sstevel@tonic-gate xforth_t a;
159*7c478bd9Sstevel@tonic-gate
160*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 1, "x@");
161*7c478bd9Sstevel@tonic-gate addr = (xforth_t *)POP(DS);
162*7c478bd9Sstevel@tonic-gate a = *addr;
163*7c478bd9Sstevel@tonic-gate push_xforth(env, a);
164*7c478bd9Sstevel@tonic-gate }
165*7c478bd9Sstevel@tonic-gate
166*7c478bd9Sstevel@tonic-gate /*
167*7c478bd9Sstevel@tonic-gate * x! ( o xaddr -- )
168*7c478bd9Sstevel@tonic-gate */
169*7c478bd9Sstevel@tonic-gate void
xstore(fcode_env_t * env)170*7c478bd9Sstevel@tonic-gate xstore(fcode_env_t *env)
171*7c478bd9Sstevel@tonic-gate {
172*7c478bd9Sstevel@tonic-gate xforth_t *addr;
173*7c478bd9Sstevel@tonic-gate xforth_t a;
174*7c478bd9Sstevel@tonic-gate
175*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 2, "x!");
176*7c478bd9Sstevel@tonic-gate addr = (xforth_t *)POP(DS);
177*7c478bd9Sstevel@tonic-gate a = pop_xforth(env);
178*7c478bd9Sstevel@tonic-gate *addr = a;
179*7c478bd9Sstevel@tonic-gate }
180*7c478bd9Sstevel@tonic-gate
181*7c478bd9Sstevel@tonic-gate /*
182*7c478bd9Sstevel@tonic-gate * /x ( -- n )
183*7c478bd9Sstevel@tonic-gate */
184*7c478bd9Sstevel@tonic-gate static void
slash_x(fcode_env_t * env)185*7c478bd9Sstevel@tonic-gate slash_x(fcode_env_t *env)
186*7c478bd9Sstevel@tonic-gate {
187*7c478bd9Sstevel@tonic-gate PUSH(DS, sizeof (xforth_t));
188*7c478bd9Sstevel@tonic-gate }
189*7c478bd9Sstevel@tonic-gate
190*7c478bd9Sstevel@tonic-gate /*
191*7c478bd9Sstevel@tonic-gate * /x* ( nu1 -- nu2 )
192*7c478bd9Sstevel@tonic-gate */
193*7c478bd9Sstevel@tonic-gate static void
slash_x_times(fcode_env_t * env)194*7c478bd9Sstevel@tonic-gate slash_x_times(fcode_env_t *env)
195*7c478bd9Sstevel@tonic-gate {
196*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 1, "/x*");
197*7c478bd9Sstevel@tonic-gate TOS *= sizeof (xforth_t);
198*7c478bd9Sstevel@tonic-gate }
199*7c478bd9Sstevel@tonic-gate
200*7c478bd9Sstevel@tonic-gate /*
201*7c478bd9Sstevel@tonic-gate * xa+ ( addr1 index -- addr2 )
202*7c478bd9Sstevel@tonic-gate */
203*7c478bd9Sstevel@tonic-gate static void
xa_plus(fcode_env_t * env)204*7c478bd9Sstevel@tonic-gate xa_plus(fcode_env_t *env)
205*7c478bd9Sstevel@tonic-gate {
206*7c478bd9Sstevel@tonic-gate fstack_t index;
207*7c478bd9Sstevel@tonic-gate
208*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 2, "xa+");
209*7c478bd9Sstevel@tonic-gate index = POP(DS);
210*7c478bd9Sstevel@tonic-gate TOS += index * sizeof (xforth_t);
211*7c478bd9Sstevel@tonic-gate }
212*7c478bd9Sstevel@tonic-gate
213*7c478bd9Sstevel@tonic-gate /*
214*7c478bd9Sstevel@tonic-gate * xa1+ ( addr1 -- addr2 )
215*7c478bd9Sstevel@tonic-gate */
216*7c478bd9Sstevel@tonic-gate static void
xa_one_plus(fcode_env_t * env)217*7c478bd9Sstevel@tonic-gate xa_one_plus(fcode_env_t *env)
218*7c478bd9Sstevel@tonic-gate {
219*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 1, "xa1+");
220*7c478bd9Sstevel@tonic-gate TOS += sizeof (xforth_t);
221*7c478bd9Sstevel@tonic-gate }
222*7c478bd9Sstevel@tonic-gate
223*7c478bd9Sstevel@tonic-gate /*
224*7c478bd9Sstevel@tonic-gate * xbflip ( oct1 -- oct2 )
225*7c478bd9Sstevel@tonic-gate */
226*7c478bd9Sstevel@tonic-gate void
xbflip(fcode_env_t * env)227*7c478bd9Sstevel@tonic-gate xbflip(fcode_env_t *env)
228*7c478bd9Sstevel@tonic-gate {
229*7c478bd9Sstevel@tonic-gate union {
230*7c478bd9Sstevel@tonic-gate uchar_t b_bytes[sizeof (xforth_t)];
231*7c478bd9Sstevel@tonic-gate xforth_t b_xf;
232*7c478bd9Sstevel@tonic-gate } b, c;
233*7c478bd9Sstevel@tonic-gate int i;
234*7c478bd9Sstevel@tonic-gate
235*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 1, "xbflip");
236*7c478bd9Sstevel@tonic-gate b.b_xf = pop_xforth(env);
237*7c478bd9Sstevel@tonic-gate for (i = 0; i < sizeof (xforth_t); i++)
238*7c478bd9Sstevel@tonic-gate c.b_bytes[i] = b.b_bytes[(sizeof (xforth_t) - 1) - i];
239*7c478bd9Sstevel@tonic-gate push_xforth(env, c.b_xf);
240*7c478bd9Sstevel@tonic-gate }
241*7c478bd9Sstevel@tonic-gate
242*7c478bd9Sstevel@tonic-gate void
unaligned_xfetch(fcode_env_t * env)243*7c478bd9Sstevel@tonic-gate unaligned_xfetch(fcode_env_t *env)
244*7c478bd9Sstevel@tonic-gate {
245*7c478bd9Sstevel@tonic-gate fstack_t addr;
246*7c478bd9Sstevel@tonic-gate int i;
247*7c478bd9Sstevel@tonic-gate
248*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 1, "unaligned-x@");
249*7c478bd9Sstevel@tonic-gate addr = POP(DS);
250*7c478bd9Sstevel@tonic-gate for (i = 0; i < sizeof (xforth_t); i++, addr++) {
251*7c478bd9Sstevel@tonic-gate PUSH(DS, addr);
252*7c478bd9Sstevel@tonic-gate cfetch(env);
253*7c478bd9Sstevel@tonic-gate }
254*7c478bd9Sstevel@tonic-gate bxjoin(env);
255*7c478bd9Sstevel@tonic-gate xbflip(env);
256*7c478bd9Sstevel@tonic-gate }
257*7c478bd9Sstevel@tonic-gate
258*7c478bd9Sstevel@tonic-gate void
unaligned_xstore(fcode_env_t * env)259*7c478bd9Sstevel@tonic-gate unaligned_xstore(fcode_env_t *env)
260*7c478bd9Sstevel@tonic-gate {
261*7c478bd9Sstevel@tonic-gate fstack_t addr;
262*7c478bd9Sstevel@tonic-gate int i;
263*7c478bd9Sstevel@tonic-gate
264*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 2, "unaligned-x!");
265*7c478bd9Sstevel@tonic-gate addr = POP(DS);
266*7c478bd9Sstevel@tonic-gate xbsplit(env);
267*7c478bd9Sstevel@tonic-gate for (i = 0; i < sizeof (xforth_t); i++, addr++) {
268*7c478bd9Sstevel@tonic-gate PUSH(DS, addr);
269*7c478bd9Sstevel@tonic-gate cstore(env);
270*7c478bd9Sstevel@tonic-gate }
271*7c478bd9Sstevel@tonic-gate }
272*7c478bd9Sstevel@tonic-gate
273*7c478bd9Sstevel@tonic-gate /*
274*7c478bd9Sstevel@tonic-gate * xbflips ( xaddr len -- )
275*7c478bd9Sstevel@tonic-gate */
276*7c478bd9Sstevel@tonic-gate static void
xbflips(fcode_env_t * env)277*7c478bd9Sstevel@tonic-gate xbflips(fcode_env_t *env)
278*7c478bd9Sstevel@tonic-gate {
279*7c478bd9Sstevel@tonic-gate fstack_t len, addr;
280*7c478bd9Sstevel@tonic-gate int i;
281*7c478bd9Sstevel@tonic-gate
282*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 2, "xbflips");
283*7c478bd9Sstevel@tonic-gate len = POP(DS);
284*7c478bd9Sstevel@tonic-gate addr = POP(DS);
285*7c478bd9Sstevel@tonic-gate for (i = 0; i < len; i += sizeof (xforth_t),
286*7c478bd9Sstevel@tonic-gate addr += sizeof (xforth_t)) {
287*7c478bd9Sstevel@tonic-gate PUSH(DS, addr);
288*7c478bd9Sstevel@tonic-gate unaligned_xfetch(env);
289*7c478bd9Sstevel@tonic-gate xbflip(env);
290*7c478bd9Sstevel@tonic-gate PUSH(DS, addr);
291*7c478bd9Sstevel@tonic-gate unaligned_xstore(env);
292*7c478bd9Sstevel@tonic-gate }
293*7c478bd9Sstevel@tonic-gate }
294*7c478bd9Sstevel@tonic-gate
295*7c478bd9Sstevel@tonic-gate /*
296*7c478bd9Sstevel@tonic-gate * xbsplit ( o -- b.lo b.2 b.3 b.4 b.5 b.6 b.7 b.hi )
297*7c478bd9Sstevel@tonic-gate */
298*7c478bd9Sstevel@tonic-gate static void
xbsplit(fcode_env_t * env)299*7c478bd9Sstevel@tonic-gate xbsplit(fcode_env_t *env)
300*7c478bd9Sstevel@tonic-gate {
301*7c478bd9Sstevel@tonic-gate union {
302*7c478bd9Sstevel@tonic-gate uchar_t b_bytes[sizeof (xforth_t)];
303*7c478bd9Sstevel@tonic-gate xforth_t b_xf;
304*7c478bd9Sstevel@tonic-gate } b;
305*7c478bd9Sstevel@tonic-gate int i;
306*7c478bd9Sstevel@tonic-gate
307*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 1, "xbsplit");
308*7c478bd9Sstevel@tonic-gate b.b_xf = pop_xforth(env);
309*7c478bd9Sstevel@tonic-gate for (i = 0; i < sizeof (xforth_t); i++)
310*7c478bd9Sstevel@tonic-gate PUSH(DS, b.b_bytes[(sizeof (xforth_t) - 1) - i]);
311*7c478bd9Sstevel@tonic-gate }
312*7c478bd9Sstevel@tonic-gate
313*7c478bd9Sstevel@tonic-gate /*
314*7c478bd9Sstevel@tonic-gate * xlflip ( oct1 -- oct2 )
315*7c478bd9Sstevel@tonic-gate */
316*7c478bd9Sstevel@tonic-gate void
xlflip(fcode_env_t * env)317*7c478bd9Sstevel@tonic-gate xlflip(fcode_env_t *env)
318*7c478bd9Sstevel@tonic-gate {
319*7c478bd9Sstevel@tonic-gate union {
320*7c478bd9Sstevel@tonic-gate lforth_t b_lf[LF_PER_XF];
321*7c478bd9Sstevel@tonic-gate xforth_t b_xf;
322*7c478bd9Sstevel@tonic-gate } b, c;
323*7c478bd9Sstevel@tonic-gate int i;
324*7c478bd9Sstevel@tonic-gate
325*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 1, "xlflip");
326*7c478bd9Sstevel@tonic-gate b.b_xf = pop_xforth(env);
327*7c478bd9Sstevel@tonic-gate for (i = 0; i < LF_PER_XF; i++)
328*7c478bd9Sstevel@tonic-gate c.b_lf[i] = b.b_lf[(LF_PER_XF - 1) - i];
329*7c478bd9Sstevel@tonic-gate push_xforth(env, c.b_xf);
330*7c478bd9Sstevel@tonic-gate }
331*7c478bd9Sstevel@tonic-gate
332*7c478bd9Sstevel@tonic-gate /*
333*7c478bd9Sstevel@tonic-gate * xlflips ( xaddr len -- )
334*7c478bd9Sstevel@tonic-gate */
335*7c478bd9Sstevel@tonic-gate static void
xlflips(fcode_env_t * env)336*7c478bd9Sstevel@tonic-gate xlflips(fcode_env_t *env)
337*7c478bd9Sstevel@tonic-gate {
338*7c478bd9Sstevel@tonic-gate fstack_t len, addr;
339*7c478bd9Sstevel@tonic-gate int i;
340*7c478bd9Sstevel@tonic-gate
341*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 2, "xlflips");
342*7c478bd9Sstevel@tonic-gate len = POP(DS);
343*7c478bd9Sstevel@tonic-gate addr = POP(DS);
344*7c478bd9Sstevel@tonic-gate for (i = 0; i < len; i += sizeof (xforth_t),
345*7c478bd9Sstevel@tonic-gate addr += sizeof (xforth_t)) {
346*7c478bd9Sstevel@tonic-gate PUSH(DS, addr);
347*7c478bd9Sstevel@tonic-gate unaligned_xfetch(env);
348*7c478bd9Sstevel@tonic-gate xlflip(env);
349*7c478bd9Sstevel@tonic-gate PUSH(DS, addr);
350*7c478bd9Sstevel@tonic-gate unaligned_xstore(env);
351*7c478bd9Sstevel@tonic-gate }
352*7c478bd9Sstevel@tonic-gate }
353*7c478bd9Sstevel@tonic-gate
354*7c478bd9Sstevel@tonic-gate /*
355*7c478bd9Sstevel@tonic-gate * xlsplit ( o -- quad.lo quad.hi )
356*7c478bd9Sstevel@tonic-gate */
357*7c478bd9Sstevel@tonic-gate static void
xlsplit(fcode_env_t * env)358*7c478bd9Sstevel@tonic-gate xlsplit(fcode_env_t *env)
359*7c478bd9Sstevel@tonic-gate {
360*7c478bd9Sstevel@tonic-gate union {
361*7c478bd9Sstevel@tonic-gate lforth_t b_lf[LF_PER_XF];
362*7c478bd9Sstevel@tonic-gate xforth_t b_xf;
363*7c478bd9Sstevel@tonic-gate } b;
364*7c478bd9Sstevel@tonic-gate int i;
365*7c478bd9Sstevel@tonic-gate
366*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 1, "xlsplit");
367*7c478bd9Sstevel@tonic-gate b.b_xf = pop_xforth(env);
368*7c478bd9Sstevel@tonic-gate for (i = 0; i < LF_PER_XF; i++)
369*7c478bd9Sstevel@tonic-gate PUSH(DS, b.b_lf[(LF_PER_XF - 1) - i]);
370*7c478bd9Sstevel@tonic-gate }
371*7c478bd9Sstevel@tonic-gate
372*7c478bd9Sstevel@tonic-gate
373*7c478bd9Sstevel@tonic-gate /*
374*7c478bd9Sstevel@tonic-gate * xwflip ( oct1 -- oct2 )
375*7c478bd9Sstevel@tonic-gate */
376*7c478bd9Sstevel@tonic-gate static void
xwflip(fcode_env_t * env)377*7c478bd9Sstevel@tonic-gate xwflip(fcode_env_t *env)
378*7c478bd9Sstevel@tonic-gate {
379*7c478bd9Sstevel@tonic-gate union {
380*7c478bd9Sstevel@tonic-gate wforth_t b_wf[WF_PER_XF];
381*7c478bd9Sstevel@tonic-gate xforth_t b_xf;
382*7c478bd9Sstevel@tonic-gate } b, c;
383*7c478bd9Sstevel@tonic-gate int i;
384*7c478bd9Sstevel@tonic-gate
385*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 1, "xwflip");
386*7c478bd9Sstevel@tonic-gate b.b_xf = pop_xforth(env);
387*7c478bd9Sstevel@tonic-gate for (i = 0; i < WF_PER_XF; i++)
388*7c478bd9Sstevel@tonic-gate c.b_wf[i] = b.b_wf[(WF_PER_XF - 1) - i];
389*7c478bd9Sstevel@tonic-gate push_xforth(env, c.b_xf);
390*7c478bd9Sstevel@tonic-gate }
391*7c478bd9Sstevel@tonic-gate
392*7c478bd9Sstevel@tonic-gate /*
393*7c478bd9Sstevel@tonic-gate * xwflips ( xaddr len -- )
394*7c478bd9Sstevel@tonic-gate */
395*7c478bd9Sstevel@tonic-gate static void
xwflips(fcode_env_t * env)396*7c478bd9Sstevel@tonic-gate xwflips(fcode_env_t *env)
397*7c478bd9Sstevel@tonic-gate {
398*7c478bd9Sstevel@tonic-gate fstack_t len, addr;
399*7c478bd9Sstevel@tonic-gate int i;
400*7c478bd9Sstevel@tonic-gate
401*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 2, "xwflips");
402*7c478bd9Sstevel@tonic-gate len = POP(DS);
403*7c478bd9Sstevel@tonic-gate addr = POP(DS);
404*7c478bd9Sstevel@tonic-gate for (i = 0; i < len; i += sizeof (xforth_t),
405*7c478bd9Sstevel@tonic-gate addr += sizeof (xforth_t)) {
406*7c478bd9Sstevel@tonic-gate PUSH(DS, addr);
407*7c478bd9Sstevel@tonic-gate unaligned_xfetch(env);
408*7c478bd9Sstevel@tonic-gate xwflip(env);
409*7c478bd9Sstevel@tonic-gate PUSH(DS, addr);
410*7c478bd9Sstevel@tonic-gate unaligned_xstore(env);
411*7c478bd9Sstevel@tonic-gate }
412*7c478bd9Sstevel@tonic-gate }
413*7c478bd9Sstevel@tonic-gate
414*7c478bd9Sstevel@tonic-gate /*
415*7c478bd9Sstevel@tonic-gate * xwsplit ( o -- w.lo w.2 w.3 w.hi )
416*7c478bd9Sstevel@tonic-gate */
417*7c478bd9Sstevel@tonic-gate static void
xwsplit(fcode_env_t * env)418*7c478bd9Sstevel@tonic-gate xwsplit(fcode_env_t *env)
419*7c478bd9Sstevel@tonic-gate {
420*7c478bd9Sstevel@tonic-gate union {
421*7c478bd9Sstevel@tonic-gate wforth_t b_wf[WF_PER_XF];
422*7c478bd9Sstevel@tonic-gate xforth_t b_xf;
423*7c478bd9Sstevel@tonic-gate } b;
424*7c478bd9Sstevel@tonic-gate int i;
425*7c478bd9Sstevel@tonic-gate
426*7c478bd9Sstevel@tonic-gate CHECK_DEPTH(env, 1, "xwsplit");
427*7c478bd9Sstevel@tonic-gate b.b_xf = pop_xforth(env);
428*7c478bd9Sstevel@tonic-gate for (i = 0; i < WF_PER_XF; i++)
429*7c478bd9Sstevel@tonic-gate PUSH(DS, b.b_wf[(WF_PER_XF - 1) - i]);
430*7c478bd9Sstevel@tonic-gate }
431*7c478bd9Sstevel@tonic-gate
432*7c478bd9Sstevel@tonic-gate #pragma init(_init)
433*7c478bd9Sstevel@tonic-gate
434*7c478bd9Sstevel@tonic-gate static void
_init(void)435*7c478bd9Sstevel@tonic-gate _init(void)
436*7c478bd9Sstevel@tonic-gate {
437*7c478bd9Sstevel@tonic-gate fcode_env_t *env = initial_env;
438*7c478bd9Sstevel@tonic-gate
439*7c478bd9Sstevel@tonic-gate ASSERT(env);
440*7c478bd9Sstevel@tonic-gate NOTICE;
441*7c478bd9Sstevel@tonic-gate P1275(0x241, 0, "bxjoin", bxjoin);
442*7c478bd9Sstevel@tonic-gate P1275(0x242, 0, "<l@", lsfetch);
443*7c478bd9Sstevel@tonic-gate P1275(0x243, 0, "lxjoin", lxjoin);
444*7c478bd9Sstevel@tonic-gate P1275(0x244, 0, "wxjoin", wxjoin);
445*7c478bd9Sstevel@tonic-gate P1275(0x245, 0, "x,", xcomma);
446*7c478bd9Sstevel@tonic-gate P1275(0x246, 0, "x@", xfetch);
447*7c478bd9Sstevel@tonic-gate P1275(0x247, 0, "x!", xstore);
448*7c478bd9Sstevel@tonic-gate P1275(0x248, 0, "/x", slash_x);
449*7c478bd9Sstevel@tonic-gate P1275(0x249, 0, "/x*", slash_x_times);
450*7c478bd9Sstevel@tonic-gate P1275(0x24a, 0, "xa+", xa_plus);
451*7c478bd9Sstevel@tonic-gate P1275(0x24b, 0, "xa1+", xa_one_plus);
452*7c478bd9Sstevel@tonic-gate P1275(0x24c, 0, "xbflip", xbflip);
453*7c478bd9Sstevel@tonic-gate P1275(0x24d, 0, "xbflips", xbflips);
454*7c478bd9Sstevel@tonic-gate P1275(0x24e, 0, "xbsplit", xbsplit);
455*7c478bd9Sstevel@tonic-gate P1275(0x24f, 0, "xlflip", xlflip);
456*7c478bd9Sstevel@tonic-gate P1275(0x250, 0, "xlflips", xlflips);
457*7c478bd9Sstevel@tonic-gate P1275(0x251, 0, "xlsplit", xlsplit);
458*7c478bd9Sstevel@tonic-gate P1275(0x252, 0, "xwflip", xwflip);
459*7c478bd9Sstevel@tonic-gate P1275(0x253, 0, "xwflips", xwflips);
460*7c478bd9Sstevel@tonic-gate P1275(0x254, 0, "xwsplit", xwsplit);
461*7c478bd9Sstevel@tonic-gate
462*7c478bd9Sstevel@tonic-gate FORTH(0, "unaligned-x@", unaligned_xfetch);
463*7c478bd9Sstevel@tonic-gate FORTH(0, "unaligned-x!", unaligned_xstore);
464*7c478bd9Sstevel@tonic-gate }
465