4. Stores the results of manipulation in a specific
location
5. Provides the user with an useful output
Even with a simple program, such as the
resistance program, each step must be broken down
into a series of machine operations. These
instructions, along with the parameters and data, must
be translated into a language or code that the
computer can understand.
Programming is a complex problem that may
involve writing a large number of instructions. It may
also involve keeping track of a great many memory
cells that are used for instruction and data storage,
which is time-consuming and can lead to errors.
To reduce time and the possibility of errors for
complex program preparation, the compiler has been
developed. The compiler is a program that takes
certain commands and then writes, in a form the
machine understands, the instructions necessary for a
computer to execute these commands. Compilers can
bring many instructions into the final program when
called upon or signaled by a single source statement.
The compiler is problem oriented because the
operations produced are those needed to work the
problem as set out by the problem statement.
Compilers are built at various levels or degrees of
complexity. The simplest form of compiler takes one
mnemonic phrase and writes one machine instruction.
A mnemonic code is an abbreviated term describing
something to assist the human memory. For example,
to shift the contents of the A-register right nine places,
the mnemonic code RSH.A9 is used. This causes the
compiler to write an instruction that shifts the
contents of the A-register right 118 places. A
compiler written on this level is commonly called an
assembler. Note the advantages as follows:
1. No opportunity to use the wrong function code
2. No necessity to convert the shift count to octal
A more sophisticated compiler may take a
statement, such as multiply principal by rate, and
generate all the instructions necessary for the
computer to do the following:
1. Locate the factors involved (in this case the
principal and rate)
2. Transfer these factors to the arithmetic unit
3. Perform the indicated arithmetic operation (in
this case multiplication)
4. Store the resultant (which, in this case, will be
the interest or the principal)
The compiler also keeps track of all memory
allocations, whether being used for data or
instructions.
Depending on the complexity of the problem to be
solved, programs may vary in length from a few
instructions to many thousands of instructions.
Ultimately, the program could occupy a significant,
perhaps even an excessive, portion of computer
memory.
One method used to preclude this
possibility is to segment the program, storing seldom
used portions in auxiliary storage, and reading these
portions into the main memory only when they are
required. An important method of developing this
ability is through the use of subroutines.
SUBROUTINES
As a program grows larger, certain functions must
be repeated. The instructions necessary to perform
each of these repeated functions are grouped together
to form subroutines. These subroutines may then be
referenced by a relatively few instructions in the main
program. This eliminates repeating certain groups of
instructions throughout the program.
EXECUTIVE ROUTINES
The instructions that control access to the various
subroutines are called the executive routine of the
main program.
Depending upon the complexity of
the program, there may also be subexecutive routines
within the executive routines.
Housekeeping is a term used frequently with
subroutines. At the time of entry into a subroutine,
the contents of the various addressable registers may
or may not be of value. An addressable register is
defined as any register whose contents can be altered
under program control. The programmer must take
steps to preserve the contents of these registers unless
they are of no value.
JUMP AND RETURN JUMP
INSTRUCTIONS
The jump and return jump instructions are used to
assist in the construction of executive routines. These
instructions provide the computer with the ability to
leave the sequential execution of the main program,
execute any of the subroutines, and then return to the
main program.
8-14