home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
EFFO
/
pd6.lzh
/
LIB
/
TILE
/
forth.f83
< prev
next >
Wrap
Text File
|
1989-12-21
|
5KB
|
129 lines
\
\ FORTH LEVEL SYSTEM DEFINITIONS
\
\ Copyright (c) 1989 by Mikael R.K. Patel
\
\ Computer Aided Design Laboratory (CADLAB)
\ Department of Computer and Information Science
\ Linkoping University
\ S-581 83 LINKOPING
\ SWEDEN
\
\ Email: mip@ida.liu.se
\
\ Started on: 30 June 1988
\
\ Last updated on: 26 November 1989
\
\ Dependencies:
\ (forth) forth, string, enumerates, bitfields, structures
\
\ Description:
\ High level extensions to the forth kernel. Implementation
\ dependent sections such as entry and vocabulary structures.
\
\ Copying:
\ This program is free software; you can redistribute it and\or modify
\ it under the terms of the GNU General Public License as published by
\ the Free Software Foundation; either version 1, or (at your option)
\ any later version.
\
\ This program is distributed in the hope that it will be useful,
\ but WITHOUT ANY WARRANTY; without even the implied warranty of
\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\ GNU General Public License for more details.
\
\ You should have received a copy of the GNU General Public License
\ along with this program; see the file COPYING. If not, write to
\ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
.( Loading Forth definitions...) cr
( Memory word size and integer range)
32 constant BITS/WORD
4 constant BYTES/WORD
1 BITS/WORD 1- << constant MIN_INT
MIN_INT 1- constant MAX_INT
( Entry and vocabulary structures)
#include enumerates.f83
#include bitfields.f83
#include structures.f83
bitfields structures enumerates string forth definitions
struct.type ENTRY ( -- )
ptr +link ( Pointer to previous entry)
ptr +name ( Pointer to null-ended string)
long +mode ( Mode bit field)
long +code ( Code type or pointer to code)
long +parameter ( Parameter field or pointer to dito)
struct.end
bitfield.type MODES ( -- )
bit IMMEDIATE ( Execution always)
bit EXECUTION ( Execution only)
bit COMPILITION ( Compilation only)
bit PRIVATE ( Private only)
4 bits RESERVED ( Bit fields reserved for future use)
bitfield.end ( Bit 8-31 are free for applications)
enum.type CODES ( -- )
enum CODE ( Primitive code)
enum COLON ( Colon definition)
enum VARIABLE ( Variable)
enum CONSTANT ( Constant)
enum VOCABULARY ( Vocabulary)
enum CREATE ( Created symbol)
enum USER ( User variable local to task)
enum LOCAL ( Local frame variable)
enum FORWARD ( Forward reference)
enum FIELD ( Field access variable)
enum EXCEPTION ( Exception variable)
enum.end ( Otherwise forth level manager)
: .entry ( entry -- )
." entry#" dup . ( Print entry address)
." link: " dup +link @ . ( Print link)
." name: " dup +name @ print ( Print name)
." mode: " dup +mode @ . ( Print mode)
." code: " dup +code @ . ( Print code)
." parameter: " +parameter @ . ; ( Print parameter field)
: .context ( -- )
." context: " context ( Access context vocabulary set)
begin ( Iterate over all vocabularies)
dup @ ?dup ( Access vocabulary)
while
.name space ( And print vocabulary name)
sizeof ptr + ( Index the next vocabulary in the set)
repeat
drop cr ;
: .current ( -- )
." current: " current @ .name cr ; ( Print name of current vocabulary)
: .vocabulary ( -- )
." vocabulary: " context ( Access search vocabularies)
begin
dup @ ?dup ( Check for last vocabulary)
while
+parameter @ ( Access list of entries)
begin
?dup ( For all entries)
while
dup +code @ VOCABULARY = ( Check if the entry is a vocabulary)
if dup .name space then ( Print its name and continue)
+link @ ( to the next entry)
repeat
sizeof ptr + ( Move to the next vocabulary)
repeat
drop cr ; ( Drop search list pointer)
forth only