1 09/11/84  fortran typeless builtins
  2 
  3 This segment describes Fortran's new typeless intrinsic functions and
  4 how they are used.
  5 
  6 
  7 Explanation of typeless data type:
  8 
  9 There are six builtin functions, "and", "or", "xor", "bool", "compl",
 10 and "fld", that return their results in a special data mode called
 11 "typeless".  This data mode is treated as a one word bit-string (36
 12 bits).
 13 
 14 
 15 Typeless arithmetic:
 16 
 17 There are no typeless variables or constants, only typeless
 18 expressions.  Typeless entities can only exist as the result of one of
 19 the six typeless functions and can only be combined with integer or
 20 other typeless entities.
 21 
 22 
 23 Typeless expressions may contain the basic mathematical operators
 24 ("+", "-", "/", and "*").  When typeless values are combined in this
 25 way, the operations are performed in the same manner as integer
 26 arithmetic.  As an example, the expression:
 27 
 28 (bool (i) + 4) * 9
 29 
 30 adds the typeless value (which is the same as the integer value) of
 31 "i" to 4 and then multiplies the result by 9.  If "i" was, for
 32 example, the integer 3, the value of the above expression would be the
 33 bit-string whose integer value was 63 (3+4=7, 7*9=63).
 34 
 35 With the arithmetic operators the result is always typeless; with
 36 relational operators, the result is logical.
 37 
 38 
 39 Typeless assignments:
 40 
 41 Assignments of this data type can only be to variables one word in
 42 length (scalar or subscripted).
 43 
 44 Whenever the right side of an equals operation yields a typeless
 45 result, the assignment operation is typeless.  This means that the 36
 46 bit string representing the value on the right hand side is stored
 47 without conversion into the location indicated by the left hand side.
 48 The left hand side must have a real, integer, or character*4 data
 49 type.  For example, if "r" is a real variable, the statement:
 50 
 51 r = bool(r) + 1
 52 
 53 adds one to the least significant bit of the real value of "r", using
 54 an integer add, and stores the new value as a bit-string in "r".
 55 
 56 
 57 Assignments to logical variables are allowed but are treated
 58 differently.  The result is .TRUE.  if any bits are set, or .FALSE.
 59 if all the bits are zero.
 60 
 61 
 62 The individual functions:
 63 
 64 and (a1, a2, ...)
 65 Bit by bit logical product of two or more arguments.  All arguments
 66 must have a one word data type.
 67 
 68 or (a1, a2, ...)
 69 Bit by bit logical sum of two or more arguments.  All arguments must
 70 have a one word data type.
 71 
 72 xor (a1, a2, ...)
 73 Bit by bit "exclusive or" of two or more arguments.  All of the
 74 arguments must have a one word data type.
 75 
 76 
 77 bool (a1)
 78 Returns the single argument as a typeless bit-string.  The argument
 79 must have a one word data type.
 80 
 81 compl (a1)
 82 Returns a typeless bit-string which is the one's complement of the
 83 single argument.  The argument must have a one word data type.
 84 
 85 
 86 fld (i1, i2, a)
 87 Used to manipulate bit-strings.  The first two arguments are integer
 88 expressions where 0<= "i1" <=35, 1<= "i2" <=36, and (i1 + i2) <= 36.
 89 The third argument must have a one word data type.  This function
 90 extracts a field of "i2" bits from a 36 bit string represented by "a"
 91 starting with the bit indicated by "i1" (counted from left to right
 92 where the 0'th bit is the leftmost).  The resulting field is
 93 right-justified and the remaining bits are set to zero.
 94 
 95 
 96 This intrinsic function can also appear as a pseudo-variable on the
 97 left hand side of an assignment statement.  When the fld intrinsic is
 98 used in this manner, it must not be the first executable statement of
 99 the program or it will be interpreted as a statement function.  The
100 fld pseudo-variable is defined as follows:
101 
102 fld (i1, i2, a) = b
103 
104 where "i1" and "i2" are integer expressions as described above; "a" is
105 a scalar or subscripted variable; and "b" is an expression.  The "i2"
106 rightmost bits of expression "b" will be inserted into "a" beginning
107 at bit position "i1".
108 
109 
110 Other related functions:
111 
112 The following are integer functions with integer arguments that
113 perform bit shifting operations and are therefore related to the
114 typeless functions.  The first argument of these functions can be a
115 typeless expression.
116 
117 
118 ils (i1, i2)
119 The first argument (which may be either a typeless or integer
120 expression) is shifted left by the number of bit positions indicated
121 by the second argument (which is an integer expression).  The function
122 returns an integer value.
123 
124 irs (i1, i2)
125 The first argument is shifted right (with sign extension) by the
126 number of bit positions indicated by the second argument.
127 
128 
129 ilr (i1, i2)
130 The first argument is rotated left by the number of bit positions
131 indicated by the second argument.
132 
133 irl (i1, i2)
134 The first argument is shifted right (without sign extension) by the
135 number of bit positions indicated by the second argument.