]> thyrsus.com Git - mad.git/commitdiff
One more page.
authorEric S. Raymond <esr@thyrsus,com>
Thu, 10 Jun 2004 04:40:36 +0000 (04:40 +0000)
committerEric S. Raymond <esr@thyrsus,com>
Thu, 10 Jun 2004 04:40:36 +0000 (04:40 +0000)
doc/mad-manual.xml

index 8f822c03f45d48655a5c2863992c2cbdda51c3a6..4572379aa659f13e227b0272a80bae3f2e095402 100644 (file)
@@ -5290,7 +5290,8 @@ in the accumulator or MQ register.  (The END instruction should never
 be encountered <emphasis>during processing</emphasis> of the
 sequence.)</para>
 
-<para>Examples:</para>
+</sect2>
+<sect2><title>Examples:</title>
 
 <para>(1) The following program could be used to define floating point
 multiplication if it were not already in the MAD language.  The three
@@ -5350,6 +5351,96 @@ 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>
 
+<programlisting>
+       DEFINE UNARY OPERATOR .SHIFT., PRECEDENCE SAME AS .ABS.
+       MODE STRUCTURE .SHIFT. 1 TO 5
+
+JMP *+3, MQ, *+1
+JMP *+1, AC, *+3
+JMP *+3, BT, *+5
+STQ  T
+CLA  B
+ASL  18
+OUT  AC
+STO  T
+JMP  *-4
+END
+</programlisting>
+
+<para>One would also have to provide for all contexts in which mode 5
+variables or constants might appear.  In particular, one might needf
+the following (in the case of "*", the "TO r" in a type 1 scheme may
+be omitted.):</para>
+
+<programlisting>
+       MODE STRUCTURE 5 = 5
+
+JMP *+1, BT, *+2
+JMP *+2, AC, *+4
+CLA  B
+STO  A
+OUT  AC
+STQ  A
+OUT  MQ
+END
+</programlisting>
+
+<para>Of course, this could also have been written:</para>
+
+<programlisting>
+       MODE STRUCTURE 5 = 5
+       SAME SEQUENCE AS 1 = 1
+</programlisting>
+
+<para>(3) Another example, illustrating the use of the local object
+program reference (LOC) is the operator .BIT., a Boolean binary
+operator whose value is 1B if A has a 1 in bit position B, and 0B
+otherwise.  (Bits are numbered here from the left, 0-35.)</para>
+
+<programlisting>
+       DEFINE BINARY OPERATOR .BIT., PRECEDENCE SAME AS .E.
+
+       MODE STRUCTURE 1 .BIT.1 TO 2, 2.BIT.1 TO 2, 0.BIT.1 TO 2
+
+JMP *+6, MQ, *+1
+JMP *+1, AC, *+7
+JMP *+1, BT, *+13
+LDQ A
+STA LOC+1               &lt;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;&mdash;
+JMP *+6
+JMP *+3, AT, *+1
+STQ T
+LDQ A
+CLA B
+STA LOC+1
+RQL 0
+PXD
+LGL 1
+OUT AC
+STO T
+JMP *-8
+
+       MODE STRUCTURE 1 .BIT.0 TO 1.BIT.1,
+      1 2 .BIT. 0 TO 2.BIT. 1, 0 .BIT. 0 TO 0 .BIT. 1
+
+        SAME SEQUENCE AS 1 = 0
+</programlisting>
+
+<para>Note that in the instruction indicated by the arrow the address
+(LOC+1) is that which will appear in the object program, not that
+which is in the sequence definition program.  This sequence could be
+written more elegantly but was written in this way to illustrate the
+use of LOC.</para>
+
+</sect2>
+<sect2><title>Card Forms</title>
+
+<para>The DEFINE and MODE STRUCTURE statements are punched (as any
+other MAD statements) starting in (or after) column 12.  Instructions
+in the sequence must have the "operation code" in columns 8-10, and
+the rest of the instruction in (or after) column 12.  Blanks are
+ignored throughout, except in operating codes.</para>
+
 </sect2>
 </sect1>
 </appendix>