home *** CD-ROM | disk | FTP | other *** search
/ Unix System Administration Handbook 1997 October / usah_oct97.iso / rfc / 100s / rfc194.txt < prev    next >
Text File  |  1997-06-27  |  33KB  |  1,012 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                                       Vint Cerf - UCLA
  8.  
  9.                                       Eric Harslem - Rand
  10.  
  11. RFC 194                               John Heafner - Rand
  12. NIC 7139
  13. Category: D.4                         Bob Metcalfe - MIT
  14. Updates: None
  15. Obsoletes: None                       Jim White - UCSB
  16.  
  17.  
  18.                   THE DATA RECONFIGURATION SERVICE --
  19.  
  20.                COMPILER/INTERPRETER IMPLEMENTATION NOTES
  21.  
  22.  
  23.                     I.  NEW FEATURES OF THE LANGUAGE
  24.  
  25. 1.   The meaning of S(#,E,,l) is only find an arbitrary
  26.      number  (<=256) of EBCDIC characters and store them in
  27.      identifier S.  This descriptor is terminated only by
  28.      an invalid EBCDIC or by exceeding maximum permissible
  29.      character count (256).
  30. 2.   The assignment (S .<=. T) causes all attributes of
  31.      identifier T to be given to S, i.e., length, type,
  32.      and contents.
  33. 3.   (S .<=. T || X) concatenates X onto the right-hand
  34.      side of T and stores the result in S.  If T and X
  35.      are binary the resulting value has a length equal
  36.      to the sum L(T) + L(X).
  37. 4.   T(X) joins L(X) and V(X) as a built-in identifier
  38.      function.
  39.      T(X) = type of identifier X.
  40.      L(X) = length of contents of X.
  41.      V(X) = contents of X converted to binary
  42.             (decimal - binary is presently the only
  43.             transformation).
  44. 5.   New types ED and AD are EBCDIC and ASCII encoded
  45.      decimal, respectively.  These have been added to
  46.      complement the V(X) function.
  47. 6.   New type SB has been added as signed binary.  Type B
  48.      is a logical binary string.
  49. 7.   The syntactic notation for return-from-a-form has
  50.      been changed.  See new syntax.
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.                                                                 [Page 1]
  59.  
  60. Data Reconfiguration Service                                     RFC 194
  61.  
  62.  
  63. II.  NEW SYNTAX
  64.  
  65. form              :: = rule | form
  66. rule              :: = label  inputstream outputstream;
  67. label             :: = INTEGER | NULL
  68. inputstream       :: = terms | NULL
  69. terms             :: = term | terms, term
  70. outputstream      :: = :terms | NULL
  71. term              :: = identifier | identifier descriptor |
  72.                        descriptor | comparator
  73. identifier        :: = <alpha followed by 0-3 alphanumerics>
  74. descriptor        :: = (replicationexpr, datatype, valueexpr,
  75.                        lengthexpr control)
  76. comparator        :: = (concatexpr connective concatexpr control) |
  77.                        (identifier .<=. concatexpr control)
  78. replicationexpr   :: = # | arithmetricexpr | NULL
  79. datatype          :: = B | O | X | E | A | ED | AD | SB | T (identifier)
  80. valueexpr         :: = concatexpr | NULL
  81. lengthexpr        :: = arithmeticexpr | NULL
  82. connective        :: = .LE. | .LT. | .GT. | .GE. | .EQ. | .NE.
  83. concatexpr        :: = value | concatexpr    value
  84. value             :: = literal | arithmeticexpr
  85. arithmeticexpr    :: = primary | arithmeticexpr operator primary
  86. primary           :: = identifier | L(identifier) | V(identifier) |
  87.                          INTEGER
  88. operator          :: = + | - | * | /
  89. literal           :: = literaltype "string"
  90.  
  91. literaltype       :: = B | 0 | X | E | A | ED | AD | SB
  92. string            :: = <from 0 to 256 chars>
  93. control           :: = :options | NULL
  94. options           :: = SFUR (arithmeticexpr) | SFUR (arithmeticexpr),
  95.                        SFUR (arithmeticexpr)
  96. SFUR              :: = S | F | U | SR | FR | UR
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.                                                                 [Page 2]
  115.  
  116. Data Reconfiguration Service                                     RFC 194
  117.  
  118.  
  119. III.  THE FORM INTERPRETER
  120.  
  121. Interpreter Overview
  122.  
  123.      The interpreter is a simple minded machine having the virtue of
  124. helping the compiler writer by providing a rather powerful instruction
  125. set for hard-to-compile operations.  Figure 1 shows the machine
  126. configuration:
  127.  
  128.  
  129.   +-------------+                        +--------------+
  130.   | inputstream |                        | outputstream |
  131.   +-------------+                        +--------------+
  132.              /\                           /
  133.               \                          /
  134.                \                        /
  135.                 \                     \/
  136.                 +-----------------------+
  137.                 |         CPU           |
  138.                 +-----------------------+
  139.                        |        /\
  140.                        |         |
  141.                        |         |
  142.                        \/        |
  143.                 +-----------------------+
  144.     Storage:    | Instruction           |
  145.                 | Sequence              |
  146.                 +-----------------------+
  147.                 | Label Table           |
  148.                 +-----------------------+
  149.                 | Literal/Identifier    |
  150.                 | Pool                  |
  151.                 +-----------------------+
  152.                 | Variable length       |
  153.                 | string area           |
  154.                 +-----------------------+
  155.  
  156.  
  157.                 Fig. 1. Form Interpreter
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.                                                                 [Page 3]
  171.  
  172. Data Reconfiguration Service                                     RFC 194
  173.  
  174.  
  175.     The CPU is a box full of miscellaneous parts, the most important
  176. being the Arithmetic Logic Unit and the instruction decoding unit.  The
  177. CPU also maintains a collection of state registers to keep track of what
  178. it is doing.  Figure 2 shows the rough layout.
  179.  
  180.  
  181.    +-----------------+                +---------------+
  182.    | Instruction     |                | Instruction   |
  183.    | Counter         |                | Register      |
  184.    +-----------------+                +---------------+
  185.                                            |
  186.                                            |
  187.                                            V
  188.                                     +----------------+
  189.                                     | Operation Code |
  190.                                     | Decoding       |
  191.      Run Time Stack                 +----------------+
  192.    +------------------+                 /     |    \
  193.    |   Operands       |                /      |     \
  194.    +------------------+              \/       V     \/
  195.    |                  |               +-----------------+
  196.    +------------------+              /   Instruction     \
  197.    |                  |              |   Interpreter     |
  198.    +------------------+              |   Routines        |
  199.    |                  |               \                 /
  200.    +------------------+                +---------------+
  201.    |                  |                    |      /\
  202.    +------------------+                    |       |
  203.    |                  |                    |       |
  204.    +------------------+                    V       |
  205.    |                  |                +---------------+
  206.    +------------------+ <------------- | Arithmetic    |
  207.    |                  | -------------> | Logic Unit    |
  208.    +------------------+                +---------------+
  209.    |                  |
  210.    +------------------+
  211.    |                  |
  212.    +------------------+
  213.  
  214.  
  215.    +------------------+                +------------------+
  216.    |Initial Input Ptr.|                | Output pointer   |
  217.    +------------------+                +------------------+
  218.  
  219.    +------------------+                +------------------+
  220.    |Current Input Ptr.|                | True/False Flag  |
  221.    +------------------+                +------------------+
  222.  
  223.  
  224.  
  225.  
  226.                                                                 [Page 4]
  227.  
  228. Data Reconfiguration Service                                     RFC 194
  229.  
  230.  
  231. Fig.  2.  The Central Processor
  232.  
  233.      The CPU is a stack machine driven by a Polish postfix instruction
  234. sequence.  Operands placed on the Run Time Stack are used for arithmetic
  235. expression evaluation and for parameter passing between the interpreter
  236. and the built-in functions.
  237.      The Current Input Pointer and the Output Pointer keep track of the
  238. two data streams.  Two input pointers are needed because of the backup
  239. requirement in the event of rule failure.  All of these pointers are bit
  240. pointers into the two streams.
  241.      Various implementations of the Run Time Stack are independent of
  242. the interpretation of the DRS machine's instruction set.  It is
  243. suggested that the stack will contain instruction operands from the
  244. instruction stream.
  245.      The format of a compiled instruction sequence for a form is shown
  246. in Fig. 3.
  247.  
  248.                         16 bits
  249.                  +--------/\---------+
  250.                 /                     \
  251.  
  252.                 +---------------------+
  253.                 |  length n in bytes  |
  254.            +--  +---------------------+
  255.            |    |                     |
  256.            |    |     compiled        |
  257.            |    |     16-bit          |
  258.         n <     |     instructions    |
  259.            |    |                     |
  260.            |    |                     |
  261.            |    |                     |
  262.            +--  +---------------------+
  263.  
  264.  
  265.        Fig. 3.  Compiled Instruction Sequence Format
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.                                                                 [Page 5]
  283.  
  284. Data Reconfiguration Service                                     RFC 194
  285.  
  286.  
  287.    The format of the compiled Label Table is shown in Fig. 4.
  288.  
  289.                                        16 bits
  290.                                   +-----/\-------+
  291.                                  /                \
  292.  
  293.                                  +-----------------+
  294.                                  |  length n       |
  295.                                  |  in bytes       |
  296.         +--   +------------------+-----------------+
  297.         |     | numeric value of |  byte offset    |
  298.         |     | statement number |  in inst. seq.  |
  299.         |     +------------------+-----------------+
  300.         |     |        :                :          |
  301.      n <      |        :                :          |
  302.         |     |        :                :          |
  303.         |     |                                    |
  304.         |     |                                    |
  305.         |     |                                    |
  306.         +--   +------------------------------------+
  307.  
  308.               \_________________ _________________/
  309.                                 V
  310.                               32 bits
  311.  
  312.  
  313.                     Fig. 4.  Compiled Label Table
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.                                                                 [Page 6]
  339.  
  340. Data Reconfiguration Service                                     RFC 194
  341.  
  342.  
  343.    Literals and Identifiers are compiled as shown in fig. 5.
  344.  
  345.                                    2              2
  346.                               +----/\----+   +----/\----+
  347.                              /            \ /            \
  348.  
  349.                              +-------------+--------------+
  350.             1         1      | length n    |    length n  |
  351.          ___/\____ ___/\____ | in bytes    |    in bytes  |
  352.         +---------+----------+-------------+--------------+
  353.      /  |         |//////////|             |              |
  354.      |  | Type    |//////////| bit length  |  byte offset |
  355.      |  |         |//////////|             |              |
  356.      |  +---------+----------+-------------+--------------+
  357. 5*n <   |                           :                     |
  358.      |  |                           :                     |
  359.      |  |                           :                     | Identifiers
  360.      |  |                                                 |
  361.      \  |                                                 |
  362.         +-------------------------------------------------+
  363.      /  |                                                 |
  364.      |  |            literals are                         |
  365.      |  |            byte-aligned                         | Literals
  366.   m <   |                                                 |
  367.      |  |                                                 |
  368.      |  |                                                 |
  369.      \  +-------------------------------------------------+
  370.  
  371.      Legend:
  372.  
  373.      Type 0 = undefined
  374.           1 = B (binary)
  375.           2 = 0 (octal)
  376.           3 = X (hexadecimal)
  377.           4 = E (EBCDIC)
  378.           5 = A (ASCII)
  379.           6 = ED (EBCDIC encoded decimal)
  380.           7 = AD (ASCII encoded decimal)
  381.           8 = SB (signed binary, two's complement)
  382.  
  383.  
  384.              Fig. 5.  Compiled Literals and Identifiers
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.                                                                 [Page 7]
  395.  
  396. Data Reconfiguration Service                                     RFC 194
  397.  
  398.  
  399.    Types B, 0, X, AD, ED, and SB point to 32-bit word- aligned data
  400.    shown below.
  401.  
  402.  +---+---+-----+-------+       +-------------------+    word-aligned,
  403.  | T |///|  L  |    ---+-----> |                   |    32-bit right-
  404.  +---+---+-----+-------+       +-------------------+    justified
  405.  
  406.  
  407.       Types E and A point to byte-aligned symbol streams
  408. as shown below.
  409.  
  410.                                  byte-aligned, L <= 256
  411.  +---+---+-----+-------+       +------------------------+
  412.  | T |///|  L  |    ---+-----> |                        |
  413.  +---+---+-----+-------+       +------------------------+
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.                                                                 [Page 8]
  451.  
  452. Data Reconfiguration Service                                     RFC 194
  453.  
  454.  
  455. Instruction Format
  456.  
  457.      Since literals and identifiers will be stored in the same data
  458. area, more than 256 literals plus identifiers might be encountered so
  459. more than 8 bits are needed to reference literal/id pool.  Furthermore,
  460. such references must be distinguished from operators in the instruction
  461. stream, so a 16-bit instruction will be used, as shown below.
  462.  
  463.      +--------+------------------------+
  464.      |    4   |          12            |
  465.      +--------+------------------------+
  466.          |
  467.         /
  468.        /
  469.       /
  470.      |
  471.      V
  472.      LD = 0  literal or identifier reference (12-bit positive integer)
  473.      IC = 1  12-bit two's complement integer constant
  474.      OP = 2  operator
  475.      AD = 3  address (12-bit positive integer)
  476.     ARB = 4  indefinite replication factor
  477.    NULL = 5  missing attribute of term
  478.  
  479.      The operation code decoder picks up types 0, 1, 3, 4,
  480. and 5 and deposits them on top of the stack (TOS).  LD is an
  481. index into the literal/identifier table, and AD is an index
  482. into the instruction sequence.
  483.  
  484.      The decoder examines OP elements further:
  485.  
  486.  
  487.          4        4            8
  488.      +--------+--------+----------------+
  489.      |  0010  |        |////////////////|
  490.      +--------+--------+----------------+
  491.         OP        |
  492.                   +----------> 0 = binary operator
  493.                                1 = unary operator
  494.                                2 = special operator
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.                                                                 [Page 9]
  507.  
  508. Data Reconfiguration Service                                     RFC 194
  509.  
  510.  
  511. Binary Operators (*)
  512.  
  513.      Let the TOS contain y and the next level, x.  The binary operators
  514. compute x  <bop> y, popping both x, y from stack, and put the result
  515. back on top of the stack.
  516.  
  517.                      +---+ <-- TOS  +-----+ <-- TOS
  518.                      | y |          | x-y |
  519.      e.g.     x-y => +---+     ===> +-----+
  520.                      | x |          |/////|
  521.                      +---+          +-----+
  522.  
  523.  
  524. Binary Operator Encoding
  525.  
  526.                      4        4        4        4
  527.                 +--------+--------+--------+--------+
  528.                 |  0010  |  0000  |        |////////|
  529.                 +--------+--------+--------+--------+
  530.                                        |
  531.             +--------------------------+
  532.             |
  533.             V
  534.      0 = integer +
  535.      1 = integer -
  536.      2 = integer x
  537.      3 = integer : (or /), no remainder
  538.      4 = concatenate ||
  539.  
  540.      All binary operations except concatenate expect the top
  541. two elements on the stack to describe type B, 0, X, or SB.  The
  542. result is always a 32-bit type B element.  The concatenate
  543. operator fails unless both types are identical.  For example:
  544.  
  545.  
  546. -------
  547.      (*) As suggested above, the stack really contains instruction
  548. operands that describe data; for convenience in illustrations
  549. the data rather than their descriptors are shown on the stack.
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.                                                                [Page 10]
  563.  
  564. Data Reconfiguration Service                                     RFC 194
  565.  
  566.  
  567.         type     L    value             T       L     V
  568.        +------+------+------+        +------+------+------+
  569. TOS -> |  B   |  32  |  4   |        |  B   |  32  |  12  | <- TOS
  570.        +------+------+------+   ==>  +------+------+------+
  571.        |  B   |  8   |  16  |        |//////|//////|//////|
  572.        +------+------+------+        +------+------+------+
  573.        Before-operation                after-operation
  574.  
  575.  
  576.  
  577.        +------+------+------+        +------+------+------+
  578. TOS -> |  A   |  2   |  DE  |        |  A   |  5   |ABCDE | <- TOS
  579.        +------+------+------+   ==>  +------+------+------+
  580.        |  A   |  3   | ABC  |        |//////|//////|//////|
  581.        +------+------+------+        +------+------+------+
  582.        Before || operation             after || operation
  583.  
  584.  
  585. No binary operator has any effect on the TRUE/FALSE flag.
  586.  
  587.  
  588. Unary Operators
  589.  
  590.          4        4        4        4
  591.      +--------+--------+--------+--------+
  592.      |  0010  |  0001  |        |        |
  593.      +--------+--------+--------+--------+
  594.                           |         |
  595.            +--------------+         |
  596.            |                        |
  597.            V                        |
  598.     0 = integer minus               V
  599.     1 = load identifier          0 = evaluated contents
  600.                                      (after dec - binary
  601.                                       conversion)
  602.                                  1 = length field
  603.                                  2 = type field
  604.     2 = Label Table Reference
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616.  
  617.  
  618.                                                                [Page 11]
  619.  
  620. Data Reconfiguration Service                                     RFC 194
  621.  
  622.  
  623.      For the unary minus operator the data described by the top of the
  624. stack is replaced with its 2's complement.  The form fails if the TOS
  625. type is not SB, B, 0, or X.
  626.      The Load identifier expects the TOS to describe an index into the
  627. literal/identifier pool (that is, an LD instruction) .  The TOS
  628. described data is replaced by 32-bit type B values.  The operation fails
  629. if the contents cannot be converted from encoded decimal to binary.  B,
  630. 0, and X types are treated as unsigned integers, SB is treated as 2's
  631. complement.
  632.      The Label Table Reference operator expects a 32-bit type B value
  633. described by TOS and searches for this label in the label Table.  If
  634. found, the TOS described data is replaced by the relative address in the
  635. instruction sequence of the label (in the form of an AD instruction).
  636. If not found, the form fails.  No Unary operator has any effect on the
  637. TRUE/FALSE flag.
  638.  
  639.  
  640. Special Operators
  641.  
  642.                 4        4        4        4
  643.             +--------+--------+--------+--------+
  644.             |  0010  |  0010  |        |        |
  645.             +--------+--------+--------+--------+
  646.                                  |         |
  647.          +-----------------------+        /
  648.          |                               /
  649.          V                              /
  650.    0 = store TOS                        |
  651.    1 = return                           V
  652.    2 = branch               0 = true, 1 = false, 2 = unconditional
  653.  
  654.    3 = compare              0 = .EQ.  2 = .LE.   4 = .GE.
  655.                             1 = .NE.  3 = .LT.   5 = .GT.
  656.  
  657.    4 = move input ptr       0 = store current into initial
  658.                             1 = store initial into current
  659.  
  660.    5 = input call           0 = no compare
  661.                             1 = compare
  662.  
  663.    6 = output call
  664.  
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.                                                                [Page 12]
  675.  
  676. Data Reconfiguration Service                                     RFC 194
  677.  
  678.  
  679. Store TOS
  680.  
  681.     The TOS describes an index into the ID table and the next lower
  682. element in the stack describes a value to be stored.  After execution,
  683. both elements are popped off the stack.
  684.  
  685. Return
  686.  
  687.      The TOS describes a value to be returned to the routine which
  688. initiated the FORM MACHINE.  The actual mechanism will be implementation
  689. dependent, but the FORM MACHINE will relin- quish control after this
  690. instruction completes execution.
  691.  
  692. Branch
  693.  
  694.      The TOS describes an index into the instruction sequence to be used
  695. as the new instruction counter (IC) if the branch conditions are
  696. satisfied.  The branch instruction checks the state of the TRUE/FALSE
  697. flag register and either increments the IC by 1 or replaces it with the
  698. TOS described element.  In any case, the TOS is popped.
  699.  
  700. Compare
  701.  
  702.      The compare operator takes the two elements described by the two
  703. top stack entries and compares them (.EQ.,.LT.,etc.).  If n is at the
  704. top of the stack, and m is just below, then m.xx.n is performed, and the
  705. TRUE/False flag is set accordingly.  For .xx. = .EQ. or .NE. we must
  706. have identical type, length, and content for equality to hold.
  707.      The other boolean comparators will not be attempted if types are
  708. different (i.e., form fails), but for same types, B, 0, X cause binary-
  709. justified compares, and A, E, AD, ED cause left-justified string
  710. compares with the shorter string padded with blanks.
  711.  
  712. Move Input Pointer
  713.  
  714.      This operator (no operands) replaces the Current Input Pointer with
  715. the Initial Input Pointer (back-up), or the Initial Input Pointer with
  716. the current one (entry to rule).
  717.  
  718. Input Call
  719.  
  720.     This is the most complex operator thus far encountered.  It requires
  721. four operands from the run-time stack:
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.                                                                [Page 13]
  731.  
  732. Data Reconfiguration Service                                     RFC 194
  733.  
  734.  
  735. TOS  +----------------------------+
  736.      | binary or null             |  length to find
  737.      +----------------------------+
  738.      | LD to literal or null      |  value (literal)
  739.      +----------------------------+
  740.      | binary code                |  input data type
  741.      +----------------------------+
  742.      | binary, arbitrary, or null |  replication count
  743.      +----------------------------+
  744.  
  745.      The input call operator can be invoked with the "no compare" flag
  746. set, in which case the value expression parameter is ignored and only
  747. the input type and length expressions are used.  In this case, the input
  748. routine tries to find in the input stream as many characters of the
  749. required type (bits, digits, etc.) as needed to fill the length
  750. expression requirement.  If successful, the TRUE/FALSE flag is set TRUE,
  751. the stack is popped to remove the input parameters, and the string
  752. obtained is described by the TOS.  If the input stream cannot be matched
  753. then the parameters are popped off the stack, and the TRUE/FALSE flag is
  754. set FALSE.
  755.  
  756.      If the "compare" flag is set, the input stream must be searched for
  757. the value expression.  However, we must take some care here to be sure
  758. we know what to look for.  There are several cases:
  759.  
  760. a)  The length expression parameter is greater than the
  761.     length of the value expression but the type of input de-
  762.     sired is the same as the value expression type.  For B, 0
  763.     and X types, right-justify value expression in length-
  764.     expression field, sign bit is extended left if type BS.
  765.     If type A, E, AD, or ED pad on the right with blanks.  b)  Same as
  766. a) but length is too small.  B, 0, and X type strings
  767.     are truncated on the left.  A, E, AD and ED are truncated
  768.     on the right.  c)  The type of the value expression and the type
  769. parameter
  770.     differ.  This case is deferred for discussion and pre-
  771.     sently is considered an error causing form failure.
  772.  
  773.      If the input string matches, then the TRUE/FALSE flag is set true,
  774. the parameters are popped from the stack, and the resulting string is
  775. described by the TOS.  Otherwise, the FALSE flag is set and the
  776. parameters are popped.
  777.  
  778.      When a successful match is found the input subroutine always
  779. advances the Current Input Pointer by the appropriate amount.  Since we
  780. are dealing at the bit level this pointer must be maintained as a bit
  781. pointer!
  782.  
  783.  
  784.  
  785.  
  786.                                                                [Page 14]
  787.  
  788. Data Reconfiguration Service                                     RFC 194
  789.  
  790.  
  791. Output Call
  792.  
  793.      This routine utilizes the same parameters as the input call, but
  794. operates on the output stream.  The TRUE/FALSE flag is not distributed
  795. by this operator.  As for input, there are four parameters on top of the
  796. stack, the length expression value, the value expression value, the
  797. desired output type, and the replication expression value.  When there
  798. is a mis- match between the output type and the value expression type, a
  799. conversion must take place.  The value expression is trans- formed into
  800. the desired output type and fitted into the field length specified by
  801. the length expression.
  802.  
  803. Truncation and Padding Rules
  804.  
  805. a)  Character -> character (A,E,AD,ED -> A,E,AD,ED) conversion
  806.     is left-justified and truncated or padded with blanks
  807.     on the right.  b)  Character -> numeric and numeric -> character
  808. conversion is
  809.     right-justified and truncated or padded on the left with
  810.     zeros.  Beware!  Two's complement numbers may be bollixed
  811.     by this.  c)  Numeric -> character conversion is right-justified and
  812.     left padded with blanks or left-truncated.  As for the unary
  813. operators, a numeric bit-string is treated as unsigned, except SB which
  814. is treated as two's complement.  Thus we have:
  815.  
  816.                 (1,ED,X"FF",3) = E'255'
  817.                (1,ED,X"100",3) = E'256'
  818.      but (1,ED,SB"10000000",4) = E'-256'
  819.  
  820.      If the output routine is able to perform the desired action, it
  821. advances the Output Stream Pointer, and pops all parameters from the
  822. run-time stack.
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.                                                                [Page 15]
  843.  
  844. Data Reconfiguration Service                                     RFC 194
  845.  
  846.  
  847. V.  INSTRUCTION SET
  848.  
  849. it/id ref           LD <num>                 Literal or identifier
  850.                                              reference -> TOS
  851. int const           IC <num>                 small 2's comp. integer
  852.                                              constant -> TOS
  853. address             AD <num>                 Address -> TOS
  854. null parameter      NULL                     missing term attribute
  855. add                 ADD                      TOS = x,y     x + y -> TOS
  856. subtract            SUB                      TOS = x,y     x - y -> TOS
  857. multiply            MUL                      TOS = x,y     x * y -> TOS
  858. divide              DIV                      TOS = x,y     x/y -> TOS
  859. concatenate         CON                      TOS = x,y     x||y -> TOS
  860. unary minus         UNIN                     TOS = x       -x -> TOS
  861. load id value       LIV                      TOS = LD x    V(LD x) -> TOS
  862. load id length      LIL                      TOS = LD x    V(LD x) -> TOS
  863. load id type        LIT                      TOS = LD x    V(LD x) -> TOS
  864. look up label       LVL                      TOS = x       AD x -> TOS
  865. sto                 STO                      TOS = x,y     y -> x
  866. return              RET                      TOS = x       return to
  867.                                                            caller with x
  868. branch true         BT                       TOS = AD x    AD x -> Instr.
  869.                                                                    counter
  870. branch false        BF                       TOS = AD x    AD x -> Instr.
  871.                                                                    counter
  872. branch              BU                       TOS = AD x    AD x -> Instr.
  873.                                                                    counter
  874. compare equal       CEQ                      TOS = x,y     (y.EQ.x) ->
  875.                                                                    TRUE/FALSE
  876.                                                                    flag
  877. compare not equal   CNE                      TOS = x,y     (y.NE.x) -> T/FF
  878. compare <=          CLE                      TOS = x,y     (y.LE.x) -> T/FF
  879. call output         OUT                      TOS = r,t,v,l (r,t,v,l) -> output
  880. call input          IN ( INC = compare       TOS = r,t,v,l (r,t,v,l) -> TOS
  881.                          INN = no compare )
  882. current -> initial  SCIP                     CIP -> IIP    (store current input
  883.                                                             ptr - initial IP)
  884. initial -> current  SICP                     IIP -> CIP    (store initial input
  885.                                                             ptr - CIP)
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.                                                                [Page 16]
  899.  
  900. Data Reconfiguration Service                                     RFC 194
  901.  
  902.  
  903. VI.  EXAMPLE COMPILATION
  904.  
  905. FORM SOURCE               GENERATED POLISH INSTRUCTION SEQUENCE
  906.  
  907.                      ADDR. INSTR.     COMMENTS
  908. (NUMB.<=.1);         0     SICP     RULE PRELUDE
  909.                      1     IC   1
  910.                      2     LD   0   REFERENCE TO NUMB
  911.                      3     STO      STORE IN NUMB
  912.                      4     SCIP     RULE POSTLUDE
  913. 1 CC(,E,,1:FR(99)),  5     SICP     RULE PRELUDE
  914.                      6     NULL     NO REPLICATION EXPRESSION
  915.                      7     IC   4   TYPE EBCDIC
  916.                      8     NULL     NO VALUE EXPRESSION
  917.                      9     IC   1   LENGTH
  918.                      10    INN      INPUT CALL WITH NO COMPARE
  919.                      11    AD   15
  920.                      12    BT       SKIP RETURN IF INN SUCCEEDS
  921.                      13    IC   99  RETURN CODE
  922.                      14    RET      RETURN TO CALLER IF FAILED
  923.                      15    LD   1   REFERENCE TO CC
  924.                      16    STO      STORE INPUT DATA IN CC
  925. LINE(,E,,121:        17    NULL     NO REPLICATION EXPRESSION
  926.          FR(99)),    18    IC   4   TYPE IS EBCDIC
  927.                      19    NULL     NO VALUE EXPRESSION
  928.                      20    IC   121 LENGTH
  929.                      21    INN      INPUT WITH NO COMPARE
  930.                      22    AD   26
  931.                      23    BT       SKIP RETURN IF OK
  932.                      24    IC   98  RETURN CODE
  933.                      25    RET      RETURN TO CALLER IF FAILED
  934.                      26    LD   2   REFERENCE TO LINE
  935.                      27    STO      STORE INPUT IN LINE
  936. :CC,                 28    SCIP     SUCCESSFUL INPUT
  937.                      29    NULL     NO REPLICATION FACTOR
  938.                      30    LD   1   REFERENCE TO CC
  939.                      31    LIT      TYPE OF CC
  940.                      32    LD   1   REFERENCE TO VALUE OF CC
  941.                      33    LD   1   CC AGAIN
  942.                      34    LIL      LENGTH OF CC
  943.                      35    OUT      OUTPUT CC
  944. (,ED,NUMB,2),        36    NULL     NO REPLICATION
  945.                      37    IC   6   TYPE IS ED
  946.                      38    LD   0   REFERENCE TO VALUE OF NUMB
  947.                      39    IC   2   LENGTH OF OUTPUT FIELD
  948.                      40    OUT      OUTPUT NUMB AS EBCDIC DEC.
  949. (,E,E".",1),         41    NULL     NO REPLICATION
  950.                      42    IC   4   TYPE IS EBCDIC
  951.  
  952.  
  953.  
  954.                                                                [Page 17]
  955.  
  956. Data Reconfiguration Service                                     RFC 194
  957.  
  958.  
  959.                      43    LD   3   REFERENCE TO E"."
  960.                      44    IC   1   LENGTH TO OUTPUT
  961.                      45    OUT      OUTPUT THE PERIOD
  962. (,E,LINE,117),       46    NULL     NO REPLICATION
  963.                      47    IC   4   TYPE IS EBCDIC
  964.                      48    LD   2   REFERENCE TO LINE
  965.                      49    IC   117 LENGTH TO OUTPUT
  966.                      50    OUT      PUT OUT CONTENTS OF LINE
  967. (NUMB.<=.NUMB+1:     51    LD   0   REFERENCE TO NUMB
  968.          U(1));      52    IC   1   AMOUNT TO ADD
  969.                      53    ADD      ADD TO NUMB
  970.                      54    LD   0   REFERENCE TO NUMB
  971.                      55    STO      STORE BACK INTO NUMB
  972.                      56    AD   5   PLACE TO GO
  973.                      57    B        UNCONDITIONAL BRANCH BACK
  974.  
  975.  
  976.                 LITERAL/IDENTIFIER TABLE
  977.  
  978.                      0     NUMB
  979.                      1     CC
  980.                      2     LINE
  981.                      3     E"."
  982.  
  983.  
  984.                      LABEL TABLE
  985.  
  986.                   LABEL     OFFSET
  987.                     1         5
  988.  
  989.  
  990.        [ This RFC was put into machine readable form for entry ]
  991.          [ into the online RFC archives by Simone Demmel 6/97 ]
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.                                                                [Page 18]
  1011.  
  1012.