More on my 8080 emulator…

I spent some more time hacking on my emulator today. The key to getting an emulator to work is to have good, clear references on how the system works, and some example code that torture tests your simulator. Except for the DAA instruction (more on that later), the documentation for the 8080 is pretty good, and reading about several of the VHDL and Verilog simulations of the 8080 turned me onto CPUDIAG.ASM, a program which was designed to exercise the 8080 (apparently early NEC clones of the 8080A had difficulties with the DAA instruction). As it turns out, this little chunk of code proved to be incredibly useful.

;***********************************************************************
; MICROCOSM ASSOCIATES  8080/8085 CPU DIAGNOSTIC VERSION 1.0  (C) 1980
;***********************************************************************
;
;DONATED TO THE "SIG/M" CP/M USER'S GROUP BY:
;KELLY SMITH, MICROCOSM ASSOCIATES
Click here for the complete source.

After a couple of hours more tinkering, my efforts were rewarded with:

::: brainwagon 8080 emulator version 0.0
::: 1453 bytes of code loaded.

 CPU IS OPERATIONAL

Huzzah! Okay, there are still a few things this thing doesn’t test, like interrupts and the like. And I couldn’t figure out how the DAA instruction is supposed to work. It’s not clear to me that SIMH implements this properly either, a quick peek at their code seems to show that none of the ADD instructions do anything to set the auxillary carry bit. For now, I just commented out the offending tests. I’ll put them back in when I have some confidence that I understand how they are supposed to work.

Now that the instructions basically work, it appears that the next thing to do would be to try to figure out how to boot CP/M on the virtual machine. Then… tidy it up to see if I can shrink the code (the code for my linux box is about 12K). Then… well, we’ll see.

On ARISSat-1 SSTV images…

I’ve been trying to get out and record more ARISSAT-1 passes, in the hopes of getting some nice SSTV images. If you follow @brainwagon on twitter, you are likely to see some of the more mundane images that I’ve been getting thusfar. I keep hoping to snag some truly great ones, but thus far, the earth seems to be really good at evading the lens of ARISSAT-1 while it’s above my radio horizon. For instance, today I got these two pictures:

Not exactly exciting. There is an 82 degree pass later today, maybe I’ll luck out.

One thing that might not be obvious is that ARISSat-1 has four cameras. You can tell which camera is in use by looking at the color of the RS01S logo in the upper left of the SSTV image.

  • Red indicates the camera pointing along the -Y axis.
  • Green indicates the +Z camera. You can sometimes see the 2m antenna in this view (as you can in the green logo image above, poking in from screen right).
  • Blue is -Z pointing view, out the “bottom” of the satellite.
  • Magenta is the +Y pointing camera.

When I look at the ARISSat-1 SSTV gallery hosted by AMSAT, I see that most of the “good” pictures come from the blue and magenta cameras, but it seems clear that the orientation of the satellite drifts a bit, and there is no guarantee. I’ll just keep plugging away until I get something better.

Yours Truly on the Zombie Tech podcast

One of the more gratifying benefits of blogging is that it provides an opportunity to meet people who share your interests and enthusiasms. A few months ago, I became aware of the crew on the #savagecircuits IRC channel on AfterNET and started hanging out there. Various group members like Atdiy, whisker, JohnS_AZ, MakerDino, and Roy_Eltham (and others) all have participated in Ustream sessions, group Skype calls, and even played some Minecraft together. It’s a fun group.

Atdiy and whisker have started a new podcast called “Zombie Tech” which is basically just an extension of these online sessions. Nominally, the purpose is to pool our geek talents to figure out how we might survive the inevitable Zombie Apocalypse™, but as serious as that is, we seem to spend most of our time talking about some of the geeky projects we are engaged in, trying to teach each other and learn more about electronics, microcontrollers, programming, and using the Internet to spread more enthusiasm for more of the same.

They asked me to be on this week, and we talked for an hour. I’d be interested in hearing any feedback (hopefully positive and constructive, but any is welcome). And thanks to Atdiy and whisker for inviting me on.

ZombieTech – Zombie Tech 004.

An 8080 emulator…

A couple of days ago I got intrigued by this cool project which ran CP/M on an AVR. The basic idea was to equip an AVR with an external RAM, and then write a compact 8080 emulator to run on the AVR. Instead of floppy drives, the AVR accesses data stored on a small SD card. I thought it was really cool.

So I decided to see how far I could get.

A couple of hours work spent watching TV had the basic framework in place, and it’s beginning to execute code. For instance, here is the simple “Hello World” program, written in 8080 assembler (it presumes that you are running on a CP/M system to supply a printing system call):

bdos    equ     0005H
        org 0x100
start:  mvi c,9
        lxi d,msg
        call bdos
        hlt
msg:    db 'Hello World!', 0xA, '$'
end     start

Unless you like assembling code by hand, you need an assembler. I thought about using a simulated CP/M system running on simh, but that quickly got annoying, so instead I searched around and ultimately stumbled on asmx, a multi-CPU assembler which seemed to work just fine. It produced a nice little Intel hex format file, which my emulator can then load. I trap calls to the BDOS entry vector, and implement them with standard C calls (at the moment), and the net result is the rather unimpressive:

::: brainwagon 8080 emulator version 0.0
::: 23 bytes of code loaded.
Hello World!

Most of the control functions work, I need to get the conditional returns to work properly. I don’t have interrupt support yet, nor does it compute cycle counts, but the overall framework is quite good. I suspect that another couple of hours of work will get 95% of the instructions working, and then I could consider doing something like implementing Space Invaders. Ultimately, I kind of want to run a simple simulated CP/M system. We’ll see how it goes: stay tuned.

RIP: Michael S. Hart, founder of Project Gutenberg

Dan alerted me to the fact that Project Gutenberg founder Michael Hart passed away. On the Project Gutenberg site, Dr. Gregory Newby wrote a very nice obituary:

Michael S. Hart – Gutenberg.

I also liked this quote from Hart:

“One thing about eBooks that most people haven’t thought much is that eBooks are the very first thing that we’re all able to have as much as we want other than air. Think about that for a moment and you realize we are in the right job.”

I’m a huge fan of Project Gutenberg. I’ve enjoyed many classic books in their collection, from the stories of Conan Doyle, to Robert Louis Stevenson, to Lewis Carroll, Bram Stoker, Mark Twain, Charles Dickens… And on and on, as far as the public domain can take me. It’s hard to overestimate the value to public literacy that Project Gutenberg provides, and it could provide much more as a resource if people used it more. Thanks to Michael Hart, what a great contribution to humanity, and what a great legacy.