umouse

umouse.git
git clone git://git.lenczewski.org/umouse.git
Log | Files | Refs | Submodules | README

DPANS3.HTM (48907B)


      1 <HTML><HEAD>
      2 <TITLE>DPANS94</TITLE>
      3 <link disabled rel="stylesheet" href="mpexc6.css">
      4 <style>@import url(mpexc6.css);</style>
      5 </head>
      6 
      7 <BODY>
      8 <table width=100%>
      9 <tr>
     10 <td align=left>
     11 <a href=dpans2.htm><img src=left.gif
     12  width=26 height=26 align=ALIGN border=0></a>
     13 <a href=dpans4.htm><img src=right.gif
     14  width=26 height=26 align=ALIGN border=0></a>
     15 </td>
     16 <td align=right>
     17 <a href=dpans.htm#toc><img src=up.gif 
     18  width=26 height=26 align=ALIGN border=0></a>
     19 <a name=3.>Table of Contents</a>
     20 </td>
     21 </tr>
     22 </table>
     23 <p>
     24 <hr size=4>
     25 
     26 <H1>3. Usage requirements</H1>
     27 
     28 A system shall provide all of the words defined in 
     29 <a href=dpans6.htm#6.1>6.1</a> Core Words.  It
     30 may also provide any words defined in the optional word sets and
     31 extensions word sets.  No standard word provided by a system shall alter
     32 the system state in a way that changes the effect of execution of any
     33 other standard word except as provided in this Standard.  A system may
     34 contain non-standard extensions, provided that they are consistent with
     35 the requirements of this Standard.
     36 
     37 <P>
     38 
     39 The implementation of a system may use words and techniques outside the
     40 scope of this Standard.
     41 
     42 <P>
     43 
     44 A system need not provide all words in executable form.  The
     45 implementation may provide definitions, including definitions of words
     46 in the Core word set, in source form only.  If so, the mechanism for
     47 adding the definitions to the dictionary is implementation defined.
     48 
     49 <P>
     50 
     51 A program that requires a system to provide words or techniques not
     52 defined in this Standard has an environmental dependency.
     53 
     54 <P>
     55 <code>
     56 See:
     57 <a href=dpansa3.htm#A.3>A.3</a> Usage requirements
     58 </code>
     59 <p>
     60 
     61 <hr>
     62 <A name=3.1>
     63 <H2>3.1 Data types</H2>
     64 </a>
     65 
     66 A data type identifies the set of permissible values for a data object.
     67 It is not a property of a particular storage location or position on a
     68 stack.  Moving a data object shall not affect its type.
     69 
     70 <P>
     71 
     72 No data-type checking is required of a system.  An ambiguous condition
     73 exists if an incorrectly typed data object is encountered.
     74 
     75 <P>
     76 
     77 <a href=dpans3.htm#table.3.1>Table 3.1</a> summarizes the data types used throughout this Standard.
     78 Multiple instances of the same type in the description of a definition
     79 are suffixed with a sequence digit subscript to distinguish them.
     80 
     81 <P>
     82 <code>
     83 See:
     84 <a href=dpansa3.htm#A.3.1>A.3.1</a> Date-types
     85 </code>
     86 <p>
     87 
     88 <hr>
     89 <A name=3.1.1>
     90 <H3>3.1.1 Data-type relationships</H3>
     91 </a>
     92 
     93 Some of the data types are subtypes of other data types.  A data type i
     94 is a subtype of type j if and only if the members of i are a subset of
     95 the members of j.  The following list represents the subtype
     96 relationships using the phrase <B>i =&gt; j</B> to denote <B>i is a subtype
     97 of j</B>.  The subtype relationship is transitive; if i =&gt; j and j =&gt; k
     98 then i =&gt; k:
     99 
    100 <PRE>
    101 	+n => u => x;
    102 	+n => n => x;
    103 	char => +n;
    104 	a-addr => c-addr => addr => u;
    105 	flag => x;
    106 	xt => x;
    107 	+d => d => xd;
    108 	+d => ud => xd.
    109 </PRE>
    110 <P>
    111 
    112 Any Forth definition that accepts an argument of type i shall also accept an
    113 argument that is a subtype of i.
    114 
    115 <P>
    116 
    117 <hr>
    118 <A name=3.1.2>
    119 <H3>3.1.2 Character types</H3>
    120 </a>
    121 
    122 Characters shall be at least one address unit wide, contain at least eight
    123 bits, and have a size less than or equal to cell size.
    124 
    125 <P>
    126 
    127 The characters provided by a system shall include the graphic characters
    128 {32..126}, which represent graphic forms as shown in 
    129 <a href=dpans3.htm#table.3.2>table 3.2</a>.
    130 
    131 <P>
    132 <code>
    133 See:
    134 <a href=dpansa3.htm#A.3.1.2>A.3.1.2</a> Character types
    135 </code>
    136 <p>
    137 
    138 <hr>
    139 <A name=3.1.2.1>
    140 <H2>3.1.2.1 Graphic characters</H2>
    141 </a>
    142 
    143 A graphic character is one that is normally displayed (e.g., A, #, &, 6).
    144 These values and graphics, shown in 
    145 <a href=dpans3.htm#table.3.2>table 3.2</a>, are taken directly from ANS
    146 X3.4-1974 (ASCII) and ISO 646-1983, International Reference Version (IRV).
    147 The graphic forms of characters outside the hex range {20..7E} are
    148 implementation-defined.  Programs that use the graphic hex 24 (the currency
    149 sign) have an environmental dependency.
    150 
    151 <P>
    152 
    153 The graphic representation of characters is not restricted to particular type
    154 fonts or styles.  The graphics here are examples.
    155 
    156 <P>
    157 
    158 <hr>
    159 <A name=3.1.2.2>
    160 <H4>3.1.2.2 Control characters</H4>
    161 </a>
    162 
    163 All non-graphic characters included in the implementation-defined character
    164 set are defined in this Standard as control characters.  In particular, the
    165 characters {0..31}, which could be included in the implementation-defined
    166 character set, are control characters.
    167 
    168 <P>
    169 
    170 Programs that require the ability to send or receive control characters have
    171 an environmental dependency.
    172 
    173 <P>
    174 
    175 <hr>
    176 <h3><a name=table.3.1>Table 3.1</a> - Data types</h3>
    177 <P>
    178 
    179 
    180 <PRE>
    181 Symbol          Data type                         Size on stack
    182 ------          ---------                         -------------
    183 flag            flag                              1 cell
    184 true            true flag                         1 cell
    185 false           false flag                        1 cell
    186 char            character                         1 cell
    187 n               signed number                     1 cell
    188 +n              non-negative number               1 cell
    189 u               unsigned number                   1 cell
    190 n|u 1           number                            1 cell
    191 x               unspecified cell                  1 cell
    192 xt              execution token                   1 cell
    193 addr            address                           1 cell
    194 a-addr          aligned address                   1 cell
    195 c-addr          character-aligned address         1 cell
    196 d               double-cell signed number         2 cells
    197 +d              double-cell non-negative number   2 cells
    198 ud              double-cell unsigned number       2 cells
    199 d|ud 2          double-cell number                2 cells
    200 xd              unspecified cell pair             2 cells
    201 colon-sys       definition compilation            implementation dependent
    202 do-sys          do-loop structures                implementation dependent
    203 case-sys        CASE structures                   implementation dependent
    204 of-sys          OF structures                     implementation dependent
    205 orig            control-flow origins              implementation dependent
    206 dest            control-flow destinations         implementation dependent
    207 loop-sys        loop-control parameters           implementation dependent
    208 nest-sys        definition calls                  implementation dependent
    209 i*x, j*x, k*x 3 any data type                     0 or more cells
    210 </PRE>
    211 
    212 <P>
    213 
    214 <B>1</B> May be either a signed number or an unsigned number depending
    215 on context.
    216 
    217 <P>
    218 
    219 <B>2</B> May be either a double-cell signed number or a double-cell
    220 unsigned number depending on context.
    221 
    222 <P>
    223 
    224 <B>3</B> May be an undetermined number of stack entries of unspecified
    225 type.  For examples of use, see 
    226 <a href=dpans6.htm#6.1.1370>6.1.1370</a> EXECUTE, 
    227 <a href=dpans6.htm#6.1.2050>6.1.2050</a> QUIT.
    228 
    229 <p>
    230 <code>
    231 See:
    232 <a href=dpans11.htm#11.3.1>11.3.1</a> Data types,
    233 <a href=dpans12.htm#12.3.1>12.3.1</a> Data types,
    234 <a href=dpans14.htm#14.3.1>14.3.1</a> Data types,
    235 <a href=dpans16.htm#16.3.1>16.3.1</a> Data types.
    236 </code>
    237 <p>
    238 
    239 <HR>
    240 <h3><a name=table.3.2>Table 3.2</a> - Standard graphic characters</h3>
    241 
    242 
    243 <PRE>
    244 Hex     IRV     ASCII
    245 ---     ---     -----
    246 20
    247 21      !       !
    248 22      "       "
    249 23      #       #
    250 24      °       $
    251 25      %       %
    252 26      &       &
    253 27      '       '
    254 28      (       (
    255 29      )       )
    256 2A      *       *
    257 2B      +       +
    258 2C      ,       ,
    259 2D      -       -
    260 2E      .       .
    261 2F      /       /
    262 30      0       0
    263 31      1       1
    264 32      2       2
    265 33      3       3
    266 34      4       4
    267 35      5       5
    268 36      6       6
    269 37      7       7
    270 38      8       8
    271 39      9       9
    272 3A      :       :
    273 3B      ;       ;
    274 3C      <       <
    275 3D      =       =
    276 3E      >       >
    277 3F      ?       ?
    278 40      @       @
    279 41      A       A
    280 42      B       B
    281 43      C       C
    282 44      D       D
    283 45      E       E
    284 46      F       F
    285 47      G       G
    286 48      H       H
    287 49      I       I
    288 4A      J       J
    289 4B      K       K
    290 4C      L       L
    291 4D      M       M
    292 4E      N       N
    293 4F      O       O
    294 50      P       P
    295 51      Q       Q
    296 52      R       R
    297 53      S       S
    298 54      T       T
    299 55      U       U
    300 56      V       V
    301 57      W       W
    302 58      X       X
    303 59      Y       Y
    304 5A      Z       Z
    305 5B      [       [
    306 5C      \       \
    307 5D      ]       ]
    308 5E      ^       ^
    309 5F      _       _
    310 60      `       `
    311 61      a       a
    312 62      b       b
    313 63      c       c
    314 64      d       d
    315 65      e       e
    316 66      f       f
    317 67      g       g
    318 68      h       h
    319 69      i       i
    320 6A      j       j
    321 6B      k       k
    322 6C      l       l
    323 6D      m       m
    324 6E      n       n
    325 6F      o       o
    326 70      p       p
    327 71      q       q
    328 72      r       r
    329 73      s       s
    330 74      t       t
    331 75      u       u
    332 76      v       v
    333 77      w       w
    334 78      x       x
    335 79      y       y
    336 7A      z       z
    337 7B      {       {
    338 7C      |       |
    339 7D      }       }
    340 7E      ~       ~
    341 </PRE>
    342 
    343 <P>
    344 
    345 <hr>
    346 <A name=3.1.3>
    347 <H3>3.1.3 Single-cell types</H3>
    348 </a>
    349 
    350 The implementation-defined fixed size of a cell is specified in address units
    351 and the corresponding number of bits.  See 
    352 <a href=dpanse.htm#E.2>E.2</a> Hardware peculiarities.
    353 
    354 <P>
    355 
    356 Cells shall be at least one address unit wide and contain at least sixteen
    357 bits.  The size of a cell shall be an integral multiple of the size of a
    358 character.  Data-stack elements, return-stack elements, addresses, execution
    359 tokens, flags, and integers are one cell wide.
    360 
    361 <P>
    362 <code>
    363 See:
    364 <a href=dpansa3.htm#A.3.1.3>A.3.1.3</a> Single-cell types
    365 </code>
    366 <p>
    367 
    368 <hr>
    369 <A name=3.1.3.1>
    370 <H4>3.1.3.1 Flags</H4>
    371 </a>
    372 
    373 Flags may have one of two logical states, true or false.  Programs that use
    374 flags as arithmetic operands have an environmental dependency.
    375 
    376 <P>
    377 
    378 A true flag returned by a standard word shall be a single-cell value with all
    379 bits set.  A false flag returned by a standard word shall be a single-cell
    380 value with all bits clear.
    381 
    382 <P>
    383 <code>
    384 See:
    385 <a href=dpansa3.htm#A.3.1.3.1>A.3.1.3.1</a> Flags
    386 </code>
    387 <p>
    388 
    389 <hr>
    390 <A name=3.1.3.2>
    391 <H4>3.1.3.2 Integers</H4>
    392 </a>
    393 
    394 The implementation-defined range of signed integers shall include
    395 {-32767..+32767}.
    396 
    397 <P>
    398 
    399 The implementation-defined range of non-negative integers shall include
    400 {0..32767}.
    401 
    402 <P>
    403 
    404 The implementation-defined range of unsigned integers shall include
    405 {0..65535}.
    406 
    407 <P>
    408 <code>
    409 See:
    410 <a href=dpansa3.htm#A.3.1.3.2>A.3.1.3.2</a> Integers
    411 </code>
    412 <p>
    413 
    414 <hr>
    415 <A name=3.1.3.3>
    416 <H4>3.1.3.3 Addresses</H4>
    417 </a>
    418 
    419 An address identifies a location in data space with a size of one address
    420 unit, which a program may fetch from or store into except for the restrictions
    421 established in this Standard.  The size of an address unit is specified in
    422 bits.  Each distinct address value identifies exactly one such storage
    423 element.  See 
    424 <a href=dpans3.htm#3.3.3>3.3.3</a> Data space.
    425 
    426 <P>
    427 
    428 The set of character-aligned addresses, addresses at which a character can be
    429 accessed, is an implementation-defined subset of all addresses.  Adding the
    430 size of a character to a character-aligned address shall produce another
    431 character-aligned address.
    432 
    433 <P>
    434 
    435 The set of aligned addresses is an implementation-defined subset of
    436 character-aligned addresses.  Adding the size of a cell to an aligned address
    437 shall produce another aligned address.
    438 
    439 <P>
    440 <code>
    441 See:
    442 <a href=dpansa3.htm#A.3.1.3.3>A.3.1.3.3</a> Addresses
    443 </code>
    444 <p>
    445 
    446 <hr>
    447 <A name=3.1.3.4>
    448 <H4>3.1.3.4 Counted strings</H4>
    449 </a>
    450 
    451 A counted string in memory is identified by the address (c-addr) of its length
    452 character.
    453 
    454 <P>
    455 
    456 The length character of a counted string shall contain a binary
    457 representation of the number of data characters, between zero and the
    458 implementation-defined maximum length for a counted string.  The maximum
    459 length of a counted string shall be at least 255.
    460 
    461 <P>
    462 <code>
    463 See:
    464 <a href=dpansa3.htm#A.3.1.3.4>A.3.1.3.4</a> Counted strings
    465 </code>
    466 <p>
    467 
    468 <hr>
    469 <A name=3.1.3.5>
    470 <H4>3.1.3.5 Execution tokens</H4>
    471 </a>
    472 
    473 Different definitions may have the same execution token if the
    474 definitions are equivalent.
    475 
    476 <P>
    477 <code>
    478 See:
    479 <a href=dpansa3.htm#A.3.1.3.5>A.3.1.3.5</a> Execution tokens
    480 </code>
    481 <p>
    482 
    483 <hr>
    484 <A name=3.1.4>
    485 <H3>3.1.4 Cell-pair types</H3>
    486 </a>
    487 
    488 A cell pair in memory consists of a sequence of two contiguous cells.  The
    489 cell at the lower address is the first cell, and its address is used to
    490 identify the cell pair.  Unless otherwise specified, a cell pair on a stack
    491 consists of the first cell immediately above the second cell.
    492 
    493 <P>
    494 <code>
    495 See:
    496 <a href=dpansa3.htm#A.3.1.4>A.3.1.4</a> Cell-pair types
    497 </code>
    498 <p>
    499 
    500 <hr>
    501 <A name=3.1.4.1>
    502 <H4>3.1.4.1 Double-cell integers</H4>
    503 </a>
    504 
    505 On the stack, the cell containing the most significant part of a
    506 double-cell integer shall be above the cell containing the least
    507 significant part.
    508 
    509 <P>
    510 
    511 The implementation-defined range of double-cell signed integers shall
    512 include {-2147483647..+2147483647}.
    513 
    514 <P>
    515 
    516 The implementation-defined range of double-cell non-negative integers
    517 shall include {0..2147483647}.
    518 
    519 <P>
    520 
    521 The implementation-defined range of double-cell unsigned integers shall
    522 include {0..4294967295}.  Placing the single-cell integer zero on the
    523 stack above a single-cell unsigned integer produces a double-cell
    524 unsigned integer with the same value.  See 
    525 <a href=dpans3.htm#3.2.1.1>3.2.1.1</a> Internal number
    526 representation.
    527 
    528 <P>
    529 <code>
    530 See:
    531 <a href=dpansa3.htm#A.3.1.4.1>A.3.1.4.1</a> Double-cell integers
    532 </code>
    533 <p>
    534 
    535 <hr>
    536 <A name=3.1.4.2>
    537 <H4>3.1.4.2 Character strings</H4>
    538 </a>
    539 
    540 A string is specified by a cell pair (c-addr u) representing its
    541 starting address and length in characters.
    542 
    543 <P>
    544 <code>
    545 See:
    546 <a href=dpansa3.htm#A.3.1.3.4>A.3.1.3.4</a> Counted strings
    547 </code>
    548 <p>
    549 
    550 <hr>
    551 <A name=3.1.5>
    552 <H3>3.1.5 System types</H3>
    553 </a>
    554 
    555 The system data types specify permitted word combinations during
    556 compilation and execution.
    557 
    558 <P>
    559 
    560 <hr>
    561 <A name=3.1.5.1>
    562 <H4>3.1.5.1 System-compilation types</H4>
    563 </a>
    564 
    565 These data types denote zero or more items on the control-flow stack
    566 (see 
    567 <a href=dpans3.htm#3.2.3.2>3.2.3.2</a>).  
    568 The possible presence of such items on the data stack
    569 means that any items already there shall be unavailable to a program
    570 until the control-flow-stack items are consumed.
    571 
    572 <P>
    573 
    574 The implementation-dependent data generated upon beginning to compile a
    575 definition and consumed at its close is represented by the symbol
    576 colon-sys throughout this Standard.
    577 
    578 <P>
    579 
    580 The implementation-dependent data generated upon beginning to compile a
    581 do-loop structure such as 
    582 <a href=dpans6.htm#6.1.1240>DO</a> ... 
    583 <a href=dpans6.htm#6.1.1800>LOOP</a> 
    584 and consumed at its close is
    585 represented by the symbol do-sys throughout this Standard.
    586 
    587 <P>
    588 
    589 The implementation-dependent data generated upon beginning to compile a
    590 <a href=dpans6.htm#6.2.0873>CASE</a> ... 
    591 <a href=dpans6.htm#6.2.1342>ENDCASE</a> 
    592 structure and consumed at its close is represented by
    593 the symbol case-sys throughout this Standard.
    594 
    595 <P>
    596 
    597 The implementation-dependent data generated upon beginning to compile an
    598 <a href=dpans6.htm#6.2.1950>OF</a> ... 
    599 <a href=dpans6.htm#6.2.1343>ENDOF</a> 
    600 structure and consumed at its close is represented by the
    601 symbol of-sys throughout this Standard.
    602 
    603 <P>
    604 
    605 The implementation-dependent data generated and consumed by executing
    606 the other standard control-flow words is represented by the symbols orig
    607 and dest throughout this Standard.
    608 
    609 <P>
    610 
    611 <hr>
    612 <A name=3.1.5.2>
    613 <H4>3.1.5.2 System-execution types</H4>
    614 </a>
    615 
    616 These data types denote zero or more items on the return stack.  Their
    617 possible presence means that any items already on the return stack shall
    618 be unavailable to a program until the system-execution items are
    619 consumed.
    620 
    621 <P>
    622 
    623 The implementation-dependent data generated upon beginning to execute a
    624 definition and consumed upon exiting it is represented by the symbol
    625 nest-sys throughout this Standard.
    626 
    627 <P>
    628 
    629 The implementation-dependent loop-control parameters used to control the
    630 execution of do-loops are represented by the symbol loop-sys throughout
    631 this Standard.  Loop-control parameters shall be available inside the
    632 do-loop for words that use or change these parameters, words such as 
    633 <a href=dpans6.htm#6.1.1680>I</a>,
    634 <a href=dpans6.htm#6.1.1730>J</a>, 
    635 <a href=dpans6.htm#6.1.1760>LEAVE</a> and 
    636 <a href=dpans6.htm#6.1.2380>UNLOOP</a>.
    637 
    638 <P>
    639 
    640 <hr>
    641 <A name=3.2>
    642 <H2>3.2 The implementation environment</H2>
    643 </a>
    644 
    645 <p>
    646 
    647 
    648 <hr>
    649 <A name=3.2.1>
    650 <H3>3.2.1 Numbers</H3>
    651 </a>
    652 
    653 <p>
    654 <code>
    655 See:
    656 <a href=dpansa3.htm#A.3.2.1>A.3.2.1</a> Numbers
    657 </code>
    658 <p>
    659 
    660 
    661 <hr>
    662 <A name=3.2.1.1>
    663 <H4>3.2.1.1 Internal number representation</H4>
    664 </a>
    665 
    666 This Standard allows one's complement, two's complement, or
    667 sign-magnitude number representations and arithmetic.  Arithmetic zero
    668 is represented as the value of a single cell with all bits clear.
    669 <P>
    670 
    671 The representation of a number as a compiled literal or in memory is
    672 implementation dependent.
    673 
    674 <P>
    675 
    676 <hr>
    677 <A name=3.2.1.2>
    678 <H4>3.2.1.2 Digit conversion</H4>
    679 </a>
    680 
    681 Numbers shall be represented externally by using characters from the
    682 standard character set.
    683 
    684 <P>
    685 
    686 Conversion between the internal and external forms of a digit shall
    687 behave as follows:
    688 
    689 <P>
    690 
    691 The value in 
    692 <a href=dpans6.htm#6.1.0750>BASE</a> 
    693 is the radix for number conversion.  A digit has a
    694 value ranging from zero to one less than the contents of BASE.  The
    695 digit with the value zero corresponds to the character <B>0</B>.  This
    696 representation of digits proceeds through the character set to the
    697 decimal value nine corresponding to the character <B>9</B>.  For digits
    698 beginning with the decimal value ten the graphic characters beginning
    699 with the character <B>A</B> are used.  This correspondence continues up
    700 to and including the digit with the decimal value thirty-five which is
    701 represented by the character <B>Z</B>.  The conversion of digits outside
    702 this range is implementation defined.
    703 
    704 <P>
    705 <code>
    706 See:
    707 <a href=dpansa3.htm#A.3.2.1.2>A.3.2.1.2</a> Digit conversion
    708 </code>
    709 <p>
    710 
    711 <hr>
    712 <A name=3.2.1.3>
    713 <H4>3.2.1.3 Free-field number display</H4>
    714 </a>
    715 
    716 Free-field number display uses the characters described in digit
    717 conversion, without leading zeros, in a field the exact size of the
    718 converted string plus a trailing space.  If a number is zero, the least
    719 significant digit is not considered a leading zero.  If the number is
    720 negative, a leading minus sign is displayed.
    721 
    722 <P>
    723 
    724 Number display may use the pictured numeric output string buffer to hold
    725 partially converted strings (see 
    726 <a href=dpans3.htm#3.3.3.6>3.3.3.6</a> Other transient regions).
    727 
    728 <P>
    729 
    730 <hr>
    731 <A name=3.2.2>
    732 <H3>3.2.2 Arithmetic</H3>
    733 </a>
    734 
    735 <p>
    736 
    737 
    738 <hr>
    739 <A name=3.2.2.1>
    740 <H4>3.2.2.1 Integer division</H4>
    741 </a>
    742 
    743 Division produces a quotient q and a remainder r by dividing operand a
    744 by operand b.  Division operations return q, r, or both.  The identity
    745 b*q + r = a shall hold for all a and b.
    746 
    747 <P>
    748 
    749 When unsigned integers are divided and the remainder is not zero, q is
    750 the largest integer less than the true quotient.
    751 
    752 <P>
    753 
    754 When signed integers are divided, the remainder is not zero, and a and b
    755 have the same sign, q is the largest integer less than the true
    756 quotient.  If only one operand is negative, whether q is rounded toward
    757 negative infinity (floored division) or rounded towards zero (symmetric
    758 division) is implementation defined.
    759 
    760 <P>
    761 
    762 Floored division is integer division in which the remainder carries the
    763 sign of the divisor or is zero, and the quotient is rounded to its
    764 arithmetic floor.  Symmetric division is integer division in which the
    765 remainder carries the sign of the dividend or is zero and the quotient
    766 is the mathematical quotient <B>rounded towards zero</B> or
    767 <B>truncated</B>.  Examples of each are shown in tables 
    768 <a href=dpans3.htm#table.3.3>3.3</a> and 
    769 <a href=dpans3.htm#table.3.3>3.4</a>.
    770 
    771 <P>
    772 
    773 In cases where the operands differ in sign and the rounding direction
    774 matters, a program shall either include code generating the desired form
    775 of division, not relying on the implementation-defined default result,
    776 or have an environmental dependency on the desired rounding direction.
    777 
    778 <P>
    779 <code>
    780 See:
    781 <a href=dpansa3.htm#A.3.2.2.1>A.3.2.2.1</a> Integer division
    782 </code>
    783 <p>
    784 
    785 <hr>
    786 <h3><a name=table.3.3>Table 3.3</a> - Floored Division Example</h3>
    787 <P>
    788 
    789 
    790 <PRE>
    791 Dividend        Divisor Remainder       Quotient
    792 --------        ------- ---------       --------
    793 10                 7       3                1
    794 -10                7       4               -2
    795 10                -7      -4               -2
    796 -10               -7      -3                1
    797 </PRE>
    798 <P>
    799 
    800 
    801 <hr>
    802 <h3><a name=table.3.4>Table 3.4</a> - Symmetric Division Example</h3>
    803 
    804 
    805 <PRE>
    806 Dividend        Divisor Remainder       Quotient
    807 --------        ------- ---------       --------
    808 10                 7       3                1
    809 -10                7      -3               -1
    810 10                -7       3               -1
    811 -10               -7      -3                1
    812 
    813 </PRE>
    814 <P>
    815 
    816 
    817 <P>
    818 
    819 <hr>
    820 <A name=3.2.2.2>
    821 <H4>3.2.2.2 Other integer operations</H4>
    822 </a>
    823 
    824 In all integer arithmetic operations, both overflow and underflow shall
    825 be ignored.  The value returned when either overflow or underflow occurs
    826 is implementation defined.
    827 
    828 <P>
    829 <code>
    830 See:
    831 <a href=dpansa3.htm#A.3.2.2.2>A.3.2.2.2</a> Other integer operations
    832 </code>
    833 <p>
    834 
    835 <hr>
    836 <A name=3.2.3>
    837 <H3>3.2.3 Stacks</H3>
    838 </a>
    839 
    840 <p>
    841 <code>
    842 See:
    843 <a href=dpansa3.htm#A.3.2.3>A.3.2.3</a> Stacks
    844 </code>
    845 <p>
    846 
    847 <hr>
    848 <A name=3.2.3.1>
    849 <H4>3.2.3.1 Data stack</H4>
    850 </a>
    851 
    852 Objects on the data stack
    853 shall be one cell wide.
    854 
    855 <P>
    856 
    857 <hr>
    858 <A name=3.2.3.2>
    859 <H4>3.2.3.2 Control-flow stack</H4>
    860 </a>
    861 
    862 The control-flow stack is a last-in, first out list whose elements
    863 define the permissible matchings of control-flow words and the
    864 restrictions imposed on data-stack usage during the compilation of
    865 control structures.
    866 
    867 <P>
    868 
    869 The elements of the control-flow stack are system-compilation data
    870 types.
    871 
    872 <P>
    873 
    874 The control-flow stack may, but need not, physically exist in an
    875 implementation.  If it does exist, it may be, but need not be,
    876 implemented using the data stack.  The format of the control-flow stack
    877 is implementation defined.  Since the control-flow stack may be
    878 implemented using the data stack, items placed on the data stack are
    879 unavailable to a program after items are placed on the control-flow
    880 stack and remain unavailable until the control-flow stack items are
    881 removed.
    882 
    883 <P>
    884 <code>
    885 See:
    886 <a href=dpansa3.htm#A.3.2.3.2>A.3.2.3.2</a> Control-flow stack
    887 </code>
    888 <p>
    889 
    890 <hr>
    891 <A name=3.2.3.3>
    892 <H4>3.2.3.3 Return stack</H4>
    893 </a>
    894 
    895 Items on the return stack shall consist of one or more cells.  A system
    896 may use the return stack in an implementation-dependent manner during
    897 the compilation of definitions, during the execution of do-loops, and
    898 for storing run-time nesting information.
    899 
    900 <P>
    901 
    902 A program may use the return stack for temporary storage during the
    903 execution of a definition subject to the following restrictions:
    904 
    905 <UL>
    906 <LI>A program shall not access values on the return stack (using 
    907 <a href=dpans6.htm#6.1.2070>R@</a>,
    908 <a href=dpans6.htm#6.1.2060>R&gt;</a>, 
    909 <a href=dpans6.htm#6.2.0415>2R@</a> or 
    910 <a href=dpans6.htm#6.2.0410>2R&gt;</a>) 
    911 that it did not place there using 
    912 <a href=dpans6.htm#6.1.0580>&gt;R</a> or 
    913 <a href=dpans6.htm#6.2.0340>2&gt;R;</a>
    914 <LI>A program shall not access from within a do-loop values placed
    915 on the return stack before the loop was entered;
    916 <LI>All values placed on the return stack within a do-loop shall be
    917 removed before 
    918 <a href=dpans6.htm#6.1.1680>I</a>, 
    919 <a href=dpans6.htm#6.1.1730>J</a>, 
    920 <a href=dpans6.htm#6.1.1800>LOOP</a>, 
    921 <a href=dpans6.htm#6.1.0140>+LOOP</a>, 
    922 <a href=dpans6.htm#6.1.2380>UNLOOP</a>, or 
    923 <a href=dpans6.htm#6.1.1760>LEAVE</a> is executed;
    924 <LI>All values placed on the return stack within a definition shall
    925 be removed before the definition is terminated or before 
    926 <a href=dpans6.htm#6.1.1380>EXIT</a> is
    927 executed.
    928 </UL>
    929 
    930 <P>
    931 <code>
    932 See:
    933 <a href=dpansa3.htm#A.3.2.3.3>A.3.2.3.3</a> Return stack
    934 </code>
    935 <p>
    936 
    937 <hr>
    938 <A name=3.2.4>
    939 <H3>3.2.4 Operator terminal</H3>
    940 </a>
    941 
    942 <code>
    943 See:
    944 <a href=dpans1.htm#1.2.2>1.2.2</a> Exclusions
    945 </code>
    946 <P>
    947 
    948 <hr>
    949 <A name=3.2.4.1>
    950 <H4>3.2.4.1 User input device</H4>
    951 </a>
    952 
    953 The method of selecting the user input
    954 device is implementation defined.
    955 
    956 <P>
    957 
    958 The method of indicating the end of an input line of text is
    959 implementation defined.
    960 
    961 <P>
    962 
    963 <hr>
    964 <A name=3.2.4.2>
    965 <H4>3.2.4.2 User output device</H4>
    966 </a>
    967 
    968 The method of selecting the user output device is implementation
    969 defined.
    970 
    971 <P>
    972 
    973 <hr>
    974 <A name=3.2.5>
    975 <H3>3.2.5 Mass storage</H3>
    976 </a>
    977 
    978 A system need not provide any standard words for accessing mass storage.
    979 If a system provides any standard word for accessing mass storage, it
    980 shall also implement the Block word set.
    981 
    982 <P>
    983 
    984 <hr>
    985 <A name=3.2.6>
    986 <H3>3.2.6 Environmental queries</H3>
    987 </a>
    988 
    989 The name spaces for 
    990 <a href=dpans6.htm#6.1.1345>ENVIRONMENT?</a> 
    991 and definitions are disjoint.  Names of
    992 definitions that are the same as ENVIRONMENT? strings shall not impair
    993 the operation of ENVIRONMENT?.  
    994 Table 3.5 contains the valid input
    995 strings and corresponding returned value for inquiring about the
    996 programming environment with ENVIRONMENT?.
    997 
    998 <P>
    999 
   1000 <a name=table.3.5>
   1001 Table 3.5 - Environmental Query Strings
   1002 </a>
   1003 <P>
   1004 
   1005 
   1006 
   1007 <PRE>
   1008 String                Value  Constant?       Meaning
   1009                     data type
   1010 /COUNTED-STRING         n       yes     maximum size of a counted string,
   1011                                         in characters
   1012 /HOLD                   n       yes     size of the pictured numeric output
   1013                                         string buffer, in characters
   1014 /PAD                    n       yes     size of the scratch area pointed to
   1015                                         by PAD, in characters
   1016 ADDRESS-UNIT-BITS       n       yes     size of one address unit, in bits
   1017 CORE                    flag    no      true if complete core word set
   1018                                         present (i.e., not a subset as
   1019                                         defined in <a href=dpans5.htm#5.1.1>5.1.1</a>)
   1020 CORE-EXT                flag    no      true if core extensions word
   1021                                         set present
   1022 FLOORED                 flag    yes     true if floored division is the default
   1023 MAX-CHAR                u       yes     maximum value of any character in the
   1024                                         implementation-defined character set
   1025 MAX-D                   d       yes     largest usable signed double number
   1026 MAX-N                   n       yes     largest usable signed integer
   1027 MAX-U                   u       yes     largest usable unsigned integer
   1028 MAX-UD                  ud      yes     largest usable unsigned double number
   1029 RETURN-STACK-CELLS      n       yes     maximum size of the return stack,
   1030                                         in cells
   1031 STACK-CELLS             n       yes     maximum size of the data stack,
   1032                                         in cells
   1033 </PRE>
   1034 <P>
   1035 
   1036 If an environmental query (using ENVIRONMENT?) returns false (i.e.,
   1037 unknown) in response to a string, subsequent queries using the same
   1038 string may return true.  If a query returns true (i.e., known) in
   1039 response to a string, subsequent queries with the same string shall also
   1040 return true.  If a query designated as constant in the above table
   1041 returns true and a value in response to a string, subsequent queries
   1042 with the same string shall return true and the same value.
   1043 
   1044 <P>
   1045 <code>
   1046 See:
   1047 <a href=dpansa3.htm#A.3.2.6>A.3.2.6</a> Environmental queries,
   1048 <a href=dpans7.htm#7.3.1>7.3.1</a> Environmental queries,
   1049 <a href=dpans8.htm#8.3.1>8.3.1</a> Environmental queries,
   1050 <a href=dpans9.htm#9.3.4>9.3.4</a> Environmental queries,
   1051 <a href=dpans10.htm#10.3.2>10.3.2</a> Environmental queries,
   1052 <a href=dpans11.htm#11.3.3>11.3.3</a> Environmental queries,
   1053 <a href=dpans12.htm#12.3.4>12.3.4</a> Environmental queries,
   1054 <a href=dpans13.htm#13.3.2>13.3.2</a> Environmental queries,
   1055 <a href=dpans14.htm#14.3.2>14.3.2</a> Environmental queries,
   1056 <a href=dpans15.htm#15.3.1>15.3.1</a> Environmental queries,
   1057 <a href=dpans16.htm#16.3.2>16.3.2</a> Environmental queries,
   1058 <a href=dpans17.htm#17.3>17.3</a> Additional usage requirements.
   1059 </code>
   1060 <p>
   1061 
   1062 <hr>
   1063 <A name=3.3>
   1064 <H2>3.3 The Forth dictionary</H2>
   1065 </a>
   1066 
   1067 Forth words are organized into a structure called the dictionary.  While
   1068 the form of this structure is not specified by the Standard, it can be
   1069 described as consisting of three logical parts: a name space, a code
   1070 space, and a data space.  The logical separation of these parts does not
   1071 require their physical separation.
   1072 
   1073 <P>
   1074 
   1075 A program shall not fetch from or store into locations outside data
   1076 space.  An ambiguous condition exists if a program addresses name space
   1077 or code space.
   1078 
   1079 <P>
   1080 <code>
   1081 See:
   1082 <a href=dpansa3.htm#A.3.3>A.3.3</a> The Forth dictionary
   1083 </code>
   1084 <p>
   1085 
   1086 <hr>
   1087 <A name=3.3.1>
   1088 <H3>3.3.1 Name space</H3>
   1089 </a>
   1090 
   1091 The relationship between name space and data space is implementation
   1092 dependent.
   1093 
   1094 <P>
   1095 
   1096 <hr>
   1097 <A name=3.3.1.1>
   1098 <H4>3.3.1.1 Word lists</H4>
   1099 </a>
   1100 
   1101 The structure of a word list is implementation dependent.  When
   1102 duplicate names exist in a word list, the latest-defined duplicate shall
   1103 be the one found during a search for the name.
   1104 
   1105 <P>
   1106 
   1107 <hr>
   1108 <A name=3.3.1.2>
   1109 <H4>3.3.1.2 Definition names</H4>
   1110 </a>
   1111 
   1112 Definition names shall contain {1..31} characters.  A system may allow
   1113 or prohibit the creation of definition names containing non-standard
   1114 characters.
   1115 
   1116 <P>
   1117 
   1118 Programs that use lower case for standard definition names or depend on
   1119 the case-sensitivity properties of a system have an environmental
   1120 dependency.
   1121 
   1122 <P>
   1123 
   1124 A program shall not create definition names containing non-graphic
   1125 characters.
   1126 
   1127 <P>
   1128 <code>
   1129 See:
   1130 <a href=dpansa3.htm#A.3.3.1.2>A.3.3.1.2</a> Definition names
   1131 </code>
   1132 <p>
   1133 
   1134 <hr>
   1135 <A name=3.3.2>
   1136 <H3>3.3.2 Code space</H3>
   1137 </a>
   1138 
   1139 The relationship between code space and data space is implementation
   1140 dependent.
   1141 
   1142 <P>
   1143 
   1144 <hr>
   1145 <A name=3.3.3>
   1146 <H3>3.3.3 Data space</H3>
   1147 </a>
   1148 
   1149 Data space is the only logical area of the dictionary for which standard
   1150 words are provided to allocate and access regions of memory.  These
   1151 regions are: contiguous regions, variables, text-literal regions, input
   1152 buffers, and other transient regions, each of which is described in the
   1153 following sections.  A program may read from or write into these regions
   1154 unless otherwise specified.
   1155 
   1156 <P>
   1157 <code>
   1158 See:
   1159 <a href=dpansa3.htm#A.3.3.3>A.3.3.3</a> Data space
   1160 </code>
   1161 <p>
   1162 
   1163 <hr>
   1164 <A name=3.3.3.1>
   1165 <H4>3.3.3.1 Address alignment</H4>
   1166 </a>
   1167 
   1168 Most addresses used in ANS Forth are aligned addresses (indicated by
   1169 a-addr) or character-aligned (indicated by c-addr).  
   1170 <a href=dpans6.htm#6.1.0706>ALIGNED</a>, 
   1171 <a href=dpans6.htm#6.1.0897>CHAR+</a>, and
   1172 arithmetic operations can alter the alignment state of an address on the
   1173 stack.  CHAR+ applied to an aligned address returns a character-aligned
   1174 address that can only be used to access characters.  Applying CHAR+ to a
   1175 character-aligned address produces the succeeding character-aligned
   1176 address.  Adding or subtracting an arbitrary number to an address can
   1177 produce an unaligned address that shall not be used to fetch or store
   1178 anything.  The only way to find the next aligned address is with
   1179 ALIGNED.  An ambiguous condition exists when 
   1180 <a href=dpans6.htm#6.1.0650>@</a>, 
   1181 <a href=dpans6.htm#6.1.0010>!</a>, , 
   1182 (<a href=dpans6.htm#6.1.0150>comma</a>), 
   1183 <a href=dpans6.htm#6.1.0130>+!</a>, 
   1184 <a href=dpans6.htm#6.1.0350>2@</a>, or
   1185 <a href=dpans6.htm#6.1.0310>2!</a> 
   1186 is used with an address that is not aligned, or when 
   1187 <a href=dpans6.htm#6.1.0870>C@</a>, 
   1188 <a href=dpans6.htm#6.1.0850>C!</a>, or 
   1189 <a href=dpans6.htm#6.1.0860>C,</a> is
   1190 used with an address that is not character-aligned.
   1191 
   1192 <P>
   1193 
   1194 The definitions of 
   1195 <a href=dpans6.htm#6.1.1000>6.1.1000</a> CREATE and 
   1196 <a href=dpans6.htm#6.1.2410>6.1.2410</a> VARIABLE require that
   1197 the definitions created by them return aligned addresses.
   1198 
   1199 <P>
   1200 
   1201 After definitions are compiled or the word 
   1202 <a href=dpans6.htm#6.1.0705>ALIGN</a> 
   1203 is executed the
   1204 data-space pointer is guaranteed to be aligned.
   1205 
   1206 <P>
   1207 <code>
   1208 See:
   1209 <a href=dpansa3.htm#A.3.3.3.1>A.3.3.3.1</a> Address alignment
   1210 </code>
   1211 <p>
   1212 
   1213 <hr>
   1214 <A name=3.3.3.2>
   1215 <H4>3.3.3.2 Contiguous regions</H4>
   1216 </a>
   1217 
   1218 A system guarantees that a region of data space allocated using 
   1219 <a href=dpans6.htm#6.1.0710>ALLOT</a>, ,
   1220 (<a href=dpans6.htm#6.1.0150>comma)</a>, C, 
   1221 (<a href=dpans6.htm#6.1.0860>c-comma</a>), and 
   1222 <a href=dpans6.htm#6.1.0705>ALIGN</a> 
   1223 shall be contiguous with the last
   1224 region allocated with one of the above words, unless the restrictions in
   1225 the following paragraphs apply.  The data-space pointer 
   1226 <a href=dpans6.htm#6.1.1650>HERE</a> 
   1227 always
   1228 identifies the beginning of the next data-space region to be allocated.
   1229 As successive allocations are made, the data-space pointer increases.  A
   1230 program may perform address arithmetic within contiguously allocated
   1231 regions.  The last region of data space allocated using the above
   1232 operators may be released by allocating a corresponding negatively-sized
   1233 region using ALLOT, subject to the restrictions of the following
   1234 paragraphs.
   1235 
   1236 <P>
   1237 
   1238 <a href=dpans6.htm#6.1.1000>CREATE</a> 
   1239 establishes the beginning of a contiguous region of data space,
   1240 whose starting address is returned by the CREATEd definition.  This
   1241 region is terminated by compiling the next definition.
   1242 
   1243 <P>
   1244 
   1245 Since an implementation is free to allocate data space for use by code,
   1246 the above operators need not produce contiguous regions of data space if
   1247 definitions are added to or removed from the dictionary between
   1248 allocations.  An ambiguous condition exists if deallocated memory
   1249 contains definitions.
   1250 
   1251 <P>
   1252 <code>
   1253 See:
   1254 <a href=dpansa3.htm#A.3.3.3.2>A.3.3.3.2</a> Contiguous regions
   1255 </code>
   1256 <p>
   1257 
   1258 <hr>
   1259 <A name=3.3.3.3>
   1260 <H4>3.3.3.3 Variables</H4>
   1261 </a>
   1262 
   1263 The region allocated for a variable may be non-contiguous with regions
   1264 subsequently allocated with , 
   1265 (<a href=dpans6.htm#6.1.0150>comma</a>) or 
   1266 <a href=dpans6.htm#6.1.0710>ALLOT</a>.  
   1267 For example, in:
   1268 
   1269 
   1270 <PRE>
   1271         VARIABLE X  1 CELLS ALLOT
   1272 </PRE>
   1273 <P>
   1274 
   1275 the region X and the region
   1276 ALLOTted could be non-contiguous.
   1277 
   1278 <P>
   1279 
   1280 Some system-provided variables, such as 
   1281 <a href=dpans6.htm#6.1.2250>STATE</a>, 
   1282 are restricted to read-only
   1283 access.
   1284 
   1285 <P>
   1286 
   1287 <hr>
   1288 <A name=3.3.3.4>
   1289 <H4>3.3.3.4 Text-literal regions</H4>
   1290 </a>
   1291 
   1292 The text-literal regions, specified by strings compiled with 
   1293 <a href=dpans6.htm#6.1.2165>S"</a> and 
   1294 <a href=dpans6.htm#6.2.0855>C"</a>,
   1295 may be read-only.
   1296 
   1297 <P>
   1298 
   1299 A program shall not store into the text-literal regions created by S"
   1300 and C" nor into any read-only system variable or read-only transient
   1301 regions.  An ambiguous condition exists when a program attempts to store
   1302 into read-only regions.
   1303 
   1304 <P>
   1305 
   1306 <hr>
   1307 <A name=3.3.3.5>
   1308 <H4>3.3.3.5 Input buffers</H4>
   1309 </a>
   1310 
   1311 The address, length, and content of the input buffer may be transient.
   1312 A program shall not write into the input buffer.  In the absence of any
   1313 optional word sets providing alternative input sources, the input buffer
   1314 is either the terminal-input buffer, used by 
   1315 <a href=dpans6.htm#6.1.2050>QUIT</a> to hold one line from
   1316 the user input device, or a buffer specified by 
   1317 <a href=dpans6.htm#6.1.1360>EVALUATE</a>.  In all cases,
   1318 <a href=dpans6.htm#6.1.2216>SOURCE</a> returns the beginning 
   1319 address and length in characters of the
   1320 current input buffer.
   1321 
   1322 <P>
   1323 
   1324 The minimum size of the terminal-input
   1325 buffer shall be 80 characters.
   1326 
   1327 <P>
   1328 
   1329 The address and length returned by SOURCE, the string returned by 
   1330 <a href=dpans6.htm#6.2.2008>PARSE</a>,
   1331 and directly computed input-buffer addresses are valid only until the
   1332 text interpreter does I/O to refill the input buffer or the input source
   1333 is changed.
   1334 
   1335 <P>
   1336 
   1337 A program may modify the size of the parse area by changing the contents
   1338 of 
   1339 <a href=dpans6.htm#6.1.0560>&gt;IN</a> 
   1340 within the limits imposed by this Standard.  For example, if the
   1341 contents of &gt;IN are saved before a parsing operation and restored
   1342 afterwards, the text that was parsed will be available again for
   1343 subsequent parsing operations.  The extent of permissible repositioning
   1344 using this method depends on the input 
   1345 source (see <a href=dpans7.htm#7.3.3>7.3.3</a> Block buffer
   1346 regions and <a href=dpans11.htm#11.3.4>11.3.4</a> Input source).
   1347 
   1348 <P>
   1349 
   1350 A program may directly examine the input buffer using its address and
   1351 length as returned by SOURCE; the beginning of the parse area within the
   1352 input buffer is indexed by the number in >IN.  The values are valid for
   1353 a limited time.  An ambiguous condition exists if a program modifies the
   1354 contents of the input buffer.
   1355 
   1356 <p>
   1357 <code>
   1358 See:
   1359 <a href=a0006.htm>RFI 0006</a> Writing to Input Buffers
   1360 </code>
   1361 <p>
   1362 
   1363 <hr>
   1364 <A name=3.3.3.6>
   1365 <H4>3.3.3.6 Other transient regions</H4>
   1366 </a>
   1367 
   1368 The data space regions identified by 
   1369 <a href=dpans6.htm#6.2.2000>PAD</a>, 
   1370 <a href=dpans6.htm#6.1.2450>WORD</a>, and 
   1371 <a href=dpans6.htm#6.1.0040>#&gt;</a> 
   1372 (the pictured
   1373 numeric output string buffer) may be transient.  Their addresses and
   1374 contents may become invalid after:
   1375 
   1376 <UL>
   1377 <LI>a definition is created via a defining word;
   1378 <LI>definitions are compiled with 
   1379 : or 
   1380 :NONAME;
   1381 <LI>data space is allocated using 
   1382 <a href=dpans6.htm#6.1.0710>ALLOT</a>, , 
   1383 (<a href=dpans6.htm#6.1.0150>comma</a>),
   1384 C, 
   1385 (<a href=dpans6.htm#6.1.0860>c-comma</a>), or 
   1386 <a href=dpans6.htm#6.1.0705>ALIGN</a>.
   1387 </UL>
   1388 <P>
   1389 
   1390 The previous contents of the regions identified by WORD and #&gt; may be
   1391 invalid after each use of these words.  Further, the regions returned by
   1392 WORD and #&gt; may overlap in memory.  Consequently, use of one of these
   1393 words can corrupt a region returned earlier by a different word.  The
   1394 other words that construct pictured numeric output strings 
   1395 (<a href=dpans6.htm#6.1.0490>&lt;#</a>, 
   1396 <a href=dpans6.htm#6.1.0030>#</a>, 
   1397 <a href=dpans6.htm#6.1.0050>#S</a>,
   1398 and 
   1399 <a href=dpans6.htm#6.1.1670>HOLD</a>) 
   1400 may also modify the contents of these regions.  Words that
   1401 display numbers may be implemented using pictured numeric output words.
   1402 Consequently, .  
   1403 (<a href=dpans6.htm#6.1.0180>dot</a>), 
   1404 <a href=dpans6.htm#6.2.0210>.R</a>, 
   1405 <a href=dpans15.htm#15.6.1.0220>.S</a>, 
   1406 <a href=dpans15.htm#15.6.1.0600>?</a>, 
   1407 <a href=dpans8.htm#8.6.1.1060>D.</a>, 
   1408 <a href=dpans8.htm#8.6.1.1070>D.R</a>, 
   1409 <a href=dpans6.htm#6.1.2320>U.</a>, and 
   1410 <a href=dpans6.htm#6.2.2330>U.R</a> 
   1411 could also
   1412 corrupt the regions.
   1413 
   1414 <P>
   1415 
   1416 The size of the scratch area whose address is returned by PAD shall be
   1417 at least 84 characters.  The contents of the region addressed by PAD are
   1418 intended to be under the complete control of the user: no words defined
   1419 in this Standard place anything in the region, although changing
   1420 data-space allocations as described in 
   1421 <a href=dpans3.htm#3.3.3.2>3.3.3.2</a> Contiguous regions may
   1422 change the address returned by PAD.  Non-standard words provided by an
   1423 implementation may use PAD, but such use shall be documented.
   1424 
   1425 <P>
   1426 
   1427 The size of the region identified by WORD shall be at least 33
   1428 characters.
   1429 
   1430 <P>
   1431 
   1432 The size of the pictured numeric output string buffer shall be at least
   1433 (2*n) + 2 characters, where n is the number of bits in a cell.  Programs
   1434 that consider it a fixed area with unchanging access parameters have an
   1435 environmental dependency.
   1436 
   1437 <p>
   1438 <code>
   1439 See:
   1440 <a href=dpansa3.htm#A.3.3.3.6>A.3.3.3.6</a> Other transient regions,
   1441 <a href=dpans11.htm#11.3.5>11.3.5</a> Other transient regions.
   1442 </code>
   1443 <p>
   1444 
   1445 <hr>
   1446 <a name=3.4>
   1447 <H2>3.4 The Forth text interpreter</H2>
   1448 </a>
   1449 
   1450 Upon start-up, a system shall be able to interpret, as described by
   1451 <a href=dpans6.htm#6.1.2050>6.1.2050</a> QUIT, Forth source code 
   1452 received interactively from a user
   1453 input device.
   1454 
   1455 <P>
   1456 
   1457 Such interactive systems usually furnish a <B>prompt</B> indicating that
   1458 they have accepted a user request and acted on it.  The
   1459 implementation-defined Forth prompt should contain the word <B>OK</B> in
   1460 some combination of upper or lower case.
   1461 
   1462 <P>
   1463 
   1464 Text interpretation (see 
   1465 <a href=dpans6.htm#6.1.1360>6.1.1360</a> EVALUATE and 
   1466 <a href=dpans6.htm#6.1.2050>6.1.2050</a> QUIT) shall
   1467 repeat the following steps until either the parse area is empty or an
   1468 ambiguous condition exists:
   1469 
   1470 <p>
   1471 a) Skip leading spaces and parse a name (see 
   1472 <a href=dpans3.htm#3.4.1>3.4.1</a>);
   1473 <p>
   1474 b) Search the dictionary name space (see 
   1475 <a href=dpans3.htm#3.4.2>3.4.2</a>). If a definition name
   1476 matching the string is found:
   1477 <OL>
   1478 <LI>if interpreting, perform the interpretation semantics of the
   1479 definition (see 
   1480 <a href=dpans3.htm#3.4.3.2>3.4.3.2</a>), and continue at a);
   1481 <LI>if compiling, perform the compilation semantics of the definition (see
   1482 <a href=dpans3.htm#3.4.3.3>3.4.3.3</a>), and continue at a).
   1483 </ol>
   1484 <p>
   1485 c) If a definition name matching the string is not found, attempt to
   1486 convert the string to a number (see 
   1487 <a href=dpans3.htm#3.4.1.3>3.4.1.3</a>). If successful:
   1488 <ol>
   1489 <LI>if interpreting, place the number on the data stack, and continue at a);
   1490 <LI>if compiling, compile code that when executed will place the number on
   1491 the stack (see 
   1492 <a href=dpans6.htm#6.1.1780>6.1.1780</a> LITERAL), and continue at a);
   1493 </ol>
   1494 <p>
   1495 d) If unsuccessful, an ambiguous condition exists (see 
   1496 <a href=dpans3.htm#3.4.4>3.4.4</a>).
   1497 
   1498 <P>
   1499 
   1500 
   1501 <hr>
   1502 <A name=3.4.1>
   1503 <H3>3.4.1 Parsing</H3>
   1504 </a>
   1505 
   1506 Unless otherwise noted, the number of characters parsed may be from zero
   1507 to the implementation-defined maximum length of a counted string.
   1508 
   1509 <P>
   1510 
   1511 If the parse area is empty, i.e., when the number in 
   1512 <a href=dpans6.htm#6.1.0560>&gt;IN</a> 
   1513 is equal to the
   1514 length of the input buffer, or contains no characters other than
   1515 delimiters, the selected string is empty.  Otherwise, the selected
   1516 string begins with the next character in the parse area, which is the
   1517 character indexed by the contents of &gt;IN.  An ambiguous condition exists
   1518 if the number in &gt;IN is greater than the size of the input buffer.
   1519 
   1520 <P>
   1521 
   1522 If delimiter characters are present in the parse area after the
   1523 beginning of the selected string, the string continues up to and
   1524 including the character just before the first such delimiter, and the
   1525 number in &gt;IN is changed to index immediately past that delimiter, thus
   1526 removing the parsed characters and the delimiter from the parse area.
   1527 Otherwise, the string continues up to and including the last character
   1528 in the parse area, and the number in &gt;IN is changed to the length of the
   1529 input buffer, thus emptying the parse area.
   1530 
   1531 <P>
   1532 
   1533 Parsing may change the contents of &gt;IN, but shall not affect the
   1534 contents of the input buffer.  Specifically, if the value in &gt;IN is
   1535 saved before starting the parse, resetting &gt;IN to that value immediately
   1536 after the parse shall restore the parse area without loss of data.
   1537 
   1538 <P>
   1539 
   1540 <hr>
   1541 <A name=3.4.1.1>
   1542 <H4>3.4.1.1 Delimiters</H4>
   1543 </a>
   1544 
   1545 If the delimiter is the space character, hex 20 
   1546 (<a href=dpans6.htm#6.1.0770>BL</a>), 
   1547 control characters
   1548 may be treated as delimiters.  The set of conditions, if any, under
   1549 which a <B>space</B> delimiter matches control characters is
   1550 implementation defined.
   1551 
   1552 <P>
   1553 
   1554 To skip leading delimiters is to pass by zero or more contiguous
   1555 delimiters in the parse area before parsing.
   1556 
   1557 <P>
   1558 
   1559 <hr>
   1560 <A name=3.4.1.2>
   1561 <H4>3.4.1.2 Syntax</H4>
   1562 </a>
   1563 
   1564 Forth has a simple, operator-ordered syntax.  The phrase A B C returns
   1565 values as if A were executed first, then B and finally C.  Words that
   1566 cause deviations from this linear flow of control are called
   1567 control-flow words.  Combinations of control-flow words whose stack
   1568 effects are compatible form control-flow structures.  Examples of
   1569 typical use are given for each control-flow word in
   1570 <A href=dpansa1.htm>Annex A</A>.
   1571 
   1572 <P>
   1573 
   1574 Forth syntax is extensible; for example, new control-flow words can be
   1575 defined in terms of existing ones.
   1576 
   1577 <P>
   1578 
   1579 This Standard does not require a
   1580 syntax or program-construct checker.
   1581 
   1582 <P>
   1583 
   1584 <hr>
   1585 <A name=3.4.1.3>
   1586 <H4>3.4.1.3 Text interpreter input number conversion</H4>
   1587 </a>
   1588 
   1589 When converting input numbers, the text interpreter shall recognize both
   1590 positive and negative numbers, with a negative number represented by a
   1591 single minus sign, the character <B>-</B>, preceding the digits.  The
   1592 value in 
   1593 <a href=dpans6.htm#6.1.0750>BASE</a> 
   1594 is the radix for number conversion.
   1595 
   1596 <P>
   1597 
   1598 <hr>
   1599 <A name=3.4.2>
   1600 <H3>3.4.2 Finding definition names</H3>
   1601 </a>
   1602 
   1603 A string matches a definition name if each character in the string
   1604 matches the corresponding character in the string used as the definition
   1605 name when the definition was created.  The case sensitivity (whether or
   1606 not the upper-case letters match the lower-case letters) is
   1607 implementation defined.  A system may be either case sensitive, treating
   1608 upper- and lower-case letters as different and not matching, or case
   1609 insensitive, ignoring differences in case while searching.
   1610 
   1611 <P>
   1612 
   1613 The matching of upper- and lower-case letters with alphabetic characters
   1614 in character set extensions such as accented international characters is
   1615 implementation defined.
   1616 
   1617 <P>
   1618 
   1619 A system shall be capable of finding the definition names defined by
   1620 this Standard when they are spelled with upper-case letters.
   1621 
   1622 <P>
   1623 
   1624 <hr>
   1625 <A name=3.4.3>
   1626 <H3>3.4.3 Semantics</H3>
   1627 </a>
   1628 
   1629 The semantics of a Forth definition are implemented by machine code or a
   1630 sequence of execution tokens or other representations.  They are largely
   1631 specified by the stack notation in the glossary entries, which shows
   1632 what values shall be consumed and produced.  The prose in each glossary
   1633 entry further specifies the definition's behavior.
   1634 
   1635 <P>
   1636 
   1637 Each Forth definition may have several behaviors, described in the
   1638 following sections.  The terms <B>initiation semantics</B> and
   1639 <B>run-time semantics</B> refer to definition fragments, and have
   1640 meaning only within the individual glossary entries where they appear.
   1641 
   1642 <P>
   1643 <code>
   1644 See:
   1645 <a href=dpansa3.htm#A.3.4.3>A.3.4.3</a> Semantics,
   1646 <a href=a0005.htm>RFI 0005</a>.
   1647 </code>
   1648 <p>
   1649 
   1650 <hr>
   1651 <A name=3.4.3.1>
   1652 <H4>3.4.3.1 Execution semantics</H4>
   1653 </a>
   1654 
   1655 The execution semantics of each Forth definition are specified in an
   1656 <B>Execution:</B> section of its glossary entry.  When a definition has
   1657 only one specified behavior, the label is omitted.
   1658 
   1659 <P>
   1660 
   1661 Execution may occur implicitly, when the definition into which it has
   1662 been compiled is executed, or explicitly, when its execution token is
   1663 passed to 
   1664 <a href=dpans6.htm#6.1.1370>EXECUTE</a>.  
   1665 The execution semantics of a syntactically correct
   1666 definition under conditions other than those specified in this Standard
   1667 are implementation dependent.
   1668 
   1669 <P>
   1670 
   1671 Glossary entries for defining words include the execution semantics for
   1672 the new definition in a <i>name</i> <b>Execution:</B> section.
   1673 
   1674 <P>
   1675 
   1676 <hr>
   1677 <A name=3.4.3.2>
   1678 <H4>3.4.3.2 Interpretation semantics</H4>
   1679 </a>
   1680 
   1681 Unless otherwise specified in an <B>Interpretation:</B> section of the
   1682 glossary entry, the interpretation semantics of a Forth definition are
   1683 its execution semantics.
   1684 
   1685 <P>
   1686 
   1687 A system shall be capable of executing, in interpretation state, all of
   1688 the definitions from the Core word set and any definitions included from
   1689 the optional word sets or word set extensions whose interpretation
   1690 semantics are defined by this Standard.
   1691 
   1692 <P>
   1693 
   1694 A system shall be capable of executing, in interpretation state, any new
   1695 definitions created in accordance with 
   1696 <a href=dpans3.htm#3.>3.</a>  Usage requirements.
   1697 
   1698 <P>
   1699 <code>
   1700 See:
   1701 <a href=dpansa3.htm#A.3.4.3.2>A.3.4.3.2</a> Interpretation semantics
   1702 </code>
   1703 <p>
   1704 
   1705 <hr>
   1706 <A name=3.4.3.3>
   1707 <H4>3.4.3.3 Compilation semantics</H4>
   1708 </a>
   1709 
   1710 Unless otherwise specified in a <B>Compilation:</B> section of the
   1711 glossary entry, the compilation semantics of a Forth definition shall be
   1712 to append its execution semantics to the execution semantics of the
   1713 current definition.
   1714 
   1715 <P>
   1716 <code>
   1717 See:
   1718 <a href=a0007.htm>RFI 0007</a> Distinction between <em>immediacy</em> and <em>special compilation semantics</em>.
   1719 </code>
   1720 <p>
   1721 
   1722 <hr>
   1723 <A name=3.4.4>
   1724 <H3>3.4.4 Possible actions on an ambiguous condition</H3>
   1725 </a>
   1726 
   1727 When an ambiguous condition exists, a system may take one or more of the
   1728 following actions:
   1729 
   1730 <UL>
   1731 <LI>ignore and continue;
   1732 <LI>display a message;
   1733 <LI>execute a particular word;
   1734 <LI>set interpretation state and begin text interpretation;
   1735 <LI>take other implementation-defined actions;
   1736 <LI>take implementation-dependent actions.
   1737 </UL>
   1738 <P>
   1739 
   1740 The response to a particular ambiguous condition need not be the same
   1741 under all circumstances.
   1742 
   1743 <P>
   1744 
   1745 <hr>
   1746 <A name=3.4.5>
   1747 <H3>3.4.5 Compilation</H3>
   1748 </a>
   1749 
   1750 A program shall not attempt to
   1751 nest compilation of definitions.
   1752 
   1753 <P>
   1754 
   1755 During the compilation of the current definition, a program shall not
   1756 execute any defining word, 
   1757 <a href=dpans6.htm#6.2.0455>:NONAME</a>, 
   1758 or any definition that allocates
   1759 dictionary data space.  The compilation of the current definition may be
   1760 suspended using [ 
   1761 (<a href=dpans6.htm#6.1.2500>left-bracket</a>) 
   1762 and resumed using ] 
   1763 (<a href=dpans6.htm#6.1.2540>right-bracket</a>).
   1764 While the compilation of the current definition is suspended, a program
   1765 shall not execute any defining word, :NONAME, or any definition that
   1766 allocates dictionary data space.
   1767 
   1768 <p>
   1769 <code>
   1770 See:
   1771 <a href=dpansa3.htm#A.3.4.5>A.3.4.5</a> Compilation
   1772 </code>
   1773 <p>
   1774 
   1775 <hr>
   1776 <A href=dpans.htm#toc><IMG   src="up.gif" ></A>    Table of Contents 
   1777 <BR>
   1778 <A href=dpans4.htm><IMG   src="right.gif" ></A>  Next Section
   1779 <P>
   1780 </BODY>
   1781 </HTML>