From: Eric S. Raymond Date: Thu, 10 Jun 2004 04:40:36 +0000 (+0000) Subject: One more page. X-Git-Tag: 1.0~23 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=c97c46dfe21c5d760d20b781d78e3fc6882b9052;p=mad.git One more page. --- diff --git a/doc/mad-manual.xml b/doc/mad-manual.xml index 8f822c0..4572379 100644 --- a/doc/mad-manual.xml +++ b/doc/mad-manual.xml @@ -5290,7 +5290,8 @@ in the accumulator or MQ register. (The END instruction should never be encountered during processing of the sequence.) -Examples: + +Examples: (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): + + 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 + + +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.): + + + MODE STRUCTURE 5 = 5 + +JMP *+1, BT, *+2 +JMP *+2, AC, *+4 +CLA B +STO A +OUT AC +STQ A +OUT MQ +END + + +Of course, this could also have been written: + + + MODE STRUCTURE 5 = 5 + SAME SEQUENCE AS 1 = 1 + + +(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.) + + + 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 <———————————— +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 + + +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. + + +Card Forms + +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. +