Chapter VI: Appendix: C
Structure of Procedure Calling Sequence
The following information is necessary for the user writing a non-Algol procedure to be called from an Algol program. The calling sequence differs from that found in many other languages.
The first word of the non-Algol procedure must have a simple jump instruction in its upper half, and the exit line is provided by a jump to this first word. The entry automatically causes the proper return address to be placed in the address portion of the first half-word.
Upon entry to the procedure, index register six contains an address which is used to reference each parameter. To establish linkage with the first parameter, the instruction
LDA 6 0
is performed. This brings into the accumulator a word of one of the following types:
1. SLJ 0 ENA V
2. SLJ 0 RTJ L
In case (1), V is the address of the parameter. In case (2), L is the starting address of a piece of coding for computing the address of the parameter and leaving it in the accumulator (if the parameter is an expression, the address in the accumulator will be that of a temporary containing its value). Case (1) always holds if the parameter is a simple variable, string, array identifier, switch identifier, or procedure identifier. In case (2) the same temporary will be used for all the expressions.
Both cases can be provided for by setting aside two locations for each parameter in the procedure body and placing the instruction
SLJ *-1
in the upper half of each second location. Then after
LDA 6 0
mentioned above,
STA RES1,
where RES1 is the first reserved location for the first parameter, makes the two locations into a closed subroutine. After this, the instruction
RTJ RES1
causes the address of the first parameter to be placed in the accumulator anytime it is performed. This accommodates expressions called by name.
In general, the K^th parameter is referenced as above, but beginning with
LDA 6 (K - 1).
This description does not apply to the standard procedures, each of which has its own special calling sequence.
APPENDIX D
Internal Representation of Strings
The address representing a string is that of the first word of string characters. Each left string quote is represented internally by the word
00 ... 03454 ,
and each right string quote by
00 ... 05474 .
The characters of the string which are not string quotes are packed in BCD eight characters per word. These words are in the natural order, the first immediately following the left string quote and the last immediately followed by the right string quote. If the last word before a right quote is not full, the rest of that word is filled out with zeros (not BCD blanks).
Comments
Log in to leave a comment.
The Oak Ridge ALGOL Compiler for the Control Data Corporation 1604Chapter VI: Appendix: C
0%2 min left in chapter