From 6c115614d399d92b7ad3aacdd380015a9aac0ea9 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Wed, 9 Jun 2004 00:48:58 +0000 Subject: [PATCH] Added another few pages. --- doc/mad-manual.xml | 243 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 242 insertions(+), 1 deletion(-) diff --git a/doc/mad-manual.xml b/doc/mad-manual.xml index ea10d83..8f822c0 100644 --- a/doc/mad-manual.xml +++ b/doc/mad-manual.xml @@ -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. +The Sequence + +Occasionally the sequence which would follow a particular MODE +STRUCTURE statement is known to agree exactly with some existing +sequence in MAD or some previously defined +sequence. 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: + + + MODE STRUCTURE 5 + 5 TO 5 + SAME SEQUENCE AS 1 + 1 TO 1 + + +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. + +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 +processing 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 - unconditional transfer during +processing of the sequence. This is illustrated in the +example by the introduction of the form + +JMP *-6 + +It consists merely of a local reference (* ± integer constant), +and refers to the processing of the sequence +during compilation. This instruction will not +appear in the object program generated. The * may only occur in JMP +instructions. (4) JMP - conditional transfer +during processing of the sequence. This is +illustrated in the example by the instruction + +JMP *+1, MQ, *+7 + +This refers to the symbol MQ, which is one of four logical +propositions: + + + +MQ: + +The result of the previous operation was +left in the MQ register. + + + +AC: + +The result of the previous operation was +left in the accumulator. + + + +AT: + +The current a operand is the result of the +previous operation. + + + +BT: + +The current b operand is the result of the +previous operation. + + + + +(Note: The a and b operands +refer to the context: A .NAME. B, where A is omitted for unary +operators.) + +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 true, and in the "decrement" +(right-most) position the local reference to which the processing next +proceeds if the proposition is false. (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 +always 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 not 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: + + + +A - + +refers to the a operand (not used for unary +operations) + + + + +B - + +refers to the b operand Note: A and B may +not appear in instructions such as STO, itc., which change their +values. + + + +T - + +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. + + + +T + integer constant - + +refers to other temporaries which may be used in the sequence. +There must be exactly two occurrences of +any temporary name so used. One may not assume these +temporaries are located contiguously in storage. + + + +LOG + integer constant - + +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. + + + + +Integer Constants + +C1 - symbolic name for the constant integer 1 + +CF - symbolic name for the constant ++2330000000008, useful for certain +conversions. + +Note: All integers used in definition sequences are interpreted as +usual. Integers may not exceed 1023. + + + +Processing + +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 during processing of the +sequence.) + +Examples: + +(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. + + + 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 + + +(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): + + -