Update of /cvsroot/win32forth/win32forth-stc/src
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv22499
Added Files:
struct.f
Log Message:
arm: initial load
--- NEW FILE: struct.f ---
\ $Id: struct.f,v 1.1 2007/05/17 08:13:21 alex_mcdonald Exp $ \
\ --------------------------- Change Block -------------------------------
\
\
\ ------------------------- End Change Block -----------------------------
\
\ Experimental: a fully optimising, STC based, ANS Forth compliant kernel
\
\ Copyright [c] 2005 by Alex McDonald (alex at rivadpm dot com)
\
\ 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 2 of the License, 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; if not, write to the Free Software Foundation, Inc.,
\ 675 Mass Ave, Cambridge, MA 02139, USA.
\
\ ------------------------------------------------------------------------
\ RfD: Structures - Version 4
\ 6 February 2007, Stephen Pelc
\ ------------------------------------------------------------------------
: begin-structure ( -- addr 0 )
create here 0 0 ,
does> ( -- size ) @ ;
: end-structure ( addr n -- )
swap ! ; \ set size
: +field ( n1 n2 "name" -- n3 )
create over , +
does> ( addr -- addr+n1 ) @ + ;
: field: ( n1 <"name"> -- n2 ) ( addr -- 'addr ) aligned cell +FIELD ;
: cfield: ( n1 <"name"> -- n2 ) ( addr -- 'addr ) 1 chars +FIELD ;
: bfield: ( n1 <"name"> -- n2 ) ( addr -- 'addr ) 1 +FIELD ;
: wfield: ( n1 <"name"> -- n2 ) ( addr -- 'addr ) 2 +FIELD ;
: lfield: ( n1 <"name"> -- n2 ) ( addr -- 'addr ) 4 +FIELD ;
: xfield: ( n1 <"name"> -- n2 ) ( addr -- 'addr ) 8 +FIELD ;
|