home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / equcolon.seq < prev    next >
Encoding:
Text File  |  1989-07-03  |  5.3 KB  |  173 lines

  1. \ EQUCOLON.SEQ          words to modify VALUEs          by Tom Zimmer
  2.  
  3. \ Link this file into the FILELIST chain.
  4.  
  5. FILES DEFINITIONS
  6.  
  7. VARIABLE EQUCOLON.SEQ
  8.  
  9. FORTH DEFINITIONS   META IN-META
  10.  
  11. \ CODE portion of inline manipulation words.
  12.  
  13. CODE    %@>     ( --- n1 )
  14. \ Fetch from the BODY field of following definition.
  15.                 LODSW ES:
  16.                 MOV BX, AX
  17.                 PUSH 3 [BX]
  18.                 NEXT            END-CODE
  19.  
  20. CODE    %!>     ( n1 --- )
  21. \ Store to BODY field of following definition.
  22.                 LODSW ES:
  23.                 MOV BX, AX
  24.                 POP 3 [BX]
  25.                 NEXT            END-CODE
  26.  
  27. CODE    %U@>    ( --- n1 )
  28. \ Fetch the DATA field of a USER definition in user space.
  29.                 LODSW ES:
  30.                 MOV BX, AX
  31.                 MOV BX, 3 [BX]
  32.                 ADD BX, UP
  33.                 PUSH 0 [BX]
  34.                 NEXT            END-CODE
  35.  
  36. CODE    %U!>    ( n1 --- )
  37. \ Store into the DATA field of a USER definition in user space.
  38.                 LODSW ES:
  39.                 MOV BX, AX
  40.                 MOV BX, 3 [BX]
  41.                 ADD BX, UP
  42.                 POP 0 [BX]
  43.                 NEXT            END-CODE
  44.  
  45. CODE   %+!>     ( n1 --- )
  46. \ Increment the BODY field of the following definition by n1.
  47.                 POP CX
  48.                 LODSW ES:
  49.                 MOV BX, AX
  50.                 ADD 3 [BX], CX WORD
  51.                 NEXT            END-CODE
  52.  
  53. CODE   %INCR>   ( --- )
  54. \ Increment the BODY field of the following definition by one.
  55.                 LODSW ES:
  56.                 MOV BX, AX
  57.                 INC 3 [BX] WORD
  58.                 NEXT            END-CODE
  59.  
  60. CODE   %DECR>   ( --- )
  61. \ Decrement the BODY field of the following definition by one.
  62.                 LODSW ES:
  63.                 MOV BX, AX
  64.                 DEC 3 [BX] WORD
  65.                 NEXT            END-CODE
  66.  
  67. CODE   %OFF>    ( --- )
  68. \ Clear to zero the BODY field of following definition.
  69.                 LODSW ES:
  70.                 MOV BX, AX
  71.                 MOV 3 [BX], # 0  WORD
  72.                 NEXT            END-CODE
  73.  
  74. CODE   %ON>     ( --- )
  75. \ Set to -1 the BODY field of following definition.
  76.                 LODSW ES:
  77.                 MOV BX, AX
  78.                 MOV 3 [BX], # -1 WORD
  79.                 NEXT            END-CODE
  80.  
  81. CODE   %&>      ( -- a1 )
  82. \ Return the BODY a1 address of the following word in a definition.
  83.                 LODSW ES:
  84.                 ADD AX, # 3
  85.                 1PUSH           END-CODE
  86.  
  87. \ ***************************************************************************
  88. \ CODE portion ends, and HIGH LEVEL portion begins.
  89. \
  90. \ If you are creating a stand alone application, the following definitions
  91. \ can be omitted.
  92.  
  93. : ?NOUSER       ( A1 --- A1 )
  94. \ Test a1 to verify it is not a USER definition, if it is, abort.
  95.                 DUP >IS OVER >BODY <>
  96.                 ABORT" Won't work on USER words." ;
  97.  
  98. : ?USER         ( a1 --- a1 f1 )
  99. \ test a1, is it a user word, return TRUE if it is else FALSE.
  100.                 DUP >IS OVER >BODY <> ;
  101.  
  102. : @>            ( | <name> --- n1 )
  103. \ Fetch the BODY or USER contents of <name>.
  104.                 STATE @
  105.                 IF      ' ?USER
  106.                         IF      COMPILE %U@>
  107.                         ELSE    COMPILE %@>
  108.                         THEN    X,
  109.                 ELSE    ' >IS @
  110.                 THEN    ; IMMEDIATE
  111.  
  112. : !>            ( n1 | <name> --- )
  113. \ Store into the BODY or USER field of <name>.
  114. \ The word "=:" is an alias of this word.
  115.                 STATE @
  116.                 IF      ' ?USER
  117.                         IF      COMPILE %U!>
  118.                         ELSE    COMPILE %!>
  119.                         THEN    X,
  120.                 ELSE    ' >IS !
  121.                 THEN    ; IMMEDIATE
  122.  
  123. : +!>           ( n1 | <name> --- )
  124. \ Increment the BODY or USER field of <name> by n1.
  125.                 ' ?NOUSER
  126.                 STATE @
  127.                 IF      COMPILE %+!> X,
  128.                 ELSE    >IS +!
  129.                 THEN    ; IMMEDIATE
  130.  
  131. : INCR>         ( | <name> --- )
  132. \ Increment the body of <name> by one, used to modify the following
  133. \ VALUE or VARIABLE.
  134.                 ' ?NOUSER
  135.                 STATE @
  136.                 IF      COMPILE %INCR> X,
  137.                 ELSE    >IS INCR
  138.                 THEN    ; IMMEDIATE
  139.  
  140. : DECR>         ( | <name> --- )
  141. \ Decrement the body of <name> by one, used to modify the following
  142. \ VALUE or VARIABLE.
  143.                 ' ?NOUSER
  144.                 STATE @
  145.                 IF      COMPILE %DECR> X,
  146.                 ELSE    >IS DECR
  147.                 THEN    ; IMMEDIATE
  148.  
  149. : OFF>          ( | <name> --- )
  150. \ Turn off the VALUE or VARIABLE <name> following.
  151.                 ' ?NOUSER
  152.                 STATE @
  153.                 IF      COMPILE %OFF> X,
  154.                 ELSE    >IS OFF
  155.                 THEN    ; IMMEDIATE
  156.  
  157. : ON>           ( N1 T1 --- )
  158. \ Turn on the VALUE or VARIABLE <name> following.
  159.                 ' ?NOUSER
  160.                 STATE @
  161.                 IF      COMPILE %ON> X,
  162.                 ELSE    >IS ON
  163.                 THEN    ; IMMEDIATE
  164.  
  165. : &>            ( t1 --- a1 )           \ 07/03/89 RB
  166. \ Return the BODY address a1 of word t1, a VALUE of VARIABLE.
  167.                 ' ?NOUSER
  168.                 STATE @
  169.                 IF      COMPILE %&> X,
  170.                 ELSE    >IS
  171.                 THEN    ; IMMEDIATE
  172.  
  173.