• Keine Ergebnisse gefunden

Macro-Instructions

Im Dokument The Computer Concepts (Seite 174-177)

Whenever the use of a subroutine is required by a main program, it must be suitably incorporated into that program. That is, the sub-, routine must be logically connected to the main program in such a way

that the subroutine will be executed at the proper time and, at its com-pletion, will return control to the main program to continue the execu-tion of the problem.

One method by which this connection can be effected is to insert the subroutine directly into the larger program where needed. A sub-routine incorporated in this fashion is called an "open subsub-routine" or

"direct insert subroutine." In most cases, however, this method of connection is not entirely practical or desirable. For example, in a pro-gram that requires the evaluation of a square root at 15 different places, it would be superfluous to incorporate the same square root subroutine 15 times. The desirable solution is to store the subroutine once, out of the main line sequence of the program,and, when required, enter the subroutine by a branching operation. Provision must also be made to return control to the main program at the completion of th~ subroutine.

Subroutines connected in this fashion are called "closed" or "linked"

subroutines. The instructions related to the entry and re-entry function constitute the linkage. In general, it is necessary for the linkage in-structions to a closed subroutine to supply three items of information:

155

156 Macro-Instructions 1. The address of the subroutine desired.

2. The return address after completion of the subroutine.

3. The address ( es ) of the argument (s ) in question, or the actual argument (s) itself/themselves.

The instructions that provide this linkage may, of course, be written by the programmer. However, certain special macro-instructions may be employe9, by the programmer to cause automatic generation of these linkage instructions. A macro-instruction may be defined as a pseudo-instruction which, during assembly, generates more than one machine language instruction. For the 1620 Symbolic Programming Systeml there are 17 macro-instructions available. Each of these "macros," when used in a source program, will generate the instructions necessary to provide proper linkage to one of the 17 subroutines. The subroutines are of two categories: arithmetic and functional. Table 13.1 gives a list of all available macro-instructions.

Thus, by placing in the source program, at the point at which a par-ticular subroutine is desired, the macro-instruction related to this sub-routine, the programmer will cause the SPS processor to generate, during assembly, the linkage to the desired subroutine. In addition, the processor will arrange for the subroutine to be placed in core storage.

Thus, when required during the execution of the object program, the subroutine will be transferred to and executed. The data and addresses required by the subroutine, f,l.nd supplied by the macro-instruction, are incorporated into the linkage instructions where they are either ( 1 ) transmitted directly to the subroutine or (2) simply made available for use.

In this way, the subroutine obtains the information it requires to perform its given task and also obtains the information required to gen-erate a return address to the main program. Control is returned to the main program at the completion of the subroutine by branching to the return address.

In the discussion of many of the macro-instructions, a reference is made to Appendix IV, "Floating Point Hardware," for a description of their operations. This is not to imply that macro-instructions are genuine machine commands but rather that their operation simulates the analo-gous machine code. With the realization that subroutine linkages ~re

generated by use of these macro-instructions, the programmer may con-sider them as if they were actual machine commands.

1 There are many versions of SPS; but the most commonly used is one which assumes a floating point word to always be 10 digits in length (8-digit mantissa and 2-digit characteristic). Another version allows for variability of the mantissa. It is the former version which is discussed in this chapter. Knowledge of this fixed-word-size system allows for immediate transition to the variable-mantissa system.

Macro-Instructions

ARITHMETIC

Floating Add ( FA) Floating Subtract (FS) Floating Multiply (FM) Floating Divide (FD) Fixed Divide (DIV)

157 Table 13.1*

FUNCTIONAL

Floating Square Root (FSQR)

Floating Sine (FSIN)-Radian argument Floating Cosine (FCOS)-Radian argument Floating Arctangent (FATN)

Floating Exponential (FEX)-Base e Floating Exponential (FEXT)-B'ase 10 Floating Logarithm (FLN)-Base e Floating Logarithm (FLOG )-Base 10 Floating Transmit Field (TFLS) Floating Branch and Transmit (BTFS)

• Two additional macro-instructions are also available, but their use is greatest with the variable mantissa version of SPS. These macros are Floating Shift Right (FSRS) and Floating Shift Left (FSLS). See Appendix IV "Floating Point Hardware," for a discussion of their function.

LINKAGE

A design for a subroutine linking scheme is generally a compromise between the maximum amount of information that can be obtained from the linkage and the minimum core required by the linkage. The primary linking instructions used by all macro-instructions. in the 1620 symbolic system are as follows:

LINE

..

LABEL II It" OPERATION 00 OPERANQS l REMARI'oS ••

.. ..

TFM P.I.C.K+ K *+.2.3.

8 LINK D .•. RG *-4

ft<O DSA A 8 C

. .

where "Pick" is a subroutine used by all macros and "Link" is the loca-tion of a secondary linkage.

This secondary linkage generally takes the following form:

LINE

.

LABEL II It OPERATION 00 OPERANDS l REMARKS

,.

"

..

HM PICK+C SUB 8 PICK+J

.

where "Sub" is the address of the desired subroutine and "K," "C," and

"1"

are constants supplied by the processor.

158 Macro-Instructions In this way the secondary linkage and the Pick subroutine act as intermediaries between the primary linkage and the actual subroutine desired. Pick is given the address of the address of the first argument by the primary linkage. Having this, Pick can then calculate the address of the address of the second argument, third, and so forth, and lastly the return address to the main program. The Pick routine is given the address of the main subroutine by the secondary linkage and the combination of these items allows Pick to operate as a successful

"middle man."

All secondary linkages are located after the last instruction generated by the SPS source program, and the Pick subroutine follows the last of the secondary linkages. All subroutines follow Pick. Therefore, it is nec-essary to know the size of all these elements in order to be assured that the program will not overflow the available core storage. The schematic of the linkage system is presented in Figure 13.1.

BEGINNING OF PROGRAM

Array of Secondary Linkages } Secondary L_---....,,-====] Link Associated

- - 1 - - - 1

J

Prim,,., U,k

---,

I

l ____ _

PICK

---~---CORE ASSIGNMENTS

Fig. 13.1. Schematic of Linkage System.

--, S U B R

o

U T I N E

Im Dokument The Computer Concepts (Seite 174-177)