P4_SLASH_FIELD(3)

NAME
p4_slash_field - /FIELD ( offset size "name" -- offset+size )

SYNOPSIS

#include <pfe/useful-ext.h>

FCode p4_slash_field(---);

DESCRIPTION

created a new +FIELD name with an OFFSET-RT of offset. Then add the size value to the offset so that the next /FIELD declaration will start at the end of the field currently declared. This word is the simplest way to declared structure access words in forth - the two STRUCT modules contain a more elaborate series of words. This one is used like:

      0                        ( a fresh definition is started )
      /CHAR /FIELD -&gt;zapp.a    ( zero offset from the base of the struct )
      /CELL /FIELD -&gt;zapp.b    ( no alignment, starts off at 1 from base )
      CONSTANT /zapp           ( store size of complete zap structure )

      /zapp                    ( extend the zap structure )
      /CELL /FIELD -&gt;zappx.c   ( a new field )
      CONSTANT /zappx          ( and save it again )

      CREATE zapp1 /zapp ALLOT ( a way to allocate a strucutre )
      /zapp BUFFER: zapp2      ( another way to do it, semi-standard )

      zapp2 -&gt;zapp.b @         ( read a value from the field )
      16 zapp2 -&gt;zapp.b !      ( store a value in there )

compare also with /CHAR /WCHAR /CELL /DCELL and use +FIELD as the lowlevel word, can simulate as

      : /FIELD SWAP +FIELD + ;

AUTHOR

    • Guido U. Draheim (modified by $Author: guidod $)

COPYRIGHT

Copyright (C) Tektronix, Inc. 1998 - 2001. Copyright (C) 2005 - 2008 Guido U. Draheim <guidod@gmx.de>