Intel 8080 CPU Emulator (in Javascript, no less)

After getting a version of Tiny BASIC running on my emulator, I was scanning around to try to find something else to run. And, of course, when you look, you find all sorts of cool stuff. I happened across this cool page which is an 8080 emulator which is written in Javascript, and runs entirely in the browser. Very neat.

Intel 8080 CPU Emulator.

Emulator progress, and envy…

I’ve made a tiny bit of headway, but also encountered a link which makes me envious of much greater hacking skill. Óscar Toledo did an 8080 emulator that can boot CP/M as part of the 19th International Obfuscated C Code Contest, winning Best of Show. Its brevity is the “soul of wit”. Check it out.

Toledo 8080 emulator

Óscar also has written several tiny chess programs, and a Javascript chess program. Awesome.

While I didn’t find his code to be all that helpful (it’s, well, dense to say the least), I did find his approach to be helpful. A few additional minutes of hacking, and I managed to get the Tiny BASIC that he runs on his simulator to work on my own. Witness the following BASIC program:

>LIST
  10 PRINT "A PROGRAM TO EXPLORE THE 3 * X + 1 PROBLEM"
  20 FOR I = 1 TO 10
  25 T = I 
  30 GOSUB 100
  35 PRINT
  40 NEXT I
  50 STOP
 100 PRINT T,
 110 IF T = 1 GOTO 1000
 120 LET J = T / 2 
 130 IF 2 * J # T GOTO 140
 135 LET T = J
 136 GOTO 100
 140 T = 3 * T + 1 
 150 GOTO 100
1000 PRINT
1010 RETURN

OK
>RUN
A PROGRAM TO EXPLORE THE 3 * X + 1 PROBLEM
     1

     2     1

     3    10     5    16     8     4     2     1

     4     2     1

     5    16     8     4     2     1

     6     3    10     5    16     8     4     2     1

     7    22    11    34    17    52    26    13    40    20    10     5    16     8     4     2     1

     8     4     2     1

     9    28    14     7    22    11    34    17    52    26    13    40    20    10     5    16     8     4     2     1

    10     5    16     8     4     2     1


OK
>

Not bad! I suspect that even though my 8080 simulator is still pretty rough, I could get CP/M booted on it in much the same way that he did. More later.