Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

This has just dawned on me that if you're writing an operating system then what are you writing it on? I ask this as I am reading a microprocessor fundamentals book from 1980 and this question popped in to my head:

How was the first microprocessor chip programmed?

The answer may be obvious but its bugging me.

share|improve this question
If I may be permitted to plug my own work, see my answer to "How can the Linux kernel compile itself?" on Stack Overflow. The answer is not obvious until you understand the general principle, at which point you'll say "Well, of course..." –  dmckee Jan 7 '11 at 1:21
@dmckee But it still doesn't answer the question how did it know what to do :) who told the computer with the switches what to do? I want a little more detail. –  Dean Jan 7 '11 at 1:24
So the question is about designing the boot sequence of the first chip? Well, that is certainly a question that belongs on this site, but it proceeds like designing a digital logic built from components....get it to start in a known state, then feed it inputs that will do useful things. I'll leave it to other to provide the detailed answer, because I'm shaky on that, but you do know that the first computers were implemented in vacuum tubes, right? Then there was a generation in individual transistors, all before the first micro chip. The engineers already knew what they were doing. –  dmckee Jan 7 '11 at 1:26

9 Answers 9

up vote 41 down vote accepted

I will take your question literally and discuss mostly microprocessors, not computers in general.

All computers have some sort of machine code. An instruction consists of an opcode and one or more operands. For example, the ADD instruction for the Intel 4004 (the very first microprocessor) was encoded as 1000RRRR where 1000 is the opcode for ADD and RRRR represented a register number.

The very first computer programs were written by hand, hand-encoding the 1's and 0's to create a program in machine language. This is then programmed into the chip. The first microprocessors used ROM (Read-Only Memory); this was later replaced by EPROM (Erasable Programmable ROM, which was erased with UV light); now programs are usually programmed into EEPROM ("Electrically...-EPROM", which can be erased on-chip), or specifically Flash memory.

Most microprocessors can now run programs out of RAM (this is pretty much standard for everything but microcontrollers), but there has to be a way of loading the program into RAM in the first place. As Joby Taffey pointed out in his answer, this was done with toggle switches for the Altair 8080, which was powered by an Intel 8080 (which followed the 4004 and 8008). In your PC, there is a bit of ROM called the BIOS which is used to start up the computer, and load the OS into RAM.

Machine language gets tedious real fast, so assembler programs were developed that take a mnemonic assembler language and translate it, usually one line of assembly code per instruction, into machine code. So instead of 10000001, one would write ADD R1.

But the very first assembler had to be written in machine code. Then it could be rewritten in its own assembler code, and the machine-language version used to assemble it the first time. After that, the program could assemble itself. This is called bootstrapping and is done with compilers too -- they are typically first written in assembler (or another high-level language), and then rewritten in their own language and compiled with the original compiler until the compiler can compile itself.

Since the first microprocessor was developed long after mainframes and minicomputers were around, and the 4004 wasn't really suited to running an assembler anyway, Intel probably wrote a cross-assembler that ran on one of its large computers, and translated the assembly code for the 4004 into a binary image that could be programmed into the ROM's. Once again, this is a common technique used to port compilers to a new platform (called cross-compiling).

share|improve this answer
Great answer tcrosley! Corrected a tidbit about EEPROM vs EPROM. +1 –  tyblu Jan 7 '11 at 7:12
And if you really wanted to program a microcontroller without another computer (besides your brain) you could do so by building circuitry that fed the program into it directly. If was programmed over jtag then you could flip switches to mimic the jtag commands needed to program the device. If it used external ram then you could use a lot of demultiplexors and huge arrays of resistors tied high or low to represent the bits of the instructions (and probably use a low clock speed because your hardware will be slow). –  nategoose Jan 7 '11 at 17:05
@tyblu, thanks for the edit. –  tcrosley Jan 7 '11 at 18:26
@tyblu: I'm pretty certain fuse-PROMs predated EPROMs. The simplest form of ROM is essentially a selectively-populated diode array (in early days, diodes would literally be soldered onto a grid to represent one polarity of bit; a missing diode represented the other polarity). A fuse-PROM puts a diode array on a chip, but has row transistors which are much beefier than the diodes at the intersections. One could selectively remove diodes by setting the address wires and then hitting really hard the data wires connected to the diodes one wanted to remove. –  supercat Mar 11 '11 at 19:17
check out this 'ROM' from the days of discrete transistors: en.wikipedia.org/wiki/Core_rope_memory –  JustJeff Apr 15 '11 at 12:47

Originally, programs were written on paper, and then transposed to whatever input method the computer had available. This went from knobs, switches, and jumper wires on the first computers, to punch cards, to keypads/boards.

The illustration below shows what present-day real programmers use:

share|improve this answer
Dammit, emacs.. –  tyblu Jan 7 '11 at 7:18
I program programmers. (And those programmers I program program programmers who program programmers.) –  muntoo Jan 8 '11 at 0:27
I make my own programmers. –  W5VO Jan 8 '11 at 5:31

Well I was around when micros first came out, we wrote cross assemblers and compilers on mainframes and minis, then we bootstrapped them onto 8-bit hardware, people didn't really bother building compilers/assemblers on micros until they had enough local storage to make it useful

share|improve this answer

One early form of read-only memory was a grid where the the address would select a row (pulling it low), and the columns represented data. Each column would have a pull-up, and each intersection would have a diode soldered in to represent a "zero", or no diode to represent a "one" [bit levels could be inverted if desired, in cases where that would reduce the number of diodes required]. Any desired pattern of bits could be "programmed" by soldering in the proper diodes.

This design was brought into the integrated-circuit world in the form of a fuse-PROM. Essentially a fuse PROM was a circuit just like the above, built onto a chip, except that all diodes were populated, and every diode had a weak fuse in series with it. As shipped, a PROM would read "0" at all locations. One could, however, selectively remove diodes by selecting the appropriate address and driving the appropriate data lines "hard" high [note: I think each bit may have had its own transistor, rather than a diode, but the principle is the same].

Fuse-programmed PROMs were succeeded by semiconductor memories, which store bits by implanting charges on internal capacitors. Not only are such memories more compact than fuse-PROMs, but if they are housed in UV-transparent packages they may be erased and reused. Note that even so-called "one-time programmable" memories almost always use this same design, but are simply housed in UV-opaque packages.

two men pointing at a large diode matrix diode-matrix control store of the 1950 MIT Whirlwind Computer

transistor-matrix with tiny SMD transistors transistor-matrix control store of 2005 the MT15 CPU

share|improve this answer
hope you don't mind the little tweak I made to your post. –  davidcary Apr 15 '11 at 1:14

An operating system is a computer program which runs directly on the processor. It can be written in any language which can be compiled or assembled down to machine instructions. Assembly and C are common choices.

Code is loaded into processors a single instruction at a time from a store - a ROM or RAM.

The Z3, the first programmable processor was built out of electromechanical relays and read instructions from punched film.

The Altair 8800, the first personal computer, was programmed by toggling switches.

To learn how a processor is constructed from digital logic, see A fun book to learn computer architecture (for not-exactly-beginners).

For a history, see http://en.wikipedia.org/wiki/History_of_computing_hardware

share|improve this answer

Here's a bit about really old computers:

As far as I know, back in the days, you had a big computer front panel which was used to program them. Basically, each memory cell in those computers was connected to switches. You'd power the memory and then use switches to set data in each cell. This way, you'd input program bit by bit into computer's memory. Then you'd set starting point of the program and start execution.

As technology progressed, so called bootloader programs were developed. They are short programs whose whole point is to start another program from computer's memory. The problem with entering programs bit by bit (and the later more than one bit using octal and later hexadecimal numbers) was that it was very slow and there was big chance that operator would make a mistake while loading the program. So short programs would be used to load larger programs stored in computer's memory. As time progressed, portion of code which had to be entered by hand decreased and in modern computers we often have bootloaders written in some sort of ROM or even flash memory.

share|improve this answer
In 'front panel' machines, like the earlier S-100 systems, the switches let you take control of the system bus. One switch would let you suspend the processor. While the processor was suspended, you could then manually put an address on the address bus (via switches), put data on the data bus (more switches), and then manually cause a write-cycle on the bus (another switch), or a read-cycle to pull data back to 8 individual LEDs and read the binary, etc. Doing this, you could store enough machine code in RAM, un-suspend the processor, and go from there. –  JustJeff Apr 15 '11 at 12:57

I'm not sure that anyone has addressed the OP's real question, which seems to be "How does the computer know how to get started?", so I'll take a crack at it.

Start with an analogy. "How does a transistor know how to get started?" Of course, it doesn't, it just works in accordance with physics, and the engineer builds the circuit so that it starts in a known state.

Computers know how to get started because they are circuits (very complicated, of course) and they are built to start in a particular state. In a modern machine that state might be one in which the main bus remaps part of the address space to user a ROM on the motherboard as low memory (the ROM having been burned with a BIOS). In a first generation machine the initial state might have been CPU halted, the program counter at zero, and memory toggle sub-system active.

share|improve this answer

I few years ago came across a microcontroller programmer which had a 4 digit seven segment display, and a hex keypad. I'm sure this didn't have a microcontroller on board and allowed you to enter machine code directly a byte at a time.

So this would allow you to (painfully) compile a list of Op codes manually one by one and enter them into the chip.

I have no idea if you can still get them, but I'm guessing that something similar was used back when microcontrollers were relatively new.

share|improve this answer
Sounds like possibly the KIM-1 or Cosmac ELF, both of which included a microprocessor (MOS 6502 and RCA [CD]1802). KIM: oldcomputers.net/kim1.html ELF: cosmacelf.com –  mctylr Jan 16 '11 at 2:57
It was probably something like what mctylr said. In machines of this type, there was usually a small 'monitor' program in ROM. When you entered bytes with the keypad, it was actually the 6502 (or 8085 or whatever) reading the keys, modifying memory, updating the LEDs, etc. –  JustJeff Apr 15 '11 at 12:53

The first microprocessors would have been programmed with the help of existing computers which were not based on microprocessors. Before the first CPU was produced on one chip, there already existed advanced computer architectures which were built from discrete components rather than microprocessors. Take a look at, oh, say, IBM 360.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.