The compiler will accept a procedure whose body is written in a form of machine code. This chapter gives details of the syntax and semantics of such procedures. A knowledge of Atlas machine code is assumed.
<binary digit>::=0 | 1 <octal digit>::=0|1|2|3|4|5|6|7 <octal number>::= <octal digit> | <octal digit> <octal number> <address primary>::= <unsigned integer> |<unsigned integer>.<octal digit> | *<octal number> | (<code label>) <address>::= <address primary> | <adding operator> <address primary> |<address> <adding operator> <address primary> <code label>::=<unsigned integer> <unlabelled halfword>::= <address> <halfword>::= <unlabelled halfword> | <code label> <halfword> <function digits>::= <binary digit> <octal digit> <octal digit> <octal digit> |<octal digit> <octal digit> <octal digit> <machine instruction::= <function digits>,<unsigned integer>,<unsigned integer>,<address> <code instructions>::= <function digits>,<unsigned integer>,-,<identifier> <halfword pair>::= <unlabelled halfword> / <halfword> <fullword number>::= <adding operator> <unsigned number> <array instruction>::= B79 = ADDRESS OF <subscripted variable> <dummy item>::= <empty> <unlabelled item>::=<machine instruction> | <code instruction> | <halfword pair> | < fullword number> | < array instruection> | <dummy item> <item>::= <unlabelled item> | < code label>:<item> <code tail>::= <item> end | < item>;<code tail> <code>::= begin code <code tail>
Spaces and newlines are ignored, as elsewhere in an Algol program.
addresses: 39.4 -0.1+*4-(l8)+3 items: 101, 10, 11, (3) 1: 121, 12, -, V17a 2: *77+(3)/3:4:0.2 +9.34α +10 55: B79 = ADDRESS OF x[sin(n*pi/2),Q[3,n,3]] procedure declaration: integer procedure sign (E); value E; real E; begin code 324, 0, -, E; 234, 127, 0, (1); 237, 127, 0, (2); 324, 0, 0, (3); 121, 127, 0, (1); 3: +1; 2: 325, 0, 0, (3); 1: 356, 0, -, sign end
The last example is the procedure declaration for the procedure sign, which forms part of the permanent material.
These have the form F, Ba, Bm, S and compile into straightforward machine instructions. Any assigned instruction or extracode is allowed as F. Ba and Bm are taken modulo 128.
The address S is a linear sum of 24-bit elements; each element can be a 21-bit unsigned integer with or without a 3-bit octal fraction, an octal number of up to 8 digits, or a full-word or half-word address within the procedure body, given by a code label.
These have the form P, Ba, -, <identifier>. F and Ba are as for machine instructions. An instruction of this form compiles into a machine instruction with suitable Bm and address, and gives access to the stack position or operand area of global variables, and to the formal parameters of the procedure. This is useful only for simple variables of real and integer types which are either global to the procedure or are formal parameters called by value, and for type procedures (including the procedure itself if it is a type procedure) of real and integer types. The information obtained from the access is insufficient to handle labels, procedures other than type procedures, formal parameters called by name, or subscripted variables.
The representation of numerical values of quantities in Atlas 1 is described in section 6.1.
These have the basic form S/S, and compile into 24-bit half words forming one 48-bit word. Anything allowable as an address S in a machine instruction can be written as a half word, and is compiled in the same way.
These have the form ±K, where K is an unsigned Algol number as defined in (2.5.1). They compile into standardised Atlas floating point numbers, see CS 348A, section 3.1, and section 6.1 of this manual.
The array instruction compiles to a variable number of machine instructions, depending on the subscript list. It sets in B79 the address of the subscripted variable, and a subsequent 334, 0, 79, 0 will pick up the value of the subscripted variable. The values of array elements are stored consecutively with the last subscript varying fastest, so that e.g. if q is declared as q[O:9,0:9,O:9] then after an array instruction
B79 = ADDRESS OF q [0, 0, 0]
has been obeyed the address of q[i, j, k] is b79+i+10j+100k.
The value of the elements of an array are represented in the same way as simple variables (see 4.1.3.2 above).
A dummy item is not compiled.
A code label is an unsigned integer L in the range 0≤L≤127. It is represented in Atlas as the 24-bit fullword or halfword address of the item (machine instruction, code instruction or fullword number), of the halfword (either of a halfword pair), of the first instruction of the item (array instruction), or of the next non-dummy item to the item (dummy item) to which it is prefixed. If a label is prefixed to a dummy item and no non-dummy item follows, then a jump to that label is an exit from the procedure. Code labels are local to the surrounding procedure body.
The procedure is entered at the item immediately following the symbol code, and the last (possibly dummy) item obeyed before exit is that immediately preceding tbe symbol end.
All restrictions imposed on a procedure statement or function designator calling a procedure with an Algol body apply to a call of a procedure with a code body.