There is interesting chapter "Programming Hints" on the page 55.
So, let's look at the good practices and best choices of programming craft of 1951 year...
Manchester/Ferranti Mark I/II (https://en.wikipedia.org/wiki/Manchester_Mark_1) had classic accumulator-memory architecture. RAM with registers were stored in Williams cathode ray tubes (CRTs). 20-bit instruction consisted of four 5-bit alphanumeric symbols. All letters/digits didn't fit in 32 variants of 5-bit values, so there were two "charset swap codes".
Charset was taken from telegraph, so here is base charset page:
Code: Select all
0 00000 / 8 00010 % 16 00001 T 24 00011 O
1 10000 E 9 10010 D 17 10001 Z 25 10011 B
2 01000 @ 10 01010 R 18 01001 L 26 01011 G
3 11000 A 11 11010 J 19 11001 W 27 11011 "
4 00100 : 12 00110 N 20 00101 H 28 00111 M
5 10100 S 13 10110 F 21 10101 Y 29 10111 X
6 01100 I 14 01110 C 22 01101 P 30 01111 V
7 11100 U 15 11110 K 23 11101 Q 31 11111 ?
As you can note there is no system in letter code and it's position in alphabet. I think it's because 'bits' are just holes in punched tape and count of holes corresponds to fequency of letter in texts.
Wll, let's look at the "hello, world" example (analogy) from Turing manual:
Code: Select all
// /CT/
E/ DSTI
@/ D//H
A/ R//P
:/ /C/S
S/ :CT/
I/ @CTI
U/ :C/S
%/ JS/P
D/ A/
R/ @/
That is first column contains numbers from 0 to 10 in the codepage of this monumental machine.
Program itself resides in the second column. 20-bit numbers represented with four 5-bit letters. First two (10 bit) are memory cell numbers instruction works with. Last two - instruction codes merged with so called "B-tube code" which allows to do indexations. Brutal Manchester's engineers wrote programs in such way.
So, for now we are ready to go to page 55 of manual and read some programming hints from Alan Turing:
Well... without assembler automatically relocating code and symbols it sounds good.Manoevring space
It is seldom that one writes down a page of instructions for the first time withouthaving forgotten a few vital instructions. It is therefore considered desirable to aim,not at pages which are chock-full, but say at ones which are about five-eighths full.The extra space is best left between sequences of consecutive instructions, so that oncesequence may be extended without interfering with another.
Sounds extreme, but honest.Do programming directly in teleprint code
It is never too soon to learn the meanings of the 64 functions [i.e., the opcodes]. The way to do so is to start programming in teleprint code straight away. Keep a list of themeanings always at hand, and refer to it as much as you wish: you will find that aftera week very few references are necessary. You will not yet know all the codes, but you will know a ‘working selection’. Likewise you will eventually get to know the teleprint equivalents (p. 3), but this is likely to be slower, chiefly because it is less essential to know them. ... Later it will be desirable to know the teleprint equivalents of the single characters by heart, but it is never necessary to know the equivalents for pairs of characters.
Here Turing explains general algorithm for loops for this machine.Counting procedure
One of the commonest operations is a sequence of instructions to be repeated a givennumber of times. ...
Turing explains how to do "case of" integer number using indexing registers of machine (jump table).Discrimination by control transfer
When two cases have to be given quite different treatment, involving different se-quences of instructions, it is natural to choose the relevant sequences by a test in-struction (i.e. conditional transfer/T,/H,/M, or/O). ...
Loops unrolling!Omission of counting
If the operation to be repeated contains rather few instructions e.g. three, and is crucial for the speed of the whole process it may be best to omit the instructionsconcerned with counting and to repeat the instructions concerned with the process inquestion the requisite number of times.
This trick is still usefull in assembler.Alternative entry
It is often necessary to have a number of routines differing in certain minor particulars. One would like to use essentially the same instructions for all of them. The most convenient method seems to be to use one assembly of instructions, with various points of entry. The cues of these routines will then differ only in their first ten digits.
I suppose it can be done if next calculations can be changed to include "-1" for correction.Changing sign in the accumulator
The instruction DSTJ has the effect A′={1−A±} which for most purposes is as good as A′={−A±} which can only be achieved in two instructions, or more if 80 digits are required.
Here Turing notes instructions automatically clearing accumulator and some general calculation facts, like "If an expression of form a+bc is required and the accumulator is not clear the term 'a' should be put into the accumulator first.".Clearing the accumulator
The beginner is liable either to leave things in the accumulator to get mixed upwith the next calculation or else to put in accumulator clearing instructions which could easily have been avoided. In fact it is very seldom necessary to give a specialinstruction for clearing the accumulator, if the points below are held in mind. ...
Electronic RAM worked faster than magnetic drum memory, so here Turing recommends some methods of it's economy. For example - placing useful data in address part of addressless instruction.Electronic space economy measures
We have explained that the economising of instructions in order to reduce the spaceoccupied in the magnetic store is seldom worth while. There are however occasionswhen it is worth while to economise them to save space in the electronic store. ...
Well... I would say many of this techniques still are useful in modern retroprogramming.