30 March 2006  1401 Relocatable Object Decks Page 1 of 4

1401 Relocatable Object Decks

Van Snyder

1 Introduction

Consider the following (unrelated) instructions. The convention in the 1401 Fortran compiler, which we repeat here, is that addresses above 2000 are to be relocated. The sequence number is the offset from the load address.

    0          SBR  2178
    4          MCW  3&X2,2194
   11          A    2215,2199
   18          MZ   2092&X1,2197
   25          DCW  #1

If these were assembled at 2000, they would produce an Autocoder load record:

....5...10...15...20...25...30...35...40...45...50...55...60...65...70.
1                                      1      1      1      1      1   1
HJ78M0!3J94AK15J99Y!Z2J97              L026!25,!04!11,!18!25,0400401040

The layout of the following formats is the same as produced by Autocoder: the text to be loaded is in columns 1-39 of the load record, and instructions to load it, set word marks, and relocate addresses in it are in 40-67.

2 As used in the 1401 FORTRAN compiler

1401 Relocatable Object Decks Page 2 of 4 30 March 2006

Relocation of relocatable functions in the 1401 Fortran compiler is accomplished by tagging the load instruction in location 40, and the subsequent set word mark instructions, to indicate what fields are to be relocated. It is assumed that they are relocated by the load address less 2000, since they are assembled to be loaded at 2000. The utility that converts Autocoder decks to relocatable form assumes addresses above 2000 are to be relocated. If the index tag of the A field of the load instruction has A and B zones, it means the B address of the load instruction and both addresses of the set word mark instructions, except those that are 040, are to be relocated. Otherwise they are not to be relocated. If the index tag of the B address of the load instruction has an A zone it indicates that only the B address (word mark + 4–6) of the first field is to be relocated, If it has an B zone it indicates that only the A address (word mark + 1–3) is to be relocated. If it has both A and B zones it indicates that both addresses are to be relocated. If the index tag of either address in a set word mark instruction has an A zone it indicates that only the B address (word mark + 4–6) of the tagged field is to be relocated, If it has an B zone it indicates that only the A address (word mark + 1–3) is to be relocated. If it has both A and B zones it indicates that both addresses are to be relocated. Thus the above load record becomes:

....5...10...15...20...25...30...35...40...45...50...55...60...65...70.
1                                      1      1      1      1      1   1
HJ78M0!3J94AK15J99Y!Z2J97              L0B6!K5,!|4!A1,!A8!25,0400401040

where | indicates a record mark. I haven’t discovered how it is indicated to relocate an address constant. It appears that the relocatable function library doesn’t need that feature.

3 Self-relocating 1401 object decks

3.1 Indexing and store address register are available

Assume the indexing and store address register feature is available, and that an index register, say X3 is available, that is, X3 is not initialized by the deck. Relocatable addresses within the text are replaced later, so they can be anything. The test is loaded with an LCA instruction in 40-46, in which the B address is indexed by X3. Word marks are set by SW instructions in 47-61 with A and B addresses indexed by X3. In subsequent records, fields are relocated and their index tags set using SBR instructions in 47-61, with A and B addresses indexed by X3. To relocate the text to the correct address, the B address of the load instruction, and the A and B addresses of the set word mark instructions that refer within the loaded text get an X3 tag, where X3 contains the load address.

....5...10...15...20...25...30...35...40...45...50...55...60...65...70.
1                                      1      1      1      1      1   1
HJ78M0!3J94AK15J99Y!Z2J97              L0260B5,0?40A1,0A80B5,0400401040

Now it is necessary to relocate the addresses within the loaded text and recreate the index tags on the relocated addresses. Since X3 contains the load address, not the load address less 2000, 2000 is subtracted from each address to be stored:

....5...10...15...20...25...30...35...40...45...50...55...60...65...70.
1                                      1      1      1      1      1   1
HJ78M0!3J94AK15J99Y!Z2J97              L0260B5,0?40A1,0A80B5H0?31G81040
                                      H0A01I4H0A42A5H0A71I9H0B10I21040
2BKS                                   H0B41I7Y0040B0N000000N0000001040

3.2 Indexing and store address register are not available

First assume MA is available. Assume the load address is in 97-99, but it could be anywhere, since that isn’t used as X3. The above load becomes:

....5...10...15...20...25...30...35...40...45...50...55...60...65...70.
1                                      1      1      1      1      1   1
HJ78M0!3J94AK15J99Y!Z2J97              #099053#099067L026025,0400041040
#099053#099067,040011,0400181040
#099053#099067,040025#0990031040
#099053#099067#099010#0990141040
#099053#099067#099017#0990211040
2BKS                                   #099053#099067#099024Y0040201040

Now assume MA isn’t available. The above load becomes:

....5...10...15...20...25...30...35...40...45...50...55...60...65...70.
1                                      1      1      1      1      1   1
HJ78M0!3J94AK15J99Y!Z2J97              ,065065A099067)065065L0260251040
,065065A099067)065065,0400041040
,065065A099067)065065,0400111040
,065065A099067)065065,0400181040
,065065A099067)065065,0400251040
,065065A099067)065065,0400011040
,065065A099067)065065A0990041040
,065065A099067)065065)0400011040
,065065A099067)065065,0400081040
,065065A099067)065065A0990101040
,065065A099067)065065)0400081040
,065065A099067)065065,0400121040
,065065A099067)065065A0990141040
,065065A099067)065065)0400121040
,065065A099067)065065,0400151040
,065065A099067)065065A0990171040
,065065A099067)065065)0400151040
,065065A099067)065065,0400191040
,065065A099067)065065A0990211040
,065065A099067)065065)0400191040
,065065A099067)065065,0400221040
,065065A099067)065065A0990241040
,065065A099067)065065)0400221040
2BKS                                   ,065065A099067)065065Y0040201040

The self-relocating load deck enlarges as the features to support it dwindle. Since the 1401 Fortran compiler, which eventually either executes code it compiles into core, or punches a nonrelocatable deck, requires indexing and store address, the first method can be used. Even the first method results in a substantially larger deck for the relocatable functions, but the phase of the compiler that loads them becomes much smaller:

               MCW  LDADR,99     LOAD ADDRESS TO X3
     LOOP      B    RDREC        READ A RECORD FROM CARD OR TAPE TO 1-80
               BCE  LASTCD,68,B  LAST RECORD OF THE FUNCTION?
               MCW  BLOOP&3,71   NO, RETURN TO READ THE NEXT RECORD
               B    40           RUN THE LOADER PART OF THE RECORD
     LASTCD    MCW  BFIN&3,71    RETURN TO FINISH THE LOADING
               B    40
     FIN       ....
     BLOOP     B    LOOP
     BFIN      B    FIN

Of course, the utility to convert Autocoder output to relocatable form becomes more complicated, but it doesn’t have the core constraints that the compiler has. If one is willing that this utility knows addresses within the compiler, the 1040 instruction in 68-71 of load records could be replaced with B LOOP, and the branch instruction in 68-71 could be replaced with B FIN, making the loader even simpler:

               MCW  LDADR,99     LOAD ADDRESS TO X3
     LOOP      B    RDREC        READ A RECORD FROM CARD OR TAPE TO 1-80
               B    40           LOAD THE RECORD, RETURN TO LOOP OR FIN
     FIN       ....