I bought an XT

For a while now I've been wanting to write a cycle-exact emulator for the original IBM PC and XT machines that are the direct ancestors of the machine I'm writing this on (and, almost certainly, the machine you're reading this on). I've written an 8088 emulator with cycle timings that I think are plausible but I have no idea if they're correct or not. The exact details of the timings don't seem to be published anywhere (at least not on the internet) so the only way to determine if they are correct is to compare against real hardware.

So, when I saw a cheap XT for sale on eBay recently, I made a spur-of-the-moment bid, and won it. It is a bit beaten up - the case was bent in one place, the speaker cone was falling off and the end of one the ISA slots was broken off. All these problems were easy to fix with a hammer and a bit of superglue, though. It lacks keyboard and monitor, which makes it rather difficult to do anything useful with it, but it did come with all sort of weird and wonderful cards:

  • Hyundai E40080004 MDA card with 66Kb of RAM. It's all discrete logic apart from the CRTC, RAM and a ROM which I think is a character ROM rather than a BIOS ROM (though I could be wrong). The amount of memory makes me suspect it can do graphics, but I can't find any documentation - I'd probably have to reverse engineer a schematic to find out exactly what it's capable of.
  • Tecmar Captain 200044 card with 384Kb RAM (bringing total to 640Kb), serial port, connector for a parallel port and possibly an RTC (it has a CR2032 battery on it anyway).
  • AST 5251/11 - apparently this enables PCs to connect, via Twinax, to a 5251 terminal server. It has the largest DIP packaged IC I've ever seen - a Signetics N8X305N RISC Microprocessor running at 8MHz (16MHz crystal) with 6KB of ROM and 96Kb16KB of SRAM (12KB on a daughterboard) for its own purposes.
  • A generic serial+parallel card.
  • IBM floppy and MFM hard drive controller cards.
  • IBM serial card.
  • PGS scan doubler II. It seems to be pretty rare, there's only one mention of it on Google and I've never heard of such a device being used with PCs before (though I understand they were more popular in the Amiga-verse). It's only uses the power and clock lines from the ISA bus - it has two CGA-style ports on the back, one for input and one for output. You loop the CGA card's output back into one of the ports, and the other one outputs a signal with twice the line rate (it buffers each line in its internal 2Kb RAM and outputs each one twice, at double the pixel rate). I'm guessing the output had to be a monitor with a CGA input which could run at VGA frequencies, which can't have been all that common.

It also comes with a floppy drive and a hard drive which makes the most horrendous metal-on-metal grinding sounds when it spins up and down (so I'll be very surprised if it still works).

This machine has clearly been a real working PC for someone rather than a perfectly preserved museum piece - it tells stories. At some point the original MDA card failed and was replaced with a clone, the RAM was upgraded, it's been used as a terminal for a mainframe, and at some point the owner read about this device that improves your video output, bought one, found it didn't work with his MDA card but just left it in there.

Due to lack of keyboard and monitor (neither my TV nor my VGA monitor can sync to MDA frequencies) I haven't got it to boot yet. I tried to use the scan doubler with the MDA and my VGA monitor (connecting the mono video signal via the red channel of the doubler) and the monitor was able to sync but the output was garbage - I guess the doubler is either broken or only works with CGA frequencies. If it does work with CGA then it'll be useful for seeing the TTL CGA output (though I'll have to put something together to convert the RGBI digital signals to analogue RGB - with proper fix up for colour 6 of course).

I ordered a CGA card but decided to see if I could jerry-rig something up in the meantime. I programmed my Arduino to pretend to be an XT keyboard and also the "manufacturing test device" that IBM used in their factories to load code onto the machine during early stage POST (it works by returning 65H instead of AAH in response to a keyboard reset). I then used this to reprogram the CRTC of the MDA to CGA frequencies (113 characters of 9 pixels at 16MHz pixel clock for 18 rows (14 displayed) of 14-scanline characters plus an extra 10 scanlines for a total of 262 scanlines). The sources for this are on github.

Next, I connected the hsync, vsync, video and intensity lines to a composite output stage like the one in the CGA card (it's just a transistor and a few resistors) and put some junk in video memory. Amazingly, it works - there is a barely legible picture. Even more amazingly, it is in colour! On the same breadboard I was doing this on, I had a Colpitts oscillator driving a 3.5795MHz (NTSC colour burst frequency) crystal from an earlier experiment (before my XT arrived I was trying to get colour TV output from my Arduino). This oscillator wasn't connected to anything, but the very fact that that frequency was bouncing around nearby was enough to turn off the colour killer circuit in the TV and allow it to interpret certain horizontal pixel patterns as colours.

The colours themselves aren't actually related to the picture in any useful way - the hsync and crystal aren't in sync so the phase (and hence the hues) drift over time. In fact, by applying slight heat and/or pressure to the crystal with my fingers, I can change the frequency slightly and make the hue phase drift rate faster or slower with respect to the frame rate, and even stop it altogether (though it's still not a multiple of the line rate so the colours form diagonal patterns).

The sync isn't quite right - because the hsync and vsync signals are just added together the TV loses horizontal sync for 16 lines or so during vsync and then spends half the picture trying to recover. Unfortunately the CRTC in the MDA card has a vertical sync pulse height fixed at 16 lines but it needs to be closer to 3 for NTSC so I haven't been able to get a stable signal even by XORing the signals like the CGA does. The CGA uses a 74LS175 to get a 3-line sync signal, but I don't have one of these to hand.

Here's the schematic for the circuit as I would have made it if I had the parts:

Unfortunately I haven't been able to continue the BIOS POST sequence after running this code - I tried jumping back into the BIOS at a couple of places but it just froze. I'll have to tinker with it some more to see if I can get it to work and determine where the POST is failing next.

I've determined that it should be possible for the XT to send data back over the keyboard line (the clock line is controllable by software). So I'm planning to do bidirectional communication between the XT and a host PC entirely over the keyboard port! I'm writing a tiny little OS kernel that will download a program over the keyboard port, run it, send the results back and then wait for another one.

Unfortunately my plans have been derailed because the power supply unit has failed. I noticed that the PSU fan wasn't spinning - I think that has caused some parts in the PSU to overheat. One resistor in there looked very burnt and the resistors for discharging the high-voltage smoothing capacitors were completely open circuit. I replaced all these but it's still not working. I've ordered a cheap ATX power supply and will be transplanting the guts into the XT PSU's box so that I can keep the big red switch.

36 Responses to “I bought an XT”

  1. [...] don’t mess with Jenner.  You do read his blog, however. Share this:EmailPrintFacebookTwitterDiggRedditLike this:LikeBe the first to like this [...]

  2. As I recall, the horrendous grinding sound is normal. Unless it's super-extra horrendous. Normally, the sound can easily fill a room and be heard several rooms away, with the door open.

    Good luck!

    • Andrew says:

      Ah, thanks! The hard drive doesn't boot but doesn't give a 1701 error either, so may just be empty (or at least empty in the boot sector). I'll have to poke at it with the BIOS and see if there's anything on there.

  3. Torbjørn K says:

    This is a cool project. Hope you get your XT running properly! I am lucky in the sense that my XT has a working keyboard, monitor, floppy drive and harddrive after all these years.

  4. Tomer Gabel says:

    Holy crap, dude. Well done :-)

  5. _ck_ says:

    If you email me a prepaid usps priority-mail label I'll send you a ton of ancient PC cards and even some 386sx motherboards if I can find them. I have ISA vga cards somewhere too and old memory - you can have it all.

  6. Gost says:

    If you can boot msdos from a floppy use "ctty com1" command to transfer the control from monitor+keyboard to first serial port ;)

    You could do it in autoexec.bat after you set up the com port.

  7. If I were you I would look for another XT to work with.

    As for spare parts, are there electronics recycling depots in your corner of the World? You could scavenge parts from what the customers bring in.

    Schools sometimes have repositories of obsolete equipment that they might let you peruse.

    • Andrew says:

      Pierre, if I just bought another XT when I had a problem to overcome I'd have a house full of them - they're all old and have problems. Besides, then I wouldn't have had this fun. I did have a look for old PCs/XTs in the various electronic recycling depots around here but didn't see any - I suspect that when these older rarer computers come in they just get put on eBay right away where they can sometimes fetch fairly handsome prices. The other problem with looking for such old stuff that way is that you have to comb through a *lot* of more recent stuff (486s, Pentiums, Pentium IIs) to find any scraps of the really old stuff.

  8. Informatica says:

    This was a nostalgic reading!
    I could send you a keyboard that would work, but I am in Brazil.

  9. Tad says:

    1701 is looking like a controller/drive failure.. not OS

    1701 Fixed disk or adapter general error

  10. [...] find a 30-year-old computer monitor. [Andrew] picked up an old IBM XT on eBay recently and tried to get the video working. He hasn’t seen any success yet, but the way he goes about solving this problem is very [...]

  11. [...] find a 30-year-old computer monitor. [Andrew] picked up an old IBM XT on eBay recently and tried to get the video working. He hasn’t seen any success yet, but the way he goes about solving this problem is very [...]

  12. Johannes says:

    Very interesting read, keep us updated! :)

  13. Oumpah-oumpah says:

    * You might want to check if the new power supply really provides -5V and -12V, I'm not sure that all ATX supplies do that and I seem to remember that some really old DRAMs needed a negative power rail as well as the 5VDC one. (You could try to Google the DRAM chips and see what they require.)

    * Is that graphics card really a MDA card? With that amount of memory (~64kbytes) it might be a "Hercules Graphics Card" or a clone (if it really is a monochrome card) or something else, perhaps EGA. The CGA adapter should as I remember it only have 16kbytes of RAM and it was good enough for 320x200x4 or 640x200x2.

    * There should also be one or two DIP-switches on the mainboard that tells how much memory that is installed, how many floppies that you have, if you have a math processor, etc. Try Google and see what you can find about them, just to see if they are correctly set given how you have set the machine up.

    * It might be possible to use another Arduino as some kind of bridge between the XTs keyboard connector and a modern PS/2 keyboard. Both of them should as I remember it use 5V TTL levels so if you are lucky you might get away with just some software. (If you can't find an XT keyboard.)

    • Andrew says:

      Oumpah, the new PSU provides -12V (I checked with a multimeter) which is used for RS232 ports mainly I think. It doesn't provide -5V, but that's only used for very old 16Kbit memory chips - the 64Kbit ones in this machine don't need it. If at some point I add an expansion card which does, I'll just use a linear regulator on the -12V line to get a -5V line.

      The graphics card isn't an IBM MDA card - it says "Mono Graphics" on it, is made by Hyundai and also says "ASS'Y NO. E40080004 REV. B". I haven't been able to find any information about it online but given that it uses the 0x3bX ports, 0xb000 memory addresses and generates an MDA-compatible signal by default, it's likely some kind of Hercules clone. It's all discrete logic, so definitely not an EGA.

      The DIP switches are set correctly - I have a soft copy of the technical reference manual which shows all the switch positions, and have been tinkering with them.

      Using a microcontroller to interface between XT and AT/PS2 keyboard standards has been done before.

  14. musters says:

    I need to look for it, but I have the same box (or a similar variant) sitting in my basement. I also think I have the original manual which contains schematics. What's the best way to get a hold of you?

    btw, I'm also interested in this because my video also stopped working too. I can hear full post occur (I remember the beeps, and can hear the HDD finish).

    • Andrew says:

      Musters, you can email me at andrew@reenigne.org . I have a soft copy of the original manuals with all the listings and schematics (which have been essential in being able to understand all this stuff).

      What is the video card that failed in your XT? MDA and CGA cards are both fairly easy to find on eBay, though you may want to check that it's the video card that has failed and not the monitor - given that it passes POST, the monitor is the more likely culprit.

  15. Perry says:

    You mention AMiga, if you have a 1084S monitor floating around, you can use this with an MDA card. You just use RGB mode and feed the input on green, or all three to get white text.

    66Kb (Probably 2k for text or maybe in ram character rom) is right for Hercules mode. This is 720x348 and uses a standard 15.375Khz monochrome monitor. Mono was 9x14 characters IIRC. Hercules was the bomb even after CGA came out, so many people actually ran both for a long time. You would use Hercules for text and CGA for color. 720x348 was very legible and useful for things like GEM back in the day.

    I find it incredibly ironic that the add-in card is far more powerful than the XT it was playing host to.

    • Andrew says:

      Unfortunately I don't have a 1084S monitor floating around...

      I'm guessing the 2Kb was for the font as well. Standard MDA horizontal frequency is 18.432KHz I think, not 15.375KHz.

      Which add-in card is more powerful than the XT? In what sense?

  16. Jac Goudsmit says:

    Congrats on your XT! I saw the article on Hackaday so I thought I'd stop by and post a couple of tips.

    You can probably find most (if not all) the information you're looking for in the IBM PC/XT Technical Reference Manual. This has a lot of technical information about the XT and a number of other IBM ISA cards that were used at the time, plus a complete BIOS assembly listing! I no longer own a copy of this but Google is your friend: I found three PDF files of it via Google easily.

    I don't know anything about the scan doubler either but I do know that it doesn't make much sense to have one if you're using a monochrome display adapter. HOWEVER: it might indicate that the system may have had a different video card before, and you may need to check the DIP switches on the motherboard to Monochrome mode to make it go through POST correctly.

    A loud hard disk is not unusual as someone already mentioned: the BASF hard disk in my XT was easily louder than the system fan. On most hard disks of that time, the light would come on as soon as you power it up, and it would go off when the drive was ready. If the drive is really trashed, the light will probably not go off. By the way, because those early drives didn't have autopark, it's not impossible that the drive worked before the XT shipped, and broke during transportation because the heads weren't parked...


    • Andrew says:

      Jac, thanks! I'm very familiar with the Technical Reference Manual - reading the BIOS source code in there is how I found out about the keyboard port manufacturing test protocol. It has schematics of the IBM cards but not third party cards.

      The motherboard switches were set for a monochrome card (as appropriate for the card it came with) but now that I have a CGA I've changed them so that it boots in color mode.

      Thanks for the tip about the drive light - I'll look into that.

  17. Agent24 says:

    Some of your errors might just be dirty contacts on the cards and cables etc. You should try cleaning the edge contacts if you haven't already.

    Also, this might be useful to you: http://www.retroarchive.org/dos/docs/ (contains hardware maintenance manual)

    Also this: ftp://ftp.oldskool.org/pub/misc/IBM5160TechRef.pdf (Contains schematics of the boards, and what looks like the BIOS source code)

    "I've ordered a cheap ATX power supply" - Don't get one too cheap, they often have uselessly bad quality capacitors in them, which wouldn't be suitable if you actually want to keep this machine running.

    Personally I think I'd try fixing up the original one. Hopefully you could find a schematic but it's probably not needed - should be a pretty simple design.
    some good information here: http://www.repairfaq.org/sam/smpsfaq.htm

    • Andrew says:

      Agent24, there doesn't seem to be anything wrong with any of the contacts. I tried reseating the faulty bank of RAM chips but it didn't make any difference. Thanks for the retroarchive link - there's a few things there I didn't already have.

      I think the capacitor plague died out sometime around 2007 didn't it? I haven't seen any issues with anything manufactured later than then. This is the PSU I'm using now and it seems pretty nice, but we'll see how long it lasts. I think the old one is beyond repair. At some point the fan failed and it looks like the board overheated - it's discoloured around the power transistors, one resistor was visibly burnt and some others were open-circuit. Probably all the resistors are in bad shape - it's quite amazing it worked at all. I couldn't find a schematic or repair guide for the original, but that generic one looks very useful for next time - thanks.

  18. Andrew Bowers says:

    I have a big box of old computer hardware, I think I even have some of the ancient 25MB Seagate hard drives, next time I'm down at my storage unit I'll see if I can find it, I'm pretty sure I have an 8-bit ISA video card I could send you... Sad thing is when I was in high school I had an XT that we used for doing motor control and other stuff in electronics class (This was in the late 90s when XTs were still plentiful, but cheap enough that you could fry stuff and not be out a bunch of money) but the "big" stuff like the monitors got recycled when I went off to college but I still have a big box of boards and stuff. (Might even have the computer somewhere but it's doubtful, my dad had this habit of just getting rid of stuff he thought was useless...) Email me and I'll let you know when I find it if I find anything useful :-)

  19. [...] was having a very frustrating problem trying to make my Arduino behave as the keyboard for my XT - one particular piece of code (a 1ms delay loop) seemed to be taking much longer to run on the [...]

  20. rj says:

    Once you decided to change the timing of the video mode the MDA used, why did you decide to use CGAtimings rather than e.g. VGA timings?

    • Andrew says:

      Truth be told, the main reason is that I never thought of it! CGA is closer to the MDA timings (in particular, the character clock is about the same) so I could still have an 80-column screen. My VGA monitor's minimum horizontal sync rate is ~30KHz which means that I could only have 40 columns or so. Also, it would have been less convenient to be able to use the VGA monitor at the same time as I was doing my experiments on the XT and the TV.

      However, now that you've made me think of it, I want to try setting up the CRTC registers for VGA timings on both CGA and MDA and see what they look like on the VGA monitor.

  21. [...] bought a CGA card for my XT, but it stopped working after a few weeks. These things are quite fixable - computers weren't made [...]

  22. [...] Looking at information about crystal oscillator circuits, a variable capacitor like that is usually included in order to fine-tune the frequency of the circuit. Quartz crystal frequency sources have a very small damping factor (high Q value) which means there's a very narrow range of frequencies in which they like to oscillate, but the external circuitry can influence the output frequency a little bit (as we've seen before). [...]

  23. Abel says:

    Hi Andrew! Long time ago (1992), here, in Brazil, I assembled my first PC (a XT, of course). It was a good and sound machine, with a NEC V20 processor...

    This month, I came across in the Internet with a PC Emulator ("PCE", of course) that you would find useful. The URL is http://www.hampa.ch/pce/. It was developed by a Swiss guy named Hampa (hampa@hampa.ch) and simulates a 5150 with two 16 MB HDs and two 360 KB floppy drives. To add or retrieve files to/from the emulator is made by a program like WinImage (but this is shareware) or, like I do, via DiskManager (used with MSX emulators): you must only change the extension "dsk" of the DiskManager image file to "img" (the WinImage and PCE standard) - or vice versa, to read the virtual floppies in the DiskManager.

  24. Yuhong Bao says:

    On the real-time clock on the card, looks like it uses the MM58167AN chip

  25. [...] My XT came with an unusual and interesting ISA card - a PGS scan doubler II. From the name, connections and the chips on it I determined that it was supposed to convert CGA RGBI TTL signals from 15.7KHz horizontal line rate to 31.4KHz, which would make it (timing wise) compatible with standard VGA monitors (it'd still need a DAC to convert from the TTL digital signals to RGB analogue ones). [...]

  26. [...] part of my project to emulate an IBM PC or XT with cycle accuracy, I also wanted to emulate the CGA card with cycle accuracy. That meant figuring [...]

  27. [...] part of my project to emulate an IBM PC or XT with cycle accuracy, I need to be able to get the machine into a completely known and consistent [...]

Leave a Reply