]> thyrsus.com Git - mad.git/commitdiff
Added another few pages.
authorEric S. Raymond <esr@thyrsus,com>
Wed, 9 Jun 2004 00:48:58 +0000 (00:48 +0000)
committerEric S. Raymond <esr@thyrsus,com>
Wed, 9 Jun 2004 00:48:58 +0000 (00:48 +0000)
doc/mad-manual.xml

index ea10d8300fff9554b1beebb87fd14c130c110af5..8f822c03f45d48655a5c2863992c2cbdda51c3a6 100644 (file)
@@ -5109,10 +5109,251 @@ definition program must appear in an M position in some MODE STRUCTURE
 statement.  This applies in particular to contexts occurring in N
 positions in MODE STRUCTURE statements of type 2.</para>
 
+<sect2><title>The Sequence</title>
+
+<para>Occasionally the sequence which would follow a particular MODE
+STRUCTURE statement is known to agree exactly with some existing
+sequence in MAD or some <emphasis>previously defined
+sequence</emphasis>.  In this case, the entire sequence may be
+replaced by the statement SAME SEQUENCE as [script]S, where [script]S
+is some mode scheme for which a sequence is already available in MAD
+or has been previously encountered.  For example, one might write:</para>
+
+<programlisting>
+       MODE STRUCTURE   5 + 5 TO 5
+       SAME SEQUENCE AS 1 + 1 TO 1
+</programlisting>
+
+<para>for some new mode numbered 5 for which addition happens to coincide
+with integer addition.  (Presumably, some other operator will differ
+in its mode 5 behavior from its integer behavior.)  When a new
+sequence is needed, it must follow immediately the MODE STRUCTURE
+statement to which it belongs.</para>
+
+<para>There are five kinds of instructions which may occur in the sequence:  
+(1) END - this must be the physically last instruction of the
+sequence.  It has no significance except to terminate the definition
+sequence.  
+(2) OUT AC and OUT MQ - these terminate the
+<emphasis>processing</emphasis> of the sequence and indicate that the
+result of carryin gout the object program computation will be left in
+the accumulator or MQ register, respectively.
+(3) JMP - <emphasis>unconditional</emphasis> transfer <emphasis>during
+processing of the sequence</emphasis>.  This is illustrated in the
+example by the introduction of the form</para>
+
+<para role='centered'>JMP *-6</para>
+
+<para>It consists merely of a local reference (* &plusmn; integer constant),
+and refers to the <emphasis>processing</emphasis> of the sequence
+<emphasis>during compilation</emphasis>.  This instruction will not
+appear in the object program generated.  The * may only occur in JMP
+instructions.  (4) JMP - <emphasis>conditional</emphasis> transfer
+<emphasis>during processing of the sequence</emphasis>.  This is
+illustrated in the example by the instruction</para>
+
+<para role='centered'>JMP *+1, MQ, *+7</para>
+
+<para>This refers to the symbol MQ, which is one of four logical
+propositions:</para>
+
+<variablelist>
+<varlistentry>
+<term>MQ:</term>
+<listitem>
+<para>The result of the <emphasis>previous</emphasis> operation was
+left in the MQ register.</para>
+</listitem>
+</varlistentry>
+<varlistentry>
+<term>AC:</term>
+<listitem>
+<para>The result of the <emphasis>previous</emphasis> operation was
+left in the accumulator.</para> 
+</listitem>
+</varlistentry>
+<varlistentry>
+<term>AT:</term>
+<listitem>
+<para>The current <emphasis>a</emphasis> operand is the result of the
+previous operation.</para> 
+</listitem>
+</varlistentry>
+<varlistentry>
+<term>BT:</term>
+<listitem>
+<para>The current <emphasis>b</emphasis> operand is the result of the
+previous operation.</para> 
+</listitem>
+</varlistentry>
+</variablelist>
+
+<para>(Note: The <emphasis>a</emphasis> and <emphasis>b</emphasis> operands
+refer to the context: A .NAME. B, where A is omitted for unary
+operators.)</para>
+
+<para>The conditional transfer instruction indicates in the "tag" position
+the logical proposition (e.g., MQ) in the "address" (left-most)
+position the local reference to which the processing next proceeds if
+the proposition is <emphasis>true</emphasis>, and in the "decrement"
+(right-most) position the local reference to which the processing next
+proceeds if the proposition is <emphasis>false</emphasis>.  (The
+symbol "*" refers to the location in the sequence in which the "*"
+itself is found.)  Thus, in the example, if the result of the previous
+operation was in the MQ register, processing moves next to the STQ T
+instruction while if it was not in the MQ register, processing moves
+next to the STO T instruction.  This illustrates the need for
+<emphasis>always</emphasis> saving the previous result if it is not
+used immediately.  (5) Object program instructions in the form of a
+3-letter mnemonic operation code (taken from the list given in the
+Appendix), followed by the usual address, tag, and/or decrement parts
+as in the standard 704 codes.  (SAP extended operations codes are not
+included i the Appendix and may <emphasis>not</emphasis> be used.)  In
+object program instructions the tag, if any, must be one of the digits
+0 through 7, and if there is a decrement part, the tag digit may not
+be omitted and the address part may not be omitted.  Address and
+decrement parts must be one of the following:</para>
+
+<variablelist>
+<varlistentry>
+<term>A -</term>
+<listitem>
+<para>refers to the <emphasis>a</emphasis> operand (not used for unary 
+operations)
+</para>
+</listitem>
+</varlistentry>
+<varlistentry>
+<term>B -</term>
+<listitem>
+<para>refers to the <emphasis>b</emphasis> operand Note: A and B may
+not appear in instructions such as STO, itc., which change their
+values.</para>
+</listitem>
+</varlistentry>
+<varlistentry>
+<term>T -</term>
+<listitem>
+<para>refers to the temporary in which the result of the previous
+operation must be stored if not used.  This temporary may not be used
+for any other purpose.</para>
+</listitem>
+</varlistentry>
+<varlistentry>
+<term>T + integer constant -</term>
+<listitem>
+<para>refers to other temporaries which may be used in the sequence.
+There must be <emphasis>exactly two occurrences</emphasis> of
+any temporary name so used.  One may not assume these
+temporaries are located contiguously in storage.</para>
+</listitem>
+</varlistentry>
+<varlistentry>
+<term>LOG + integer constant -</term>
+<listitem>
+<para>local object program reference, i.e., a reference in the object
+program, effective at the time of execution of the object program, not
+during translation.  (There is no provision here for a "location
+field" such as columns 1-6 in SAP.)  "LOG" refers to the location in
+which "LOG" occurs, and may not occur in a JMP instruction.</para>
+</listitem>
+</varlistentry>
+</variablelist>
+
+<sect3><title>Integer Constants</title>
+
+<para>C1 - symbolic name for the constant integer 1</para>
+
+<para>CF - symbolic name for the constant
++233000000000<subscript>8</subscript>, useful for certain
+conversions.</para>
+
+<para>Note: All integers used in definition sequences are interpreted as
+usual.  Integers may not exceed 1023.</para>
+
+</sect3>
+</sect2>
+<sect2><title>Processing</title>
+
+<para>After the definition program has been absorbed into the translator,
+the sequence is processed interpretively at each occurrence of the
+defined operator in some legal context, i.e., the first instruction is
+examined and if it is an unconditional transfer or conditional
+transfer (JMP), the transfer is made to the appropriate instruction in
+the sequence. If it is an object program instruction (operation code
+other than JMP, OUT, or END), the appropriate translation of the
+instruction is included in the machine-language version of the object
+program, which is being generated.  If it is an OUT instruction, the
+procerssing of the sequence stops, with the setting of a switch in the
+translator to indicatte whether the result of this operation remains
+in the accumulator or MQ register.  (The END instruction should never
+be encountered <emphasis>during processing</emphasis> of the
+sequence.)</para>
+
+<para>Examples:</para>
+
+<para>(1) The following program could be used to define floating point
+multiplication if it were not already in the MAD language.  The three
+sequence definition programs define floating point multiplication and
+two conversions, respectively.</para>
+
+<programlisting>
+       DEFINE BINARY OPERATOR .FMPY., PRECEDENCE SAME AS *(
+       MODE STRUCTURE 0 .FMPY.0 TO 0
+
+JMP    *+4,AC,*+1
+JMP    *+1,MQ,*+4
+JMP    *+4,AT,*+1
+JMP    *+7,BT,*+5
+STO    T
+LDQ    A
+FMP    B
+OUT    AC
+STQ    T
+JMP    *-4
+FMP    A
+OUT    AC
+END
+
+       MODE STRUCTURE 1 .FMPY. 0 TO 0.FMPY.0
+
+JMP    *+5,MQ,*+1
+JMP    *+1,AC,*+5
+JMP    *+5,AT,*+1
+STO    T
+JMP    *+2
+STQ    T
+CLA    A
+ORA    CF
+FAD    CF
+OUT    AC
+END
+
+       MODE STRUCTURE 0 .FMPY. 1 to 0.FMPY.0
+JMP    *+5,MQ,*+1
+JMP    *+1,AC,*+5
+JMP    *+5,BT,*+1
+STO    T
+JMP    *+2
+STO    T
+JMP    *+2
+STQ    T
+CLA    B
+ORA    CF
+FAD    CF
+OUT    AC
+END
+</programlisting>
+
+<para>(2) The unary operator .SHIFT., which shifts an integer in the
+address part into the decrement part of a word, would be defined as
+follows (where mode 5 indicates an integer in the decrement part of
+the word):</para>
+
+</sect2>
 </sect1>
 </appendix>
 
-
 </book>
 <!--
 Local Variables: