P4_PLUS_FIELD(3)

NAME
p4_plus_field - +FIELD: ( offset "name" -- offset )

SYNOPSIS

#include <pfe/useful-ext.h>

FCode p4_plus_field(---);

DESCRIPTION

created a new name with an OFFSET-RT runtime using the given offset. Leave the offset-value untouched, so it can be modified with words like CHAR+ and CELL+ and SFLOAT+ ; This word is the simplest way to declared structure access words in forth - the two STRUCT modules contain a more elaborate series of words. Use this one like:

      0                        ( a fresh definition is started )
      +FIELD: zapp.a+ CHAR+     ( zero offset from the base of the struct )
      +FIELD: zapp.b+ CELL+     ( no alignment, starts off at 1 from base )
      +FIELD: zapp+   DROP      ( store size of complete zap structure )

      0 zapp+                  ( extend the zap structure )
      +FIELD: zappx.c+ CELL+    ( a new field )
      +FIELD: zappx+   DROP     ( and save it again )

      CREATE zapp1  0 zapp+ ALLOT ( a way to allocate a strucutre )

      zapp2 zapp.b+ @         ( read a value from the field )
      16 zapp2 zapp.b+ !      ( store a value in there )

this form is not the traditional form used in forth, it is however quite simple. Use the simplefield declaration with /FIELD to be compatible with traditional styles that build on top of sizeof constants in forth (which are not part of the ANS Forth standard).

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>