IBM 704
This is a from-scratch, in-browser emulator of the IBM 704 Electronic Data-Processing Machine, announced in 1954: 36-bit sign-and-magnitude words in core memory, floating point in hardware, and three index registers that are subtracted and not added. The machine is modelled from IBM's Manual of Operation, instruction by instruction and with its cycle times, together with the 711 card reader, 716 printer, 721 card punch, 727 tape units and 733 drums.
By default it does the thing the 704 is remembered for. A real FORTRAN source deck goes in the reader, IBM's FORTRAN II compiler loads from tape section by section, works through its drums and tapes, lists the program on the printer and punches a binary deck. Then that deck goes back in the reader and runs. The program is Matrix Inversion Order 5 from about 1958, and its printout agrees with one from a real 704 down to the last rounded digit.
The surface is the operator's console: neon lamps for every register, the 36 panel switches, the sense switches and lights, and the Start, Reset, Clear, Load and Manual keys, all live. Other configurations compile the first example in IBM's FORTRAN Primer, its polynomial fit, and a sieve of primes written for this site, or run the SHARE assembler UA SAP. You can type your own FORTRAN into the reader and compile it.
Because the entire machine is plain JavaScript, it plugs into the shared debugger: single-step, disassemble both instruction types in octal, set breakpoints and write watchpoints, and read core and drums live.
Runs on: Web browser
IBM 704 Online Emulator
Play IBM 704 using JavaScript directly in your browser.
Controls
Configurations
| Configuration | Emulator | Machine | OS | Legal | |
|---|---|---|---|---|---|
| FORTRAN II compiles Matrix Inversion Order 5 (1958) | IBM 704 | IBM 704 | grey | Open ⛶ | |
| FORTRAN II compiles the Primer's first example (IBM, 1957) | IBM 704 | IBM 704 | grey | Open ⛶ | |
| FORTRAN II compiles the Primer's polynomial fit | IBM 704 | IBM 704 | grey | Open ⛶ | |
| FORTRAN II compiles a sieve of primes (written for this site) | IBM 704 | IBM 704 | grey | Open ⛶ | |
| UA SAP 3 assembles a loader (SHARE) | IBM 704 | IBM 704 | grey | Open ⛶ | |
| Blank machine, console only | IBM 704 | IBM 704 | open | Open ⛶ |
Machines emulated
Chips
Notes
Embedding
The core has no dependencies and no DOM, so it runs under Node as well as in a page. Load it, add the console if you want one, and own the loop:
<script src="ibm-704.js"></script> // window.IBM704, the machine
<script src="ibm-704-render.js"></script> // window.Console704, the console on a canvas
var m = new IBM704({ core: 4096 });
m.tapes[1].mount(systemTapeBytes); // SIMH p7b bytes
m.loadText(fortranSource); // punched cards in the 711 hopper
m.sw = [0,1,1,0,1,0]; // sense switches: down is 1
m.load(0o221); // the Load Tape key
m.run(m.cycles + 83333); // one second: a cycle is 12 microseconds
console.log(m.paperLines());
| Member | What it does |
|---|---|
m.run(c), m.step() | Run up to cycle count c or until something stops the machine; or one instruction. |
m.load(a) | The load keys: 0o321 card, 0o221 tape 1, 0o301 drum 1. |
m.start(), m.reset(), m.clear() | The Start, Reset and Clear keys. |
m.core | Words as doubles from 0 to 2^36-1, with the sign at 2^35. |
m.acS, m.acM, m.mqS, m.mqM, m.xr, m.pc | The accumulator and MQ as sign and magnitude (37 and 35 bits), index registers A B C, location counter. |
m.hopper, m.punched, m.paperLines() | Cards in the reader, cards out of the punch, and what the printer has produced. |
m.tapes[n], m.drums[n] | Tape units 1 to 10 and logical drums 1 to 8. |
Tape and card files are SIMH p7b, so a tape made here reads on SIMH and the other way round.
Debugger integration
The plug-in is ibm-704-debug.js, with a new decoder, /debugger/src/cpus/ibm704.js, for both instruction types.
Registers are octal and the debugger's fields are hexadecimal, so a register is shown packed: IC showing 00344 means octal 344, and typing octal digits writes it back. A digit above 7 is refused. A word is split into .H and .L, of the high and the low 18 bits. The signs are the flags AC- and MQ-, since the machine's arithmetic is sign and magnitude.
Memory. The core chip is word addressed, so the disassembler, the PC and breakpoints all follow the machine's addresses, but the shared address column and address fields work in hexadecimal. Each disassembly line starts with the real address in octal, as in @00344. The hex column of this chip shows the low eight bits of a word. core6 and drum1 to drum4 show every digit, six packed bytes a word. Reads go straight to the arrays and have no side effects.
Single step is one instruction. Execution breakpoints are checked before each instruction, against the location counter. Write watchpoints hook the one write path into core, which stores and input from a CPY both use. Pausing the debugger stops the emulator's clock and leaves the machine alone. The console keeps its own Single Step and Multiple Step keys on Manual, as on the machine.
Architecture
The IBM 704 was announced in 1954 and delivered from 1955. It was the first mass-produced computer with floating point in hardware, one of the first with core memory as standard, and the machine FORTRAN was written for. This model is the 4,096-word machine for FORTRAN, with the 8,192-word machine for the assembler. Addresses, the location counter and the index registers have only as many bits as the core needs, as the manual says.
- The word is 36 bits, sign and magnitude. The accumulator has two more, Q and P, so 38 in all. The MQ has 36. Plus zero and minus zero are different numbers, and CAS sees it.
- Index registers are subtracted.
CLA 2117,2takes its word from 2117 minus index register B. That is why TSX stores the two's complement of its location, and why a tag naming two registers ORs them. All of this is modelled. - The instruction set is the manual's, with its fundamental cycle times, 12 microseconds each: type I for shifts, type II for floating-point alignment and normalising, type III for input-output delays, type IV for a zero dividend. STZ and CAD are later than the 1955 manual, and the FORTRAN II listings need them, so they are here too.
- Floating point follows the numbered steps in the manual: 8-bit excess-128 characteristic, 27-bit fraction, the second word in the MQ with a characteristic 27 lower. When the two signs differ the MQ really does keep the smaller number's sign, which later machines changed.
- Input-output is programmed: there are no channels, and the MQ carries every word. A CPY waits until the word is at the brushes or the head. The timetable for each device uses the rates in the manual: 711 reader at 250 cards a minute, 721 punch at 100, 716 printer at 150 lines, 727 tape at 2,500 words a second, 733 drum at one word in 96 microseconds. A record starts when its sector next comes round, on a 24.6 ms revolution. The skips at end of record and end of file are as the manual gives them. Tape records, tape marks, backspace and rewind are real, and the rewind takes time.
- The 716 printer is wired as a SHARE installation wired it: FORTRAN's operating manual calls for "Share Printer Board #2". Rows go out as the type wheels come up, with the echo impulses read back in the manual's order, so the library's checked printing sees a real echo. 72 columns come from core, and the carriage hubs give skip and space.
The software. FORTRAN II is IBM's, the final 704 compiler of 1958. The system tape was assembled from the compiler's listing, all 54,000 lines of it, by the SHARE assembler running on this emulator, and IBM's editor wrote the tape. The compile on the default page is that compiler running: a real source deck in the reader, intermediate files on the drums and tapes, the listing on the printer and an object deck out of the punch. Then the deck goes back in the reader. That program, Matrix Inversion Order 5, dates from about 1958, and every one of its 25 printed values agrees with a printout from a real 704, the last place included.
The Primer's first example is IBM's, from its 1957 primer. The polynomial fit is its later example, on data cards added for this page. The sieve of primes is a program written for this site, in FORTRAN II. Assembling with UA SAP is a real run of that assembler on a small card loader from the FORTRAN II listing.
LISP is not here. The LISP 1.5 that survives is written for the 7090 and its data channels, which this machine does not have.
Not modelled. The read-write check that stops the machine when a CPY comes too late, because the emulator waits instead of missing a row: the light does come on for a CPY with nothing selected. Plugging your own control panels. The 740 and 780 displays. End of tape, because a reel here does not run out. Parity failures, because nothing here can fail. The clutch phase of the reader and printer is within the manual's ranges rather than measured, and the punch's row timing is an estimate. Multiple-unit writing with the rotary selectors. The Operator button, the speed keys, the card picture, the tape position bars and the status line are the emulator's own. The Operator does what the operating manual asks: it presses Start when the reader runs out, then carries the punched deck to the reader, leaving out the blank cards, and clears the machine and presses Load Card.