Est. 1949 Advanced

Assembler (EDSAC)

The symbolic order code of the Cambridge EDSAC, loaded by David Wheeler's Initial Orders — widely described as the world's first assembler, and the system that introduced the subroutine library, the relocating loader and the programming textbook.

Created by Order code designed by Maurice Wilkes and the Cambridge University Mathematical Laboratory; the Initial Orders that turned it into a symbolic language were written by David Wheeler

Paradigm Assembly, Imperative, Low-level
Typing None (untyped). Accumulator and multiplier held signed binary fractions; each order carried an S/F or L/D flag selecting a 17-bit short or 35-bit long operand
First Appeared 1949
Latest Version No versioned standard. Initial Orders 1 (31 orders, May 1949) was replaced by Initial Orders 2 (41 orders, September 1949), which served until EDSAC was shut down on 11 July 1958

EDSAC assembly language is where writing programs in letters instead of binary begins. The Electronic Delay Storage Automatic Calculator ran its first fully automatic calculation at the University of Cambridge Mathematical Laboratory on 6 May 1949, and from that first day programs reached it not as bit patterns but as characters punched on five-hole paper tape — A 15 F, T 64 K, E Z P F — which a small fixed program called the Initial Orders read and converted into orders in the mercury delay-line store. That fixed program, written by the research student David Wheeler, is routinely described as the world’s first assembler.

What makes EDSAC’s system remarkable is not merely that it existed first. Within a few months it also had relocation, a parameter mechanism for position-independent code, a convention for calling and returning from subroutines, a catalogued library of those subroutines on tape in a filing cabinet, and, by 1951, a textbook explaining the whole practice to outsiders. Almost every idea in that list is still in use.

The machine underneath

EDSAC’s store was a set of temperature-stabilised mercury delay lines. Accounts of its size differ in how they count: Martin Richards describes 512 words of 35 bits, each splittable into two 17-bit halves addressed separately, while the machine is more often described as having 512 short (17-bit) locations at the outset, a second battery of delay lines brought into service in 1952, and the full 1024 short locations reportedly not dependably available until 1955 or 1956. Two registers were visible to the programmer: a 71-bit accumulator and a 35-bit multiplier register. Numbers were signed binary fractions in the range -1 ≤ x < 1, with the binary point immediately below the sign bit, though integers were routinely worked with by scaling.

An order occupied 17 bits:

   5 bits     1 bit    10 bits    1 bit
 +---------+--------+-----------+-------+
 | op code | unused |  address  |  S/L  |
 +---------+--------+-----------+-------+

On tape, an order was simply the character whose five-bit code was the operation code, followed by the address in decimal, followed by S or L (in the later notation, F or D) to set the length bit. R16S assembled to 00100 0 0000010000 0; T11L to 00101 0 0000001011 1. There was no translation table to speak of — the mnemonic letter and the opcode were the same five bits, which is exactly why the first Initial Orders could fit in 31 words.

Speed, for context: the machine executed roughly 600 orders per second, read paper tape at 50 characters per second and printed at nearly seven characters per second on a Creed teleprinter. Those are the figures quoted for the original machine and its peripherals, not a benchmark against anything else; there was nothing to benchmark against.

The order code

OrderEffect
A nAdd the contents of n to the accumulator
S nSubtract the contents of n from the accumulator
H nCopy the contents of n into the multiplier register
V nMultiply, adding the product into the accumulator
N nMultiply, subtracting the product from the accumulator
T nTransfer the accumulator to n and clear it
U nTransfer the accumulator to n without clearing
C nCollate (logical AND) with the multiplier, adding into the accumulator
R, LArithmetic shift right or left, the distance encoded by the least significant one bit of the address
E nJump to n if the accumulator is ≥ 0
G nJump to n if the accumulator is < 0
I nRead the next five-bit tape character into n
O nPrint the character in the top five bits of n
F nVerify the last character output
XNo operation
YRound the accumulator (add one at bit 35)
ZStop the machine and ring the bell

There is no divide order and, in the machine as programmed here, no index registers — indexing was invented elsewhere around 1950, and Wheeler is reported to have designed an index register for EDSAC only in 1953, after a stay at the University of Illinois. Division was a library subroutine, and walking through an array meant writing self-modifying code that added a constant to the address field of an order held in store. The 1949 squares program modifies its own T order in location 25 to advance the load address, and does something similar to cycle an A order through a table of powers of ten.

There is also no “equals” test: E branches on non-negative and G on negative, so loops were customarily written to count up to zero from a negative starting value.

Initial Orders 1: an assembler in 31 words

The first Initial Orders were placed in locations 0 to 30 by uniselectors — mechanical read-only memory — when the machine was started, and execution began at location 0. The loop is short enough to summarise: read a character and shift it into the top five bits of a word to form the opcode; read decimal digits, accumulating value × 10 + digit by multiplying against a constant 10 << 11 held in the multiplier register; read S or L and derive the length bit from it; assemble the three parts and store the result with a T n S order in location 25 whose own address field is incremented on every pass.

Several words do double duty. Location 2 contains T0S, which is both a working instruction and the bit pattern 00101000000000000 used as a multiplier constant. Locations 4 and 5 sit in the middle of the code and are jumped over because they hold the constants 2 and 10. The first order on every program tape has to be a T n S whose address marks the end of the program, because the loader compares it against the running store pointer to decide when to stop loading and fall through into the program.

It worked, and it was a decisive improvement on toggling in binary. But every address was absolute. Inserting one order meant renumbering the destinations of every branch that crossed it, and a subroutine could only live at the address it was written for — which made a shared library nearly unmanageable.

Initial Orders 2: relocation, code letters, control combinations

Wilkes gave Wheeler the problem, and in September 1949 the new version went in. The budget was 42 orders; Wheeler used 41. Contemporaries called it “the leading example of programming virtuosity”, and the description is not really an exaggeration.

The new system added control combinations — what a modern assembler calls directives:

CombinationMeaning
T m KSet the load point to m (the equivalent of ORG)
G KSet the θ parameter to the current load point
T ZRestore the previous θ parameter
E m K P FEnter the program at location m
E Z P FEnter the program at location θ
P Z, P KStart of a new tape block

and code letters. The terminating letter of an order no longer just chose the operand length; it named a store location whose contents were added to the order’s address as it was loaded. There were fifteen code letters: F referred to a location holding zero, θ to the origin of the current routine, D to one, and φ, H, N, M through V were left free for the programmer. Writing A 5 θ therefore meant “add the contents of the location five words past the start of this routine”, and the routine could be loaded anywhere.

That single mechanism is what made the subroutine library practical. A tape could be copied onto the front of a program unchanged, preceded by a T m K and a G K that placed it, and the routine’s internal references would fix themselves up at load time. The conventional layout was to load from location 56 upwards, packing subroutines and the master routine end to end with no gaps, working out the addresses from the lengths published in each routine’s specification.

Here is a complete hello-world program in the notation of the period, taken from Campbell-Kelly’s tutorial guide. It prints HI rather than Hello World because, as the guide puts it, the longer message “would make the program rather longer than necessary”; @ is how the simulator writes the θ code letter in plain ASCII:

T64K        load from location 64
GK          set θ to the load point
ZF          0: stop
O5@         1: print letter shift
O6@         2: print "H"
O7@         3: print "I"
ZF          4: stop
*F          5: letter-shift character
HF          6: "H"
IF          7: "I"
EZPF        enter at θ

Changing T64K to T56K moves the whole program. The leading stop order is deliberate: programs were loaded on a tank boundary and halted so the operator could check on the monitor tube that the tape had read in correctly before pressing Reset.

The Wheeler jump

EDSAC had no call instruction, so the return address had to be manufactured. The calling sequence became the standard idiom:

   m    A m F      pick up this order itself into the accumulator
   m+1  G n F      jump to the subroutine at n
   m+2  ...        control returns here

   n    A 3 F      form the return link from a constant kept in location 3
   n+1  T p F      plant it as the final order of the subroutine
        ...
   p    ( E m+2 F )  return link planted here

The trick is that A m F loads its own bit pattern, which the subroutine then arithmetically converts into an E m+2 F jump and stores over its own last order. Wilkes, Wheeler and Gill’s presentation of this — together with the discipline of closed subroutines that could be called from anywhere and the catalogue that documented each one’s entry conditions, length and running time — is the ancestor of the calling convention and the library specification alike.

The textbook

The Preparation of Programs for an Electronic Digital Computer, published by Addison-Wesley in 1951 and universally known as Wilkes, Wheeler and Gill or WWG, grew out of a September 1950 laboratory report circulated to about a hundred people. It is the first book on programming. Beyond the order code and the Initial Orders it contains the first published account of a reusable code library with per-routine specifications, an early description of debugging by memory dump — the “post-mortem routine” — and a working argument, stated plainly in its own introduction, that programming should be an ordinary activity for scientists rather than “something of a magic art, closed except to a few specialists”. A second edition followed in 1957.

Why it matters

EDSAC’s order code is a small and awkward instruction set, and taken on its own it would be a footnote. What makes it foundational is everything Wheeler wrapped around it in 1949: the recognition that the human-readable form of a program and the loader that translates it are themselves software, that translation can do arithmetic on addresses, and that if it can do that then code becomes movable, and if code is movable it becomes shareable.

Every assembler since has been a bigger version of the same argument. The ORG directive, the relocating linker, the object library, the calling convention, the documented API entry and the idea that you look programs up in a catalogue instead of writing them again — all of them are visible, in miniature, in 41 orders written by a Cambridge research student in September 1949.

Trying it today

EDSAC has no Docker image and no compiler that targets it, but the language runs. Martin Campbell-Kelly’s simulator, maintained at Warwick and distributed through the EDSAC Replica Project, reproduces the machine’s front panel, both sets of Initial Orders, the original subroutine library and the original program documentation, and ships with a tutorial guide that includes the summer-school exercises. Andrew Herbert has published a small EDSAC assembler in Python — written for short test programs loaded through the replica’s signal sequence injector — and a command-line EDSAC emulator in C. And at The National Museum of Computing at Bletchley Park, volunteers are building a working replica intended to run the same tapes in mercury-delay-line hardware.

Timeline

1946
Construction begins at the University of Cambridge Mathematical Laboratory under Maurice Wilkes. A Daily Telegraph report of June 1949 describes a team of ten assembling EDSAC's 120 racks of valves "since early in 1946"
1949
EDSAC performs its first fully automatic calculation on 6 May 1949, printing a table of squares. David Wheeler's first Initial Orders — 31 orders held on uniselector switches and read into locations 0-30 at start-up — convert orders punched as a letter, decimal digits and a terminating S or L into binary and load them into store
1949
Maurice Wilkes writes the annotated squares-and-differences program in June 1949, printing the squares of 1 to 100 with first differences; it survives as the best-known specimen of first-generation EDSAC coding
1949
Initial Orders 2, again by Wheeler, replaces the first version in September 1949. Constrained for engineering reasons to 42 orders and written in 41, it adds code letters, relocation against a settable parameter and control combinations such as T m K and G K — an assembler and relocating loader in a program shorter than most modern hello-world binaries' headers
1949
The EDSAC subroutine library begins to take shape from the autumn onwards, with routines classified by a group letter (P for printing, D for division) and a serial number within the group; tapes are kept in cardboard boxes in a steel filing cabinet
1950
Wheeler publishes "Programme organization and initial orders for the EDSAC" in Proceedings of the Royal Society A, vol. 202, no. 1071, pp. 573-589, dated 1 August 1950 — the first published account of an assembly system
1950
The Mathematical Laboratory issues "Report on the Preparation of Programmes for the EDSAC and the Use of the Library of Subroutines" in September 1950, circulated to roughly a hundred recipients; it becomes the draft of the following year's book
1951
Wilkes, Wheeler and Gill publish The Preparation of Programs for an Electronic Digital Computer (Addison-Wesley), the first textbook on programming, describing the order code, the Initial Orders, the Wheeler jump and a catalogued library of subroutines
1951
LEO I, built by J. Lyons & Co. and modelled closely on EDSAC, begins operating — carrying EDSAC's programming methods into the first business computing service
1951
Wheeler is awarded a Cambridge PhD for the thesis Automatic Computing with the EDSAC, often described as the first doctorate in computer science. In the same year Miller and Wheeler use EDSAC to find a 79-digit prime
1952
Sandy Douglas, a Cambridge PhD student, writes OXO, a noughts-and-crosses program played against the machine through the telephone dial and the monitor tubes — commonly cited as one of the earliest graphical computer games
1957
A second edition of The Preparation of Programs for an Electronic Digital Computer appears, by which time the machine it documents is nearly obsolete
1958
EDSAC is shut down on 11 July 1958, superseded by EDSAC 2, which runs until 1965
2010
David Hartley, then Chairman of the Computer Conservation Society, proposes rebuilding EDSAC; volunteers first meet in March 2012 and construction proceeds at The National Museum of Computing at Bletchley Park, aiming to recreate the machine broadly as it stood in the early 1950s

Notable Uses & Legacy

The EDSAC subroutine library

The first catalogued library of reusable code. Routines were grouped by letter and serial number (P6, for example, prints a short positive integer; its published specification gives 32 storage locations and a running time of about 900 milliseconds per number on the original machine — a figure from the routine's own library entry, not a comparison against any other machine) and were copied from library tapes onto the program tape at punching time. Wilkes, Wheeler and Gill's 1951 book published the library along with specifications for each routine; the library eventually grew to nearly a hundred subroutines.

LEO I at J. Lyons & Co.

The Lyons Electronic Office was modelled closely on EDSAC and went into operation in 1951 running clerical and valuation jobs for the catering company — the first use of a stored-program computer for routine commercial work. Its debt to Cambridge was architectural and methodological alike: the order code, the delay-line store and the subroutine-library style of programming all came across.

Scientific computing at Cambridge

EDSAC ran as a service for the whole university rather than as a laboratory experiment. Wilkes and Wheeler used it in 1950 to integrate a differential equation on gene frequencies, reported as the first use of a computer for a problem in biology, and in 1951 J. C. P. Miller and Wheeler used it to find a 79-digit prime, then the largest known.

OXO

Sandy Douglas's noughts-and-crosses program, written in EDSAC orders around 1952 as part of doctoral work on human-computer interaction. The player entered moves on a telephone dial and the board was drawn on one of the machine's cathode-ray monitor tubes.

Teaching programming

Cambridge ran summer schools on EDSAC programming from 1950, and the exercises set there — along with the original subroutine library and program documentation — are still distributed with Martin Campbell-Kelly's EDSAC simulator, which reproduces the machine's controls and both sets of Initial Orders.

Simulation and reconstruction

The language is still executable. Campbell-Kelly's Warwick simulator runs original tapes under Initial Orders 1 or 2 on Windows, macOS and Linux; Andrew Herbert has published a small EDSAC assembler in Python (written for test programs loaded through the replica's signal sequence injector) and a command-line emulator in C; and the volunteer replica at The National Museum of Computing is being built to run the same order code in hardware.

Language Influence

Influenced

LEO

Running Today

Run examples using the official Docker image:

docker pull
Last updated: