All data and instructions are held in the computer in the form of binary numbers, that is to say, they are represented by groups of 1's and 0's. Although ability in binary arithmetic is not essential to a programmer, an understanding of the notation is reqired, and a brief explanation follows.
Since there exist only the two digits 0 and 1, counting in the binary scale proceeds thus:
One | 1 | ||
Two | 10 | ||
Three | 11 | ||
Four | 100 | ||
Five | 101 | ||
Six | 110 | ||
Seven | 111 | ||
Eight | 1000 |
The digits represent, from right to left, the powers of 2, i.e. 1, 2, 4, 8 etc., just as in the decimal scale the positions represent the powers of 10, i.e. 1, 10, 100 etc. The binary number 1101 therefore represents:
Binary | Vulgar | Decimal |
.1 | 1/2 | .5 |
.11 | 1/2 + 1/4 | .75 |
.101 | 1/2 + 0 + 1/8 | .625 |
In any calculating device, some limit is imposed upon the range of numbers which can be directly represented. For example, on the lower scale of a slide rule, the numbers run from +1 to +10. Yet it is quite practicable to multiply .003 by -140 on the rule and obtain the result -.42, provided appropriate scale factors are applied to each operand and to the apparent result. Similarly, there is no real bar to using any device for calculating with numbers outside the range which can be directly represented.
In 803 this range is from -1 to just less than +1, achieved as follows:
A quicker way of ascertaining the value of a negative number is to write -1 for the first digit, and then + 1/4 + 1/16 + 1/32 for the other "ones": adding gives -21/32 directly.
(This technique gives rise to an alternative explanation of the representation of negative numbers, namely that the first digit is -1 and the remainder are + fractions. This is misleading, for the computer treats all digits as positive.)
This method of negative number representation is most satisfactory, for
if the computer is made to add the two words representing 5/8 and -1/2 it
actually adds 5/8 to 1 1/2 and tries, therefore, to produce the number 2
1/8, which would be:
10 0010 0000 0000 0000 0000 0000 0000 0000 0000 00
But there is no room in the word for the extra digit on the left: this is
therefore lost, and the result appears as
0 0010 0000 0000 0000 0000 0000 0000 0000 0000 00
which is the proper representation of 1/8, the correct answer.
Similarly, all additions and subtractions are carried out correctly, provided that the true answer lies between -1 and 1-2^{-38}. Multiplication and division are also correctly performed.
e.g: 0 1110 1000 0000 0000 0000 0000 0000 0000 0000 00
or: 1 1111 1111 1111 1111 1111 1111 0101 0011 0110 11
to find the computer form of the equivalent negative number:
(This section should be treated lightly at first reading, and re-read later when needed.)
Many problems require calculations to be done with numbers which exceed unity in magnitude. It is therefore generally neccesary to scale all numbers by a suitable factor, as in the example of the slide rule. We now examine this question and look at number representation from a fresh angle.
Consider the number 53 which, in binary has the six digits 110101. If we wish to construct a computer word to represent 53, we must add thirty-three zeros to make up a set of thirty-nine digits. These may all be placed to the left of the 110101, or some may be placed to the right and some to the left, thus:
To enable us to describe the varying positions of the digits
representing 53, we associate the values
2^{0}, 2^{-1}, 2^{-2}, 2^{-3} .....
2^{-38}
with the 39 digits of the word. We then inspect and determine in which
position the units digit of the "53" lies, and we say that the
word is, in case (a): 53 x 2^{-38}, and in (b): 53 x
2^{-12}, and so on.
But it must be understood that what these expressions mean is that in (a) the word represents 53, so placed that its unit digit appears at the right-hand end, while in (b) the word represents 53, so placed that its unit digit is 12 places to the right of the sign digit, with 26 places further to the right. For it is as important to know what the word represents, and how as what it is. To force this point home, although (b) is to us 53 x 2^{-12}, i.e. 53 represented to scale 2^{-12}, it could equally well be 106 x 2^{-13}, or 1696 x 2^{-17} or 6.625 x 2^{-9}.
The symbol "x" is used in this text as the "represented to scale" symbol in preference to the more frequently used "." to avoid confusion: for "53.2^{-12}" could be read as "fifty three point two to the minus twelve".
Similarly, provided the two numbers with which we are dealing are expressed to the smae scale, the computer will give the correct answer, in the same scale, in all addititve and subtractive operations.
But if (b) and (f) are multiplied, the answer will be
(h) 371 x 2^{-24} (= 1484 x 2^{-26} = etc.)
To bring this to the same scale as the original operands will require doubling, and the number of doublings will depend on the scale factor in use, for to bring 371 x 2^{-24} to scale 2^{-12} requires 12 doublings, but from 1484 x 2^{-26} to 1484 x 2^{-13} requires 13 doublings.
(a) 53 x 2^{-38}: 0 0000 0000 0000 0000 0000 0000 0000 0000 1101
01
(b) 53 x 2^{-18}: 0 0000 0000 0000 1101 0100 0000 0000 0000 0000
00
Now (a) is such that a change of 1 in the last place corresponds to a change of 1 in the number represented. This scale is therefore suitable when dealing with integers, it is termed "integer scale", and the scale factor 2^{-38} is often omitted in writing when it is obvious that this scale is intended. The maximum positive capacity is 2^{38}-1 = 274,877,906,943
In (b) the right hand digit is 20 places to the right of the unit of the "53". A change of 1 here is therefore equivalent to a change of 2^{-20}, or about one millionth, in the number represented. This scale is therefore suitable where such a degree of accuracy is required. The maximum positive number which can be represented is, in "non-computer" binary:
If such a degree of accuracy is inadequate, a higher scale still may be used, but capacity is proportionately reduced.
We have, so far, only discussed scales in which tha factor is a power of two. That such scales may be more convenient than other is suggested by the multiplication problem of 2.3.1, where rescaling is done by doubling, a function provided by the computer. If the scale factor is not a power of 2, rescaling is somewhat more difficult. But other scale factors may be used, sometimes with advantage, where this consideration is of little or no importance.
In rare cases in which it is not possible to find a suitable scale factor for the solution of a particular problem, because the required accuracy and capacity cannot both be obtained simultaneously, recourse has to be had to other methods of number representation, termed "multiple-length" and "floating-point". The 803 library contains programmes which enable these methods to be used. See also Appendix 5.
When it is neccesary to store a lot of fairly short numbers in a limited number of locations, recourse may be had to a process termed packing, that is, making one word represent two or more numbers.
Add 127 x 2^{-19} to 341 x 2^{-38} and store the result. Thus:
0 0000 0000 0000 1111 1110 0000 0000 0000 0000 00 | |
+ | 0 0000 0000 0000 0000 0000 0000 0000 0101 0101 01 |
= | 0 0000 0000 0000 1111 1110 0000 0000 0101 0101 01 |
When either number is required for arithmetic purposes, a copy of this word is taken from the store, and the unwanted number deleted by a function provided for the purpose.
Whenever the 803 carries out an arithmetic operation, it automatically tests the number to determine whether capacity is being exceeded. If this is so, a special device called the overflow indicator is set. The following operations, for example, would cause this; in all cases, the correct answer is outside the proper range, so the computer cannot represent it.
Operation | Correct Result |
---|---|
1/2 + 1/2 | 1 |
-1 + -1/2 | -1 1/2 |
-3/4 - 3/8 | -1 1/8 |
Negate(-1) | 1 |
-1 x -1 | 1 |
3/4 ÷ 3/8 | 2 |
Double 5/16 twice | 1 1/4 |
Once it has been set, the overflow indicator remains set until one of two "test overflow indicator" instructions (43 and 47) is obeyed. These are conditional transfer instructions, by means of which the computer can be programmed to do one thing if overflow takes place and another if it does not. It is customary to insert one or other of these instructions at intervals in any programme in which there is a risk of capacity being exceeded. Since the overflow indicator, once set, remains set until tested, it is not neccesary to test after every operation.
A lamp on the keyboard is illuminated whenever the overflow indicator is set.
In certain cases it is possible to allow capacity to be exceeded, provided that compensating action is taken immediately.
For example, in the sequence:
Add 1/4 to 7/8, then subtract 3/8,
the addition of 1/4 + 7/8 produces 1 1/8 in the accumulator. This is the
representation of -7/8, which is wrong, and the overflow indicator is
therefore set. But the immediate subtraction of 3/8 from this gives the
correct overall result 3/4.
Whenever the correct result of a series of additions and subtractions is within the range -1 to 1-2^{-38} inclusive, the 803 will give it correctly, even though the overflow indicator may be set during the series. Deliberate overflow may also be used when employing doubling, halving, multiplication and division functions but greater care is needed when doing so.
Perforated teleprinter tape, or punched paper tape as it is usually termed, is a medium upon which data area recorded by patterns of punched holes. One character consists of between 0 and 5 code holes in a line across the tape, arranged in 5 possible positions. Between the second and third code hole positions there is a small hole, termed the sprocket hole, which is required for mechanical purposes.
To the computer, a hole represents a 1, and "no hole" a 0; each character therefore represents a five-digit binary number between 00000 (zero) and 11111 (thirty one). It is important to appreciate that, although we may quite readily programme the computer to deal with letters, figures and symbols in whatever way we please, the computer recognises them only as groups of 5 binary digits or "bits".
To the teleprinter equipment used in preparing input tapes and interpreting output tapes, however, each of the 32 possible combinations of holes has one or two specific meanings as shown in Appendix 1.
To enable a teleprinter to distinguish between the two meanings of a character, two special characters are provided, "letter shift" and "figure shift" (ls and fs). One of these precedes each group of other characters on a tape, to indicate whether they are to be read as letters or as figures and symbols.
The character "line feed" (lf) is interpreted by a teleprinter as an instruction to print the next letters, figures or symbols on a new line, while "carriage return" (cr) causes printing to start or restart at the left hand margin. "Space" (sp) characters are inserted on a tape whenever required, to cause the teleprinter to space out the letters, figures and symbols. "Blank" (bl) has no meaning, and the teleprinter will ignore it; several inches are punched at each end of a tape to simplify handling.
The choice of characters used to represent figures is governed by the rules:
These rules are made so that, respectively:
When a word represents a pair of instructions, each instruction is denoted by a group of 19 digits, 6 for the function and 13 for the number. The odd digit, which is the middle digit of the word, is termed the B digit: this has a special purpose which will be described later.
The layout is shown below.
Each function is denoted by six binary digits, which correspond, in two
sets of three, to its two-digit octal reference number. Thus function 43
(four-three, not forty-three) is, in binary, 100011. This provides a
convenient means of grouping the functions in eight groups of eight; thus
group 0 comprises functions 00 to 07, Group 1 comprises functions 10 to 17
and so on to group 7, which consists of functions 70 to 77.
The thirteen N digits in each instruction are sufficient to provide a range of N from zero to 1111111111111 = 8191 i.e. to enable the address of any location in a store of 8192 locations to be specified. This is the largest size of store which can be fitted in an 803.
Each 803 computer with a store of 4096 locations is adjusted in such a way that, if it is called upon to obey an instruction in which N is larger than the address of the last location in the store, it will ignore the left-hand N digit. Thus the instruction 04 4104 is treated as the instruction 04 8. Where the store has 2048 (1024) locations, the two (or three) left-hand N digits are ignored.
Whenever one word, of 39 digits, is placed in the store, an artificial 40th digit is automatically appended and stored with it: this is termed the parity digit, and is a 1 or a 0 as may be needed to make the total number of 1's in the whole group of 40 digits odd. When a word is taken from the store, the number of 1's in its 40 digits is checked. If this is found to be odd, the parity digit is deleted, and the computer proceeds normally. If it is even, the checking circuit gives rise to a special signal. In the basic 803 the effect of this signal is to stop the computer and illuminate a lamp on the keyboard.
This facility cannot be controlled by programming methods, and the subject is not discussed further.
Previous Chapter | Contents | Next Chapter |