The EDSAC Valve Computer

I attended an interesting talk from Andrew Herbert, hosted by The National Museum of Computing, about coding on the EDSAC or Electronic Delay Storage Automatic Calculator. This was a valve computer built by a team from the Cambridge University Mathematical Laboratory, led by Maurice Wilkes and Bill Renwick. Designed in 1947 and completed in 1949, EDSAC was amongst the worlds earliest fully electronic computers to see practical service, with the Manchester Mark I also entering use at around the same time. It had been preceded by the Manchester "Baby", completed in 1948, but this was used only as an experimental machine. Another well-known predecessor was ENIAC, which was completed in 1945 and used for military calculations but this was not a stored program computer. ENIAC was programmed by setting the positions of switches on a panel. EDSAC improved on this and operated more like a modern computer by loading machine code programs from a storage device into memory.
Transistors were only beginning to be invented when EDSAC was being designed and would not see widespread availability until the 1950s. Instead valves, also known as vacuum tubes, were the principle component used to implement the logic. A heater causes electrons to be produced in a process known as thermionic emission. In a vacuum the electrons are able to flow towards an anode (the plate). The flow of electrons between the heater and the plate effectively completes a circuit. However, the circuit can be turned off by applying a negative voltage to a wire mesh (the grid) that is located between the heater and the anode, which interrupts the electron flow. The ability to turn the electron flow on and off creates an electronic switch very similar to that of a transistor. From this action, all logic circuits can be constructed.

The EDSAC had 1024 18-bit words of memory implemented as mercury delay lines. Only 17-bits are of each word are usable, hence a little over 2K of RAM in modern parlance. So in the 1940s it still had more RAM than a ZX81! The delay lines were tubes filled with liquid metal and a sound wave sent though the metal would take some period of time to propagate from one end of the tube to the other. Data was stored in the wave as it travelled along the tube. When the data reached the end it would be fed back in again to refresh the state.
Apparently, half the RAM was usually broken at any one time so it was best to keep your programs under 512 words.
The machine has 14 CPU instructions (or maybe 19 depending how you count them) and can run at a blazing 650 instructions per second. That may not seem very fast, but it is when you compare it to the incumbent computing technology. It's apparently at least 1500 times faster than a postgrad student with a mechanical calculator. Even though the machine is extremely slow and limited by any modern standard, when you express it in the context of the contemporary available alternatives, that it could perform work equivalent to 1500 people without error and operate 24 hours a day, the value of the machine becomes apparent.
Mass storage is delivered via a 50 character per second paper tape reader and program output is to teletype. Two of the instructions are used for input and output respectively. It also has a specific instruction to ring a bell to let the operator know the program has finished.
Amazingly it is possible to do graphical video display. The system was equipped with three CRT oscilloscopes, the centre of which shows the state of the memory delays lines. The RAM is implemented as two banks of 32 delay lines (each storing 16 x 18-bit words) and the oscilloscope can show the state of any one of the delay lines in full. The exact line being displayed is selected by a rotary switch. Each dot on the oscilloscope represents one bit. Hence by setting relevant bits in the memory the machine can display an image on the screen; in effect it is a bitmap graphics display.

Coding for the EDSAC is performed in a form of assembly language and is a surprisingly familiar experience. There is an emulator available which is shown here running on Linux. I got as far as "Hello World" in EDSAC assembly. The teletype output is represented in the top right window. The code is in the left hand window, which would have been input encoded onto paper tape in the real system. The pattern of green dots in the middle is a simulation of the oscilloscope display showing the memory state of one delay line. The "long tank" selector chooses which delay line is shown.

The "O" assembler instruction outputs a character to the teletype. The characters are picked up from the referenced memory addresses. I did not figure out how to do a space character! There's also some directives (not machine instructions) at the start and end of the code that indicate to the bootstrap loader to load the paper tape and what to do with the program. It's got a kind of combined BIOS and assembler that manages your program called "Initial Orders". Here we're loading the code into memory location 64 onwards (indicated by T64K). The next "GK" directive sets a program counter offset to the load point. The code is relocatable, just like on a modern computer, and can be loaded anywhere in RAM. Memory locations are relative to the load position. The next instruction actually causes the CPU to halt which was apparently best practice so that you can verify on the display that the program has actually loaded into memory properly before running it.
Things EDSAC assembler makes hard are: it didn't originally have an index register because the concept hadn't been invented at the time of machine's design, although the machine did acquire one some years later when this was figured out. To deal with a vector you ended up doing tricks with self modifying code. Neither did it have a subroutine jump instruction because that concept hadn't been invented yet either, although there was a trick called a "Wheeler jump", named for the inventor David Wheeler, that achieved the same effect.
I fired up the games library, like this classic from 1952 called "OXO". This may have been the first ever computer game, although as with any "first", it's always hard to tell and depends how you define it.

To make your selection of square, you need an interactive input device and this computer does not have a keyboard. Input is handled by a mechanical rotary telephone dial, which is represented on the emulator in the bottom right of the screen. In this game, dialling a digit enables you to choose one of the nine positions on the noughts and crosses board.
Image credits: EDSAC Computer Photo by the University of Cambridge, EDSAC Display Tubes by the University of Cambridge, Valves image by Mister rf