Saturday, April 27, 2024

Virtualizing the 6502 with 6o6 (and The Incredible KIMplement goes 1.0)

Okay, promises, promises. Here's the first of my bucket list projects I'm completing which I've intermittently worked on for literally two decades. Now that I've finally shaken out more bugs, tuned it up and cleaned it off, it's time to let people play with the source code.
This is the official 1.0 release of the Incredible KIMplement, an emulator of the one kilobyte, 1MHz MOS/Commodore KIM-1 6502-based single board computer. It provides access to the KIM's built-in TTY support (even through your computer's real serial port) and has expanded RAM with 16K of addressing space, all on an unexpanded stock Commodore 64.

It's almost burying the lede to announce that, though, because the real meat in this entry is how the Commodore 64 manages to emulate a very different 6502-based system. That piece is "6o6," for "6502-on-6502," and is a full virtualized software NMOS 6502 CPU that runs on a 6502 CPU — which I've open-sourced too. It has full control of guest code execution, including trapping undocumented and jam opcodes, and completely abstracts all memory access, making it possible to remap addresses, intercept illegal reads or writes, or even run entirely from virtual memory. On top of that, it's complete enough to not only pass a full functional test but also virtualize itself virtualizing itself:

These GIF screencasts are real-time with no tricks. Here a Commodore 64 and Apple IIe are both running a guest "hello world" payload within 6o6 (stage 1), which is nearly instantaneous, then 6o6 running the payload as a payload within another instance of 6o6 (stage 2), which is a little slower, then 6o6 running 6o6 running 6o6 running the payload (stage 3), which is glacial. But all of it works!

Friday, April 19, 2024

So long, Z80

You can still buy 6502s from Western Design Center and others, but Zilog's getting out of Z80s (PDF), announcing earlier this week that after June 14th you won't be able to buy them anymore (specifically the last-part-standing Z84C00 which comes in various speeds from 6-20 MHz) and what you buy you can't return. This covers the Z84C0006VEG, Z84C0006PEG, Z84C0010PEG, Z84C0008AEG, Z84C0020VEG, Z84C0008PEG, Z84C0010AEG, Z84C0008VEG, Z84C0010VEG, Z84C0010VEG00TR (!), Z84C0020AEG, Z84C0020PEG, and Z84C0006AEG. Get 'em while they're hot. The Z180 and eZ80 are not affected by this announcement.

Saturday, March 30, 2024

Refurb weekend: Data General/One (and the worst LCD in the world)

I mentioned earlier that while I prefer specializing in non-x86 laptops, that doesn't mean I don't collect interesting or unusual x86 laptops, like the Brother GeoBook NB-60 (I finally tracked down a mostly working NB-80C, the top of the line model, which will be the subject of a future restoration). However, this one is a unit I've had since about 1998 when they were getting rid of it at the University I worked for, and in many ways a landmark PC laptop since it was the first battery-capable system with a full 80x25 or CGA 640x200 LCD — though with a notorious deficiency: more on that shortly — and also came with a terminal and text editor in ROM. This is the 1984 Data General/One.
I suspect it was primarily used to dial into the campus network using the built-in modem and ROM terminal emulator, at least until better alternatives became available, and then ended up forgotten somewhere until they were cleaning things out and asked me if I wanted it. (Yes, I was retro even before retro.) It came with its bag, power supply and modem cable, and of course I said yes. It wasn't pristine, though: the floppy disk eject buttons wouldn't stay on anymore, it couldn't remember its hardware configuration, and the main drive had issues with nearly full disks. And then there was that infamous LCD.

Ah, what the heck. I finally got a round tuit. That makes it time for ... another Refurb Weekend.

Monday, March 18, 2024

After 41 years, my first assembly program on my first computer, the Tomy Tutor

We got it in 1983, I think, so it only took me about 41 years to get around to it. This Tomy Tutor isn't a replacement system I secondarily acquired, nor is it a Ship of Theseus Frankenstein rebuild. This is my actual first computer, in its original case, on its original components, with the Federated Group sticker still on the original box. And it still works.
Now, why so long? Well, for one thing, it was only supposed to be a training wheels computer because a full Commodore 64 system would have cost too much, but my folks wanted to see whether we'd take to a home computer and His High Holy Munificence Fred R. Rated was blowing these babies out for a song by then. The receipt has long since disappeared, though $99 sounds about right plus maybe around $40 or so for a joystick, cassette deck and some cartridges, compared to somewhere between $200 and $300 for the recently discounted 64 — which didn't include anything else. (It tells you something about our family finances at the time when a C64 was too expensive.) I immediately started writing my own BASIC programs on it in its perverse little BASIC dialect and when my folks indeed saved up and bought us a C64 system the next year (complete with 1702 monitor and 1541 disk drive), I refused to use it. In retaliation my best interests, my parents forcibly relocated the Tomy to storage and I went on to do even bigger things on the Commodore, making it, not the Tutor, the defining computer of my childhood. That's why there's still a Commodore 128DCR on my desk.

The other reason is that there was never really a simple way to do it. Even when I found out what CPU was actually inside (incredibly a 16-bit TMS 9995, an evolved version of the TMS 9900 in the Texas Instruments 99/4 and 99/4A), there was never a Tomy assembler, and other than its small amount of scratchpad RAM (256 bytes) the entirety of the Tutor's 16K of memory is tied up in the 9918ANL VDP video chip. That sort of architecture was typical for the family, but that also means that almost everything is stored in non-executable VDP RAM, so short of burning your own cartridge EPROMs there's no way to actually create and run a machine language program on the Tutor. The first flashcart for the Tutor didn't exist until around 2016 and it was still all ROM; furthermore, while the 99/4A could have its CPU-addressable RAM expanded (as well as the 99/8, its unreleased successor to which the Tomy Tutor is closely related), there wasn't ever a Tutor RAM expansion cartridge either until very recently. But now there are multiple homebrew options even for obscure home computers like this one, and at last I've got my own assembly language program finally running on it.

And it's all done with its own, better I/O routines (if I do say my own better self) as a basis for bigger projects. But first, a little tour of the Tutor itself, and then we'll dig in.

Tuesday, March 5, 2024

xa (xa65) 2.4.1

A quick one: xa (xa65), André Fachat's compatible fast two-pass cross-assembler for 6502, 65C02, R65C02 and 65816 processors that André and I maintain is now at version 2.4.1. This optionally expands the syntax from 2.4.0 and fixes some bugs primarily with relocatable .o65 objects. As usual, there are even more tests in its extensive conformance test-suite, and it is tested on Linux/ppc64le, Mac OS X (PowerPC, Intel and Apple silicon), AIX (its primary development platform, just to be difficult), and NetBSD/macppc and NetBSD/mac68k. You can download it and read documentation in man(1) format (converted to HTML) from the main xa65 home page. xa is free and open-source under the GNU Public License v2.

Saturday, March 2, 2024

An Apple district manager's Macintosh Portable in 1989-91 (featuring GEIS AppleLink and a look at System 7.0 alpha)

A few months ago I introduced you to one of the more notable Apple pre-production units in my collection, a late prototype Macintosh Portable. But it turns out it's not merely notable for what it is than what it has on it: a beta version of System 6.0.6 (the doomed release that Apple pulled due to bugs), Apple sales databases, two online services — the maligned Mac Prodigy client, along with classic AppleLink as used by Apple staff — and two presentations, one on Apple's current Macintosh line and one on the upcoming System 7. Now that I've got the infamous Conner hard drive it came with safely copied over, it's time to explore its contents some more.
We'll start with this Macintosh Portable itself and Apple's sales channel applications, moving from there to a brief presentation of Apple's Macintosh product line as Apple's own marketing staff would have presented it, at a distinct point in the company's history.
After that, we'll also look at the upcoming System 7.0 circa 1989-90 and a couple very different views of the operating system during its alpha phase.
Finally, after a brief glance at Mac Prodigy, we'll explore a little taste of AppleLink in its classic incarnation on General Electric's Mark III network — and spoof it enough to actually get it to log in.

Saturday, February 10, 2024

CAP-X and COMP-X: how the Tandy Pocket Computers got a sucky Japanese assembler

I grew up primarily with the Commodore 64, where if you wanted to do anything really cool and useful, you had to do it in 6502 assembly language. Today I still write 6502 assembly, plus some Power ISA and even a little TMS9900. I like assembly languages and how in control of the CPU you feel writing in one. But you know what would make me not like an assembly language? One that was contrived and not actually the CPU it was running on. And you know what would make me like it even less? If it were kneecapped, convoluted and limited without even proper I/O facilities.

But this particular odd little assembler dialect had the bureaucratic weight of the Japanese government behind it, because in 1969 what was then the Ministry of International Trade and Industry (MITI, 通商産業省) developed a completely artificial processor architecture to help ensure everyone taking the Information Technology Engineer Examination (情報処理技術者試験) would do so on an even keel. No one would have been an expert in this architecture or how to program it because we just made it up, reasoned the Ministry, so therefore no one will have an unfair advantage on the test.

Of course, that lasted only a few years before the specifications got out, and soon afterwards a handful of Japanese manufacturers had added it to their computers as a feature — including their pocket computer line. Through the magic of Tandy badge engineering, two of them made it to Radio Shack stores in the United States in the mid-1980s, perplexing a generation of larval nerds like me who couldn't understand what the heck it was doing there. While it was no secret the Tandy PC-5 and Tandy PC-6 Assembler feature was a fake, few people knew its history or ever did a detailed exploration. Let's dig into the dark and gloomy corners of this utterly bogus virtual CPU that a few real computers ran — sort of — and write our own cross-assembler and virtual machine so that future geeks can be just as befuddled.