simpledeclist ::=celldec|basedec|simpledeclist celldec|simpledeclist basedec basedec ::=BASE; lowerdec ::=LOWER lwdeclist LOWEND; lwdeclist ::=celldec|lowerglobaldec|lwdeclist celldec|lwdeclist lowerglobaldec celldeclist ::=celldec|celldeclist celldec
Most PLASYD cells will be allocated upper storage. That is some address other than the first 4096 words of storage. Variables placed in upper storage cannot be directly addressed and must be accessed by indirect means. In earlier sections the method of accessing upper storage using a modifier has been described. Any set of declarations in a block head defined as a simpledeclist will be allocated upper storage. To enable such cells to be used, the upper storage is divided into arbitrary sections called domains which must not exceed 4096 words. An upper cell is then accessed by specifying the address of the first word in its domain called the base for that cell and the number of words (which must be less than 4096) between this base and the cell required. This number is called the displacement of the cell from its base. Given a cell identifier A, PLASYD defines the three addresses:
£A = base address of A, that is the address of the first word of the domain in which A appears.
$A = the displacement of A from its base.
@A = the actual address of A, @A=£A+$A.
The first upper declaration will cause a new domain to be set up and successively declared items will be assigned store locations in that domain in order until the next declaration would cause the size of the domain to exceed 4096 words. A new domain will then be started in the next available word. Each new block starts a new domain except that the block at the head of a procedure body is assumed to be part of the enclosing block's declaration.
If a single array item is more than 4096 words a new base will be started coinciding with its first word, and another new base will be started immediately after it. Any cells above the 4096'th will have to be addressed by a specially set up modifier.
If more than 4096 words are declared then a new base is defined and a comment to this effect is made on the program listing. Each base uses a word in lower storage to hold the address of the base of that domain. Each time a new domain is started, a word of lower storage is allocated at that point.
For example:
BEGIN INTEGER I(4095),J,K,L; INTEGER M(5000); INTEGER N; .......... BEGIN INTEGER P(4095),Q,R,S; .......... BEGIN INTEGER T,U,V(5000); PROCEDURE FRED(X1); BEGIN INTEGER PI,PJ(4000),PK(1000),PL(5000),PM; .................... END; END; ......... BEGIN INTEGER W,X(4000),Y(1000); .......... END; ........ END; ........ BEGIN INTEGER Z,A,B(4000),C(1000),D; PROCEDURE DICK(X1); BEGIN INTEGER E,F(5000); END; ....... END; END
would allocate the following bases and domains
Cell Lower Storage Base Address Displacement I 0 β 0 J 0 β 4095 K 1 β+4096 0 L 1 β+4096 1 M 2 β+4098 0 N 3 β+9098 0 P 4 β+9099 0 Q 4 β+9099 4095 R 5 β+13195 0 S 5 β+13195 1 T 6 β+13197 0 U 6 β+13197 1 V 7 β+13199 0 PI 8 β+18199 0 PJ 8 β+18199 1 PK 9 β+22200 0 PM 9 β+22200 1000 W 6 β+13197 0 X 6 β+13197 1 Y 10 β+17198 0 Z 4 β+9099 0 A 4 β+9099 1 B 4 β+9099 2 C 11 β+13101 0 D 11 β+13101 1000 E 11 β+13101 1001 F 12 β+14103 0
Notice that 12 lower storage cells have been used to hold base addresses. The storage for variables P, Q, R and S is reused for the variables Z, A, B, C. Similarly, T, U, V, and W, X, Y share storage.
The user may not like the arbitrary way in which new domains have been allocated. The base declaration forces a new domain to be started at this point. By using the BASE statement, certain cells can be forced in the same domain if that is required. For example:
BEGIN INTEGER I(4095), J,K,L; END
would normally allocate I and J in one domain with K and L in a separate domain. J can be forced into the same domain as K and L as follows
BEGIN INTEGER I (4095); BASE; INTEGER J,K,L; END
Although most cells are likely to be allocated upper storage, it may be advantageous to allocate lower storage to some cells. Such cells can be addressed directly and therefore do not have the overhead associated with upper cells where the base of the domain must be loaded into a modifier. A set of declarations are defined as having storage allocated in the lower area by placing the declarations between the symbols LOWER and LOWEND; to form a lower declaration. In the syntax given in Section 18.1 it can be seen that global declarations can also be defined as requiring lower storage. Details of global declarations are given later. Consider:
BEGIN INTEGER I,J; LOWER INTEGER K,L; REAL M; LOWEND; REAL N; LOWER INTEGER P=3; LOWEND; REAL Q; END
Here I, J, N and Q are allocated upper storage while K, L, M and P are allocated lower storage.
Lower storage is used for purposes other than the holding of cells declared as lower. Consequently, less than 4096 words will be available. Lower storage is allocated as follows: