Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: How did Paul Allen write an 8080 emulator in 1974?
53 points by andrewstuart 9 months ago | hide | past | favorite | 51 comments
Listening to the audiobook of “The Innovators” (highly recommend) today and the story tells of how Bill Gates wrote Basic for the Altair on an 8080 emulator written by Paul Allen in 1974.

How is this feat of computer programming not a major legend in computing history? Surely Paul Allen writing this emulator is even more impressive than Bill writing basic?




It didn't really match the modern definition of emulator. AKA, something that takes raw machine code and implements all the IO capabilities of the target device.

Instead, Paul Allen's emulator worked at the code source level, and was implemented as a macros for the assembler. This wasn't even an 8080 assembler, it was a PDP-10 assembler and they created a bunch of macros to output the proper bytes for 8080 machine code.

For PDP-10 mode, they switched to a different set of macros, that took the same source code but for each 8080 instruction, it generated one or more PDP-10 to replicated the behaviour of 8080. The source code also replaced the IO code with native PDP-10 IO routines. This gives you a PDP-10 binary that you can run as normal.

I'm sure Paul Allen could have written an 8080 machine code interpreter if he wanted to; It's really not that hard to make an emulator of a single CPU with limited IO, especially when the instructions are all documented. But the goal wasn't to emulate other people's 8080 binaries, the goal was to quickly create a programming environment to target the 8080 platform.


> I'm sure Paul Allen could have written an 8080 machine code interpreter if he wanted to

That's what I was thinking. These guys were pretty bright and an 8080 is not exactly a complex CPU. It wouldn't be a trivial task by any means, but I'm sure he or billg could have pulled it off.


Yeah I wrote one when I was in high school (on a PDP-10 running ITS in fact).

Don't get me wrong: I doubt it was enough enough to run a BASIC implementation but the 8080 instruction set is so simple that I was able to write a few simple bit-manipulation programs and believe they worked. I'm sure Allen's was much more capable, but it would not have needed to do any of the things expected of a modern emulator (timing, cache, complex addressing modes, interrupts...)


More like a cross compiler, perhaps


It's really not a cross compiler.

IMO, the problem that our modern definition of "emulator" is overly opinionated. The strict definition requires that the emulator take the CPU's machine code at runtime and either interpret it, or dynamically recompile it.

You could have an xbox emulator that dynamically recompiled x86 to x86 and everyone would agree that's an "emulator". But you make a few minor changes to that dynamic decompiler and turn it into a static decompiler and suddenly people start debating if it's still an emulator. If you go a step further and switch to using the CPU's virtualisation support or even just running the x86 code direction people will really put their foot down and say it's not an emulator. Despite the fact it's still emulating the GPU and Audio DSP and a bunch of other hardware.

The CPU is usually one of the simpler parts to emulate, the real complexity is in emulating the rest of the hardware, so I find it really weird that our definition of "emulator" only cares about how the CPU is implemented.

If we switch to a slightly less strict definition of "emulator" then there is nothing wrong with Paul Allen's 8080 emulator meeting the definition. It still emulates the behaviour of the 8080 cpu, so it is an emulator.


Sure, categorizing stuff is really hard. Almost anything looks like a compiler if you squint at it.


So.. like.. troff?


troff was a text oriented macro processor, based on roff, and almost certainly didn't run on the PDP-10, because it was written for unix. Roff was based on runoff, which was for IBM hardware. A more likely candidate would have been https://en.wikipedia.org/wiki/MACRO-10


roff was a descendent of TYPESET and RUNOFF; both preceded Unix.

https://en.wikipedia.org/wiki/TYPSET_and_RUNOFF

I would not be surprised if some version / implementation of roff ran on PDP-10 under some OS.


ITS, for sure.


So about the same time, in college in NZ we wrote a 6800 compiler for an algol like language (fit in 2k, written in assembler), to do bringup (on the university mainframe) we wrote a 6800 interpreter, it wasn't big ~1000 lines (cards), basically just a big case statement - it's not really a major feat, fom memory it took a few days. We called our company uSoft (with a mu), in retrospect it was a stupidly obvious name. Later on we discovered there was a US company using the same name, and they had an interpreter (how lame, we had a compiler).

In retrospect they had a giant market and we were kids at the end of the world, they did a little better than us. Always wished we'd trademarked the name, it would have been worth something


That’s an amazing story


thanks, I worked for one of Paul's companies at one point, sat down with him at a party and talked rockets (I flew them for fun, he was doing the X-prize), in retrospect I really wished I'd told him this story instead :-)


It wasn't that unusual. Microcomputers of the day were very limited, especially lacking memory. 4k RAM was considered to be a luxury. So many folks cross-developed using minicomputers. At my Uni, we often developed our tools on PDP-11 computers, especially using RSTS and BASIC, punched paper tape which could be read by hand fed paper tape readers. If you were lucky you had a ASR-33 terminal attached to your microcomputer or had a simple video card connected to a TV and a kludged up keyboard.

Development systems from Intel were almost as expensive as a cheap minicomputer.


There was a HN comment a while back from someone who worked on early 8-bit video game systems where they took a similar approach:

https://news.ycombinator.com/item?id=15005101


The 8080 was brought to market in April 1974 and it’s not unrealistic to assume that preliminary information on instruction encodings etc. was available earlier.

The 8008 would have been available already, but it was not binary compatible. However, an assembly translator was available (similar to the latter one translating 8080 asm to 8086).

So the question is if Allen wrote a binary emulator or perhaps something that interpreted asm source code? Maybe the emulator code is still hiding somewhere in the Microsoft archives… :)


Some background (and a bit of speculation) can be found in this retrocomputing StackExchange topic:

https://retrocomputing.stackexchange.com/questions/4984/how-...

And a bit more about the PDP10 macro assembler that was used (also for 6502 BASIC) at Michael Steil's site:

https://www.pagetable.com/?p=774


It was an 8800 emulator I believe, not 8080. (Edit - I’m mistaken - it was for the 8080 CPU)

Then they wrote the BASIC interpreter on the emulator, copied it to punched paper tape and Allen wrote the loader for that while he was on the plane to demo it for Altair.

On the real Altair 8800 hardware which they had never seen, it worked first time (they must have had some advance knowledge of the Altair’s I/O functions)

It was a series of amazing feats

https://en.m.wikipedia.org/wiki/Altair_BASIC

Edit: maybe this feat was not so famous because the Altair was not sold in numbers like the Apple II, which Steve Wozniak is well known for (25000 Altairs sold vs Apple’s 6 million - plus clones)


As far as I can remember, the Altair used an Intel 8080A processor. The Intel 8008 wasn't widely used by hobbyists. I don't recall any CPU with 8800 designation from that era. Possibly RCA or TI, but neither were used by Altair.

The Motorola 6800 and Mostek 6502 soon became more popular because they were easier to interface than the Intel 8080A. The Zilog Z80 came out a couple of years later.


You’re right. Thank you. I was misled by Altair 8800!

Intel did originally call their iAPX CPU the 8800, but that’s almost got to be an unrelated coincidence because the Altair 8800 was launched in late 1974, but the iAPX’s development didn’t begin at Intel until 1975. The iAPX is also an utterly diverse architecture and instruction set that Intel abandoned later, and they continued with the x86 line.

https://en.wikipedia.org/wiki/Intel_iAPX_432


The 6502 was also a lot cheaper -- around $25 compared to around $100 for the 8080.


For some reason people have mostly ignored the incredible technical achievements of the early Microsoft people. It was all sorts of unbelievable what e.g. Windows 95 was able to do on contemporary hardware


I always felt people thought windows 95 was amazing but it had significant support from the processor.

The earlier versions that ran on things back to the 8086 were more impressive, to me.


If you look at the 1974 8080 Assembly Programming Manual, there is not much to do. "Appendix A Instruction Summary" describes each operation in handy pseudocode. All you need to do is to make an interpreter for these:

CALL ADDR: ((SP)-1) <-- (PCH), ((SP)-2) <-- (PCL), (SP) <-- (SP)+2, (PC) <-- ADDR


This is the most informative comment in the thread. Thanks!


> (SP) <-- (SP)+2

Typo I think, should be '-2', since that stack grows downward.


Yes.


> How is this feat of computer programming not a major legend in computing history?

While what he did was certainly impressive, I don't understand why it would qualify for legendary status. Doing things like this wasn't all that rare back in the day.


I've spent most of my career in embedded systems, occasionally coming up for air to write a webapp or desktop application or even a mobile app.

I find that the devs in those spaces tend to regard working directly with hardware as being akin to magic. It's not surprising: very few developers these days are working on bare metal, so the work they do seems weird and out there, even though for us it's just another day at the office.


That makes sense, yes.

As a graybeard, I forget that what I expect pretty much any competent dev to know is no longer the baseline expectation.


It's funny the comments here saying it's not hard or unusual.

Paul Allen did this in 1974 without the Internet or modern software tools.

I think it is absolutely extraordinary and incredibly impressive.


Assembler programming wasn't an unusually exotic skill in the early 70s, and the PDP-10 was an unusually friendly environment for it.

Compared to modern programming, assembler on a 16- or 36-bit machine is simple, logical, and not at all abstract. DEC made a point of offering high quality detailed docs to students, and there was a kind of assembler culture that produced operating systems like TOPS-10, compilers for various languages, and editing tools, often with access to the sources.

And as others have pointed out, the 8080 was not a complex processor. So mapping its instructions to macros wasn't hugely challenging.

I had a friend who wrote a Z80 emulator - a harder challenge - on a PDP-10 as a spare time hobby project. It took about a month of after-hours programming. Full-time, it would have taken much less.

More interesting is that it's possible Gates & Allen had access to the sources for the PDP-11 4K word Dartmouth BASIC.

I have no idea if the original 8-bit MS-BASIC was a clean room reimplementation. But it's at least possible it wasn't.


> Assembler programming wasn't an unusually exotic skill in the early 70s

^^^ This.

Back in the 80s I wrote a 8051 assembler running on a Z80 system. This involves a parser, and also a bunch of tables with opcodes, operand formats & so on.

Took a number of weeks parttime (not sure if I ever completed it, but the bulk of the functionality was there iirc). This was using just text editor, Z80 assembler, maybe a debugger, and 8051 family datasheet(s).

Apart from emulating I/O (as simple or complex as that in emulated machine), difficulty-wise this should be similar to writing an emulator.

8051 and 8080 are not very different in complexity.


did this in 1974 without the Internet or modern software tools

Anyone doing anything with computers in 1974 did it without the internet or modern software tools. It seems to me it was an era where you were either a 'computer whizz' or else you didn't really get involved with computers.

Not saying its not impressive though, I think any programmers from that period who are still remembered now would be rated as 'very very good' by modern standards.


When it comes to implementing low level code using instructions and registers, nothing beats the data sheet. You don't need any opinions or tutorials, just a knowledge of how the chip works (it's in the data sheet), and the instruction set (also in the data sheet).

I'd highly encourage anyone to read a data sheet for something like an ESP32.


As long as you can get the errata sheets too. Nothing like spending a week banging your head against something that should work according to the datasheet, only to find in the errata "That things we said you could do? It doesn't work.".


It's even more fun when you find the bug before the manufacturer has written an errata (erratum?) for it :-(


Emulating some simple instructions really isn't that hard, we did it in first year CS. He would have had the documentation available, you don't need the internet for that.


It's certainly impressive, but not extraordinary by the standard of the day for a good programmer.

I once stuffed a software UART, simple command interpreter and a temperature control algorithm into a microcontroller that had a single accumulator and a grand total of 504 bytes of OTP Flash (a donut to anyone who can guess what it was from that odd memory size :-) and didn't give it a second thought until years later someone pointed out that it was unusual.


> I think it is absolutely extraordinary and incredibly impressive.

It's literally not extraordinary because it wasn't that rare of a thing to do. I'd expect most expert engineers of the day would be able to accomplish the same.

The internet and modern tools are merely conveniences that increase productivity. Devs have been working without them for longer than they've been working with them.


my 8080 emulator was written on the same DEC hardware as Allen's in Fortran77 in the early 1980s. no internet or "modern software tools", just the 8080 spec sheet. took me about two weeks or so, on and off. so it is not extraordinary or incredibly impressive - i'm certainly no genius SE.


it's not so very impressive. the 8080 is quite an easy processor to emulate (but not at the transistor or i/o level) - you can do it with a switch - there are only 256 possible instructions (not all used). i wrote one on the Dec10 back in the early 1980s (with assembler, disassembler and debugger) in Fortran77 and ported it to VAX and IBM 4381. we used it to teach assembler programming at the polytechnic i worked for. you could easily (well, relatively easily) have written basic on my implementation.


Writing an emulator for a simple processor isn't particularly complicated. You only need a reference manual of the processor (which I assume he had). The emulator itself can be as simple as a while loop with a switch statement inside and some simple variable manipulation. Nowhere near "feat of computer programming" or "major legend". Source: I've written Z80 and x86 emulators for fun.


[flagged]


Don't know what you're referring to. "Hell" didn't appear in the title


It's been changed. It used to say "How the h** [sic] did Paul Allen ...."


[flagged]


We've banned this account for posting unsubstantive and flamebait comments, and ignoring our requests to stop.

https://news.ycombinator.com/item?id=33566110 (Nov 2022)

https://news.ycombinator.com/item?id=32359604 (Aug 2022)

If you don't want to be banned, you're welcome to email hn@ycombinator.com and give us reason to believe that you'll follow the rules in the future. They're here: https://news.ycombinator.com/newsguidelines.html


[flagged]


Why would DOS have been claimed property of the US taxpayers when you are arguing they used that PDP-10 to create basic, not DOS?

Also, why would Harvard do that anyway? They didn't murder someone, they formed one of the biggest companies in history with their computers.

Also did Gates not buy DOS off of Seattle Computer Products? How did he screw him over exactly? Wikipedia says that it ended up making SCP millions of dollars.

https://en.wikipedia.org/wiki/Seattle_Computer_Products


1 - Correction: writing late, typo - BASIC should have been property of the US tax payers.

2 - It was still pretty novel back then, but "borrowing" computer time w/o paying for it is (and was) theft of services. Like sneaking into a movie theater without paying. It wasn't their hardware to use, it was a critical part of a commercial endeavor. They didn't have permission in advance to use it. They didn't murder someone, but they were a couple of spoilt brats who figured they could get rich by ripping people off. They ripped off SCP (next point) and they screwed over IBM & Digital Equipment Corp. with the OS/2 gaslighting & NT intellectual property theft (case settled out of court).

3 - Gates wired up the deal with IBM then "bought" 86-DOS from Seattle Computer Products knowing very well it was going to be worth millions since people were waiting for IBM to release a PC at the time. SCP made less than a million dollars and had it drawn out in court (from that same article - "Microsoft paid SCP US$925,000 and reclaimed its license for DOS"). He saw an opportunity to play middle man and then shanked SCP.


3 - What is wrong with that exactly? You make it like he ran a scam.

Him playing the middle man happens all the time. Nothing illegal about that.


Here's 2min & 57 seconds that sums it up.

https://www.youtube.com/watch?v=9nfgRf2A0Tc

Bill & Balmer didn't even have an agreement with Seattle Computer Products when they pitched it to IBM. They waltzed in, lied & said they HAD IT and they could SELL IT knowing it could go into millions of computers. Then, they bought it for chump change from SCP. SCP was a tiny nothing of a company.

It's like finding a homeless guy with a stamp collection & buying his Inverted Jenny for $1,000 USD knowing damn well it's worth over $1.5M USD (https://en.wikipedia.org/wiki/Inverted_Jenny). Is it illegal? No. Is it greedy and cruel for no good reason? Absolutely. Did it help SCP? Sure. Just like it helps the homeless guy to have a thousand dollars while you keep $1.5M simply because you could take advantage of him and there was nothing he could do about it.

Again. Gates is a liar and a thief. It's probably damn lucky for him Epstein "hung himself" in that jail cell. Otherwise, we'd probably have proof a few more choice names to call him as well.


So they bought something for chump change, legally. So your complaint is that they promised it and then had to find a way to get it. Which they did. They didn't violate anything.

So you admit Gates did nothing legally wrong, it just offends you that SCP didn't make as much as you personally feel is valid.

You seem to dislike Bill Gates to an extreme degree to where you find the fact that he did something that is completely legal, and happens in nearly every business, to be abhorent.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: