From d5c9bd7d14a5a269180570d96f1d621ba5c504ed Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 25 May 2004 16:57:30 +0000 Subject: [PATCH] More appendix text. --- doc/mad-manual.xml | 87 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/doc/mad-manual.xml b/doc/mad-manual.xml index 44c5da5..ea10d83 100644 --- a/doc/mad-manual.xml +++ b/doc/mad-manual.xml @@ -5021,6 +5021,93 @@ character, such as *, +(binary), -(binary), or /. Unary minus can be referred to in such statements by the name -U. Unary plus should not be used. + +The MODE STRUCTURE STATEMENT + +The choice of an appropriate sequence of instructions to perform +a given operation assumes knowledge not only of the operator in +question, but also of the modes of the operands. Thus A + B will be +computed via one sequence if A and B are both floating point numbers, +and via the same floating point sequence preceeded by an +integer-to-floating point conversion sequence if one of the operands +is an integer and the other is a floating point number. The +specification of an operator together with the modes of its operands +(or operand, if unary) will be called a context, +and indicated by expressions such as 1 + 1, 0 .ADD. 0, .ABS. 0, 1 +.P. 0. In these expressions, the integers represent the +modes of the operands, and if the operator is +unary, the mode is given only for the right-most (or +b) operand position. The left operand will be +referred to as the a operand. + +A mode scheme may be described as being of +one of two types: + +(1) M TO r, used for operator definitions, or +M TO N, where M and N are contexts containing the +same operators but different in exactly one operand mode, and r is a +mode number. Examples of mode schemes are 2 .LOGADD .2 to 2, 1 + 1 TO +1, 1 .ADD. 0 To 1 .ADD. 1. In the first case the operator .LOGADD. is +applied to two Boolean arguents to produce a Boolean result. In the +second case we have ordinary integer addition, producing an integer +result. The third example illustrates a mode conversion. The +operator .ADD. has occurred with an a operand in +floating point mode and a b operand in integer +mode. The mode scheme given describes the conversation of the +b operand to floating point mode. These schemes +are used in MODE STRUCTURE statements (see below) to indicate the +effect of the associated sequence on the operands involved. Reference +will be made below to schemes of "type 1" and "type 2" as indicated +above, and to the M and N contexts and the mode number r which appear +in these schemes. + +After the DEFINE statement (but not necessarily immediately +after) must be one or more sequence definition +programs. Each of these programs consists of one MODE +STRUCTURE statement followed by a "sequence". In case a new mode is +created, one may find occasion to write definition programs without +any new operators being defined. + + +Immediately after the words MODE STRUCTURE is a list of one or more +mode schemes, separated by commas. In any one MODE STRUCTURE +statement all mode schemes must be of the same "type" (see above), +which will then be referred to as the "type" of the MODE STRUCTURE +statement itself, and as the "type" of the sequence definition program +which contains this statement. A statement of type I will precede a +sequence which will accept as input one or two operands and produce a +result. (See "sequence" below.) The "sequence" will be inserted in +the object program, however, only when the operator and modes of the +operands correspond to a context appearing in one of the mode schems +in the MODE STRUCTURE statement. Thus, in the example above, if the +operator .LOGADD. appears between two operands of Boolean or integer +mode, the sequence which follows will be processed as outlined below. +If .LOGADD. appears between two operands, either (or both) of which is +of a different mode, this sequence will not be applicable. If no +other sequence definition programs are provided, the context being +translated is illegal, and an error indication is produced. the mode +number r is taken as the mode of the result of the computation which +results from the sequence. This is needed in establishing contexts of +succeeding operations. + +Since schemes of type 2 require their M and N contexts to agree in the +operator they contain and one of the mode numbers, they have the form: +2.LOGADD. 1 to 2 .LOGADD. 2. The sequence which follows a MODE +STRUCTURE statement containing this scheme will +be written so as to perform the conversion of the second operand of +.LOGADD. from integer to Boolean form in some manner. + +The following general rules apply to all sequence definition +programs: + +(1) A context appearing in an M position may not already exist in the +MAD language or appear in the M position in another MODE STRUCTURE +statement. + +(2) Every context appearing in the program containing the +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. -- 2.43.0