4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 2000 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <fcode/private.h>
33 #include <fcdriver/fcdriver.h>
35 #define LF_PER_XF (sizeof (xforth_t)/sizeof (lforth_t))
36 #define WF_PER_XF (sizeof (xforth_t)/sizeof (wforth_t))
38 void unaligned_xfetch(fcode_env_t
*);
39 void unaligned_xstore(fcode_env_t
*);
40 static void xbsplit(fcode_env_t
*);
43 pop_xforth(fcode_env_t
*env
)
45 if (sizeof (xforth_t
) == sizeof (fstack_t
))
47 return ((xforth_t
)pop_double(env
));
51 peek_xforth(fcode_env_t
*env
)
61 push_xforth(fcode_env_t
*env
, xforth_t a
)
63 if (sizeof (xforth_t
) == sizeof (fstack_t
))
66 push_double(env
, (dforth_t
)a
);
70 * bxjoin ( b.lo b.2 b.3 b.4 b.5 b.6 b.7 b.hi -- o )
73 bxjoin(fcode_env_t
*env
)
76 uchar_t b_bytes
[sizeof (xforth_t
)];
81 CHECK_DEPTH(env
, sizeof (xforth_t
), "bxjoin");
82 for (i
= 0; i
< sizeof (xforth_t
); i
++)
83 b
.b_bytes
[i
] = POP(DS
);
84 push_xforth(env
, b
.b_xf
);
91 lsfetch(fcode_env_t
*env
)
96 CHECK_DEPTH(env
, 1, "<l@");
97 addr
= (s_lforth_t
*)POP(DS
);
103 * lxjoin ( quad.lo quad.hi -- o )
106 lxjoin(fcode_env_t
*env
)
109 lforth_t b_lf
[LF_PER_XF
];
114 CHECK_DEPTH(env
, LF_PER_XF
, "lxjoin");
115 for (i
= 0; i
< LF_PER_XF
; i
++)
117 push_xforth(env
, b
.b_xf
);
121 * wxjoin ( w.lo w.2 w.3 w.hi -- o )
124 wxjoin(fcode_env_t
*env
)
127 wforth_t b_wf
[WF_PER_XF
];
132 CHECK_DEPTH(env
, WF_PER_XF
, "wxjoin");
133 for (i
= 0; i
< WF_PER_XF
; i
++)
135 push_xforth(env
, b
.b_xf
);
142 xcomma(fcode_env_t
*env
)
144 CHECK_DEPTH(env
, 1, "x,");
145 DEBUGF(COMMA
, dump_comma(env
, "x,"));
146 PUSH(DS
, (fstack_t
)HERE
);
147 unaligned_xstore(env
);
148 set_here(env
, HERE
+ sizeof (xforth_t
), "xcomma");
155 xfetch(fcode_env_t
*env
)
160 CHECK_DEPTH(env
, 1, "x@");
161 addr
= (xforth_t
*)POP(DS
);
170 xstore(fcode_env_t
*env
)
175 CHECK_DEPTH(env
, 2, "x!");
176 addr
= (xforth_t
*)POP(DS
);
185 slash_x(fcode_env_t
*env
)
187 PUSH(DS
, sizeof (xforth_t
));
194 slash_x_times(fcode_env_t
*env
)
196 CHECK_DEPTH(env
, 1, "/x*");
197 TOS
*= sizeof (xforth_t
);
201 * xa+ ( addr1 index -- addr2 )
204 xa_plus(fcode_env_t
*env
)
208 CHECK_DEPTH(env
, 2, "xa+");
210 TOS
+= index
* sizeof (xforth_t
);
214 * xa1+ ( addr1 -- addr2 )
217 xa_one_plus(fcode_env_t
*env
)
219 CHECK_DEPTH(env
, 1, "xa1+");
220 TOS
+= sizeof (xforth_t
);
224 * xbflip ( oct1 -- oct2 )
227 xbflip(fcode_env_t
*env
)
230 uchar_t b_bytes
[sizeof (xforth_t
)];
235 CHECK_DEPTH(env
, 1, "xbflip");
236 b
.b_xf
= pop_xforth(env
);
237 for (i
= 0; i
< sizeof (xforth_t
); i
++)
238 c
.b_bytes
[i
] = b
.b_bytes
[(sizeof (xforth_t
) - 1) - i
];
239 push_xforth(env
, c
.b_xf
);
243 unaligned_xfetch(fcode_env_t
*env
)
248 CHECK_DEPTH(env
, 1, "unaligned-x@");
250 for (i
= 0; i
< sizeof (xforth_t
); i
++, addr
++) {
259 unaligned_xstore(fcode_env_t
*env
)
264 CHECK_DEPTH(env
, 2, "unaligned-x!");
267 for (i
= 0; i
< sizeof (xforth_t
); i
++, addr
++) {
274 * xbflips ( xaddr len -- )
277 xbflips(fcode_env_t
*env
)
282 CHECK_DEPTH(env
, 2, "xbflips");
285 for (i
= 0; i
< len
; i
+= sizeof (xforth_t
),
286 addr
+= sizeof (xforth_t
)) {
288 unaligned_xfetch(env
);
291 unaligned_xstore(env
);
296 * xbsplit ( o -- b.lo b.2 b.3 b.4 b.5 b.6 b.7 b.hi )
299 xbsplit(fcode_env_t
*env
)
302 uchar_t b_bytes
[sizeof (xforth_t
)];
307 CHECK_DEPTH(env
, 1, "xbsplit");
308 b
.b_xf
= pop_xforth(env
);
309 for (i
= 0; i
< sizeof (xforth_t
); i
++)
310 PUSH(DS
, b
.b_bytes
[(sizeof (xforth_t
) - 1) - i
]);
314 * xlflip ( oct1 -- oct2 )
317 xlflip(fcode_env_t
*env
)
320 lforth_t b_lf
[LF_PER_XF
];
325 CHECK_DEPTH(env
, 1, "xlflip");
326 b
.b_xf
= pop_xforth(env
);
327 for (i
= 0; i
< LF_PER_XF
; i
++)
328 c
.b_lf
[i
] = b
.b_lf
[(LF_PER_XF
- 1) - i
];
329 push_xforth(env
, c
.b_xf
);
333 * xlflips ( xaddr len -- )
336 xlflips(fcode_env_t
*env
)
341 CHECK_DEPTH(env
, 2, "xlflips");
344 for (i
= 0; i
< len
; i
+= sizeof (xforth_t
),
345 addr
+= sizeof (xforth_t
)) {
347 unaligned_xfetch(env
);
350 unaligned_xstore(env
);
355 * xlsplit ( o -- quad.lo quad.hi )
358 xlsplit(fcode_env_t
*env
)
361 lforth_t b_lf
[LF_PER_XF
];
366 CHECK_DEPTH(env
, 1, "xlsplit");
367 b
.b_xf
= pop_xforth(env
);
368 for (i
= 0; i
< LF_PER_XF
; i
++)
369 PUSH(DS
, b
.b_lf
[(LF_PER_XF
- 1) - i
]);
374 * xwflip ( oct1 -- oct2 )
377 xwflip(fcode_env_t
*env
)
380 wforth_t b_wf
[WF_PER_XF
];
385 CHECK_DEPTH(env
, 1, "xwflip");
386 b
.b_xf
= pop_xforth(env
);
387 for (i
= 0; i
< WF_PER_XF
; i
++)
388 c
.b_wf
[i
] = b
.b_wf
[(WF_PER_XF
- 1) - i
];
389 push_xforth(env
, c
.b_xf
);
393 * xwflips ( xaddr len -- )
396 xwflips(fcode_env_t
*env
)
401 CHECK_DEPTH(env
, 2, "xwflips");
404 for (i
= 0; i
< len
; i
+= sizeof (xforth_t
),
405 addr
+= sizeof (xforth_t
)) {
407 unaligned_xfetch(env
);
410 unaligned_xstore(env
);
415 * xwsplit ( o -- w.lo w.2 w.3 w.hi )
418 xwsplit(fcode_env_t
*env
)
421 wforth_t b_wf
[WF_PER_XF
];
426 CHECK_DEPTH(env
, 1, "xwsplit");
427 b
.b_xf
= pop_xforth(env
);
428 for (i
= 0; i
< WF_PER_XF
; i
++)
429 PUSH(DS
, b
.b_wf
[(WF_PER_XF
- 1) - i
]);
437 fcode_env_t
*env
= initial_env
;
441 P1275(0x241, 0, "bxjoin", bxjoin
);
442 P1275(0x242, 0, "<l@", lsfetch
);
443 P1275(0x243, 0, "lxjoin", lxjoin
);
444 P1275(0x244, 0, "wxjoin", wxjoin
);
445 P1275(0x245, 0, "x,", xcomma
);
446 P1275(0x246, 0, "x@", xfetch
);
447 P1275(0x247, 0, "x!", xstore
);
448 P1275(0x248, 0, "/x", slash_x
);
449 P1275(0x249, 0, "/x*", slash_x_times
);
450 P1275(0x24a, 0, "xa+", xa_plus
);
451 P1275(0x24b, 0, "xa1+", xa_one_plus
);
452 P1275(0x24c, 0, "xbflip", xbflip
);
453 P1275(0x24d, 0, "xbflips", xbflips
);
454 P1275(0x24e, 0, "xbsplit", xbsplit
);
455 P1275(0x24f, 0, "xlflip", xlflip
);
456 P1275(0x250, 0, "xlflips", xlflips
);
457 P1275(0x251, 0, "xlsplit", xlsplit
);
458 P1275(0x252, 0, "xwflip", xwflip
);
459 P1275(0x253, 0, "xwflips", xwflips
);
460 P1275(0x254, 0, "xwsplit", xwsplit
);
462 FORTH(0, "unaligned-x@", unaligned_xfetch
);
463 FORTH(0, "unaligned-x!", unaligned_xstore
);