Instruction for use of the basic input routine R0

1. Introduction

The PC-1 is a stored program computer and uses the binary system within the machine for the representation of numbers and addresses. In using the PC-1, the program as well as the numerical data should first be stored in the machine's memory, before computation starts. This may be done, for one thing, by preparing a tape in which all the instructions and numbers are represented in binary form, and reading in this tape by pressing down the "initial load switch". However, writing down the instructions and numbers in binary notation is by no means simple.

The basic input routine "R0" enables the instructions and numbers punched on tape in decimal, alphanumeric notation to be read and placed in the PC-1 memory. R0 decodes the teleprinter code of the PC-1 perforator, converts the decimal numbers into binary form, adds the operation codes and places the assembled words in specified locations in the memory. When all the instructions and numbers have been stored, R0 causes the machine to start the program by transferring control to a specified word in the memory. R0 provides further facilities of turning the relative addresses on tape into absolute addresses, and adding one or more parameters to the words before they are stored in the memory. Input routine R0 itself occupies the locations 0 〜 67 of the PC-1 memory and is stored there by placing the binary tape of R0 in the tape reader and pressing down the "initial load switch".

2. Basic Functions

Every instruction of the PC-1 is punched in exactly the same form as it is written in the text. That is, operation code consisting of letter, either followed or not followed by a letter "l", and followed by a decimal integer denoting the address, and terminated by a comma, such as a40, x106, pl150, ... Nonsignificant zeroes at the head of the address may be omitted, so that one may punch a40 instead of a0040. Sequence of instructions punched one after another on tape is normally placed in consecutive locations in the memory. The location of the first instruction in a sequence must be specified by a "directive" in front of the sequence, which has the form M:, indicating that the sequence should occupy the storage locations M, M+1, M+2, ... in the memory.

Example:

The tape 100: pl150, vl152, sl154, tl156, jl130, causes the memory locations 100 〜 104 to be loaded by the following words.
 locatoin instruction contents of the memory 100 pl 150 001101100010010110 101 vl 152 001111100010011000 102 sl 154 010100100010011010 103 tl 156 000001100010011100 104 jl 130 011010100010000010
A program tape will consist of one or more sections of such sequences, or subprograms. Blank section of some ten centimeters should be left at the head of the program tape, and the program should begin with a "carriage return and line feed" (CR LF), which clears the working positions of R0 prior to reading essential information.

The complete program should end with a control code jlM. (terminated by a period "."), which stops the operation of R0 and starts the program by causing the control to be transferred to the location M.

Notes:
1. When the address is 0, this may altogether be omitted, for example, "jl0" may be written simply as "jl".
2. It is preferable to leave a short blank section in front of each section of the program, and to punch a CR LF at the beginning of each. This serves the purpose of easy identification of the subprograms and also it enables the reloading of some part of the program by manually transferring control to the location 0.
3. R0 ignores "blank" symbols.
4. "Erase" symbol is not ignored by R0, so that mispunched characters overpunched by 6 holes should be removed in the tape-editing stage.
3. Input of Intergers

Input of numbers occurs just as the input of instructions, that is, the number is regarded as if it were an instruction without operation code, or with the operation code "0" (blank tape). Any positive integer N (0 <= N < 217) can be read in by punching N in decimal notation and terminating by a comma ",".

Ex. 150: 12345, causes an integer 12345, or a fraction 12345 x 2-17 to be stored in memory location 150.

Negative integers - N can be read in by punching an integer 218 - N, where 0 < N <= 217.

Ex. - 2 can be read in by punching 262142,.

Long numbers are usually regarded as pairs of short positive integers (N1, N2) in the form 218N1+N2.

This is the standard way of reading in the numerical constants in library subroutines.

Note: For input of numerical data as well as constants in programs specially drawn up by the user, this would be quite inconvenient, and a universal input auxiliary routine R1 will be used for reading in signed long numbers, either integral or fractional. For input of signed, short numbers, R3 may be used instead of R1.

R0 offers an ample facility of using the preset parameters in the instructions and constants. Namely, any number of alphabets can be written as code letters in a word, except at the head, in which case it is interpreted as the operation code. Each code letter causes a number (a parameter), specified by a precursor tape, to be added to the word before it is stored in the memory. Actually, the specified parameter values for these code letters are stored in the storage locations 57 〜 87, but in general, the programmer is supposed to have no knowledge of exact storage locations for individual code letters.

There are several code letters that are reserved for specific purposes and cannot be assigned arbitrary values by the programmer. These are:

l
=2048 (= 211), used to indicate "long" instructions.
t
=t M (M is the current address of the storage location where the word is to be stored).
r
=Mo: the storage location of the first wored of the current sequence of instructions. This is assigned by the directive Mo:.
"LF" punched as a code letter is an erase symbol and serves the purpose of canceling the characters within the same word already read from tape. This function of LF is made use of by the CR LF at the head of the tape to insure uniform initial state in the operation of R0.

Setting the values to the code letters is done by a tape of the following form: e.g.

0h=131072, 0m=18, 0a=256, ...

using a new control symbol "=". Another way of setting the code letters is of course by storing these values by ordinary directives, e.g.

61:131072, 63:18, 80:256, ...

but this is inconvenient since it requires a precise knowledge of memory locations for individual code letters.

Notes:

1. Teleprinter control characters ("space"(SP), "upper case"(UC), "lower case"(LC), "carriage return"(CR) and "line feed"(LF) are treated by R0 as letters. Hence, these characters punched at the head of a word (that is, next to a terminating symbol) are regarded as (fictitious) operation codes. These symbols (except LF) punched in positions other than the head of a word is interpreted as code letters, and can in principle be used as variable code letters, except CR, the corresponding memory location for which is used by an instruction in R0. However, using teleprinter control characters as code letters is not recommended.
2. Code letters o and g are set to 28 and 68 respectively, usless otherwise specified (see next section). SP, h, m and n are set to zero by R0 tape.
3. Initial 0 in 0h=131072, only serves the purpose of making the letter h to be interpreted as a code letter, and hence can be replaced by any other letter or teleprinter control symbol.
4. Setting of parameter values using "=" symbol destroys the current store address, in case it is done between program sections.
5. Use of Code Letters

The directive M: sets the code letter r automatically to M, the location of the first word in the current sequence of instructions, and hence any word within the same sequence can be referred to by relative address by use of this code letter, e.g.

jl1r,

means jumping to the second instruction in the same section of the program.

The code letter t is actually the instruction to store the assembled word to ultimate place in the memory, and hence its values is always equal to ¥underlinetN, where N is the current destination of the word. Hence this code letter can be used to refer to the word itself, e.g.

 it becomes pM (i+t=p) gt becomes iM (g+t=i) tllt becomes oM (tllt+t=o)
where these words are supposed to be placed in location M. Use of code letter t for purposes other than the above is not recomended.

A standard use of variable code letters is to indicate the location of the first word in each subroutine, e. g. instead of

116:
 program of print routine

we punch at the head of the complete program tape

0p=116: ...

and the subroutine tape begins with

0p:
 program of print routine

so that this closed subroutine can be called in by an instruction pair

it, jlp, instead of it, jl116,.

This use of code letters greatly simplifies the use of library subroutines. The code letter o is used to refer to the storage location 28 which is used to store the independent variable in some closed subroutines. The code letter g(= 68) is used to refer to the working spaces of all kinds of program. However, the numerical value of either o or g can be modified for the programmer's convenience.     Code letters may appear in the directives as well as in instructions. It may also be used in setting of variable code letters, e.g.

0a=116, 0b=28a, 0c=36b,

is equivalent to 0a=116, 0b=144, 0c=180, and jla. has the same effect as jl116..

6. Special Directives

0t:
This sets the r-parameter equal to the current store address.
0r:
This causes the following instructions to be stored starting in the storage location specified by the previous directive.
Nr:
This causes the following instructions to be stored starting in the N-th storage location of the preceding section of the program.
Nt:
This causes the following instructions to be stored in a new location, skipping N storage location next to the preceding program.
0t:0h=0r,
This sets the parameter h equal to the current store address. (0h=0t, is unacceptable since the symbol "=" destroys the store instruction.) This combination is placed before a subroutine having directive 0h:, to place it next to the end of preceding program. h may be replaced by any other variable code letter.)
7. Control Code with "."

tN.(kN., zN.)
Stores the following program starting in the location N, without resetting the r-parameter.
Nt.
Stores the following program in a new location skipping N storage location next to the preceding program.
N.
Stops tape. When the machine is restarted, the following program is stored starting in the location N.
tNt.
Stops tape. When the machine is restarted, the following program is stored skipping N storage locations.
tt.
Special case of tNt.. Stops the tape without destroying the current store address.
8.
Stops tape. When the machine is restarted by inital start key, the following program is stored starting in the current storage locations. (analogous to tt. in effect.)
t57.jl,zN.
Replaces the store instruction by jlN, that is, transfers control to the word at N, leaving the word following in tape in the accumulator. Successive words will be read one by one and placed in the accumulator, each time R0 is called in, transferring control to the same word. (This is used when input of one word is called for during program.)
t57.
Used to restore the operation part of the store instruction to the original one (t), in case it has been modified (to, say, jl).
t57.o56,X,t57.
Print the letter X without disturbing the memory. (When more than one letter is to be printed, it is recommendd to use an interlude. See below.)
8. Input During Program

Although R0 is primarily designed for the input of the program, it is also suitable for such purposes as reading in numerical values called for by program a few at a time. A slight modification on R0 will make it still more adaptable for such uses.

If R0 is called for by jl40 in a program, the last current store address remains unaltered. If it is called for by jl55, the current contents of the accumulator replace the current store address, so that the word read can be stored in locations specified by the program.

Exit from R0 may be made in the usual way by punching jlN. at the end of the number sequence. However, it is more convenient to provide for the exit by means of some unused symbol. In case R1 is not used, either "+" or "-" symbol may be used to send control to a location N. This is done by replacing the word in 32 or 26 respectively by a pseudo-instruction ({¥tt 212980}+N). CR and LF can also be very conveniently used for the exit from R0. This is effected by 23:jlN,.

Using the input routine thus modified, it is also possible to terminate a number by CR and LF, in which case, the number is left in 0oL (28L) as a long integer.

Note: The original program of R0 sets the machine to dynamic stop on reading + or -.

9. Interlude

It is sometimes useful to do some simple operations, such as calculating constants used in the main program, printing table heading, etc. by temporarily placing a short program in the memory and transferring control to this program, before the main program has been stored. This type of program is called the interlude. At the end of an interlude, control should be transferred to R0 by, say, jl40, and subsequent program is usually written over the interlude, so that no extra space need be reserved for it. Following are examples of short programs that are often used as interludes.

1. 0t:c49,jl4,jlr.}:
This has the effect of increasing the current store address by one, if it is odd, and hence may be placed before an ¥underline{even} subroutine in order to make sure that the location of the first word be even.
2. 0t:s,o1r,l2,o3r,jl6r,jlr.
This causes carriage return and line feed to occur during input.
3. 0t:ir,zl40,o2r,jlr,jlr.
This causes the contents of the tape following it to be copied directly by the teleprinter, and may be used to print relevant information concerning the program, e.g. table heading. Blank tape at the end sends control back to R0.