The recent passing of Ward Christensen, creator of the BBS and author of XMODEM, presents as good a time as any to put into words the tale of the one time I used XMODEM in anger...
Flashback to 2006: NASA launch a probe that would eventually take photos of Pluto (which was still a planet at the time); Shakira's hips had recently passed a lie-detector test; and my brother was still selling refurbished laptops. A cousin of ours Back East in Pakistan was looking for a machine for homework n' such, so we put together a Windows 98 box with terrible specifications (if memory serves, some form of low-end Pentium with a DSTN screen) and wished it the best as it shipped off.
Trouble arrives
Come the summer of '08, our cousin checks back in: Windows had done the inevitable and corrupted its registry. The laptop would boot into DOS mode, but the graphical interface would bring up an error and demand to be reinstalled. Which isn't ideal, but you can always throw in an Entirely Official copy of Windows on CD and proceed from there.
Of course, it fell to us as both Family and the original purveyors of the hardware to fix it up, so I resolved to do that next time I was out there, which was slated for the autumn of that year.
My famous memory being as it is, I didn't take that CD. Not that it would've helped: as it turns out, the machine we shipped had no external drives. No CD, no internal Zip drive, not even a 3.5"; the laptop was bereft of ways to get new data onto it.
Evidently we'd originally installed Windows by putting the hard disk into a desktop machine using one of those 44-to-40-pin IDE adapters, and then moved the hard disk over hoping and praying it'd pick up all the hardware in the laptop. It looks like that worked (for two years even), so it should work again, and there was a desktop machine in the house where I was. All that was needed was one of those adapters, so a plan started to come together...
- Procure an IDE adapter;
- Download a Fully Legitimate copy of Windows 98 to the desktop, tying up the dialup Internet (this is rural Pakistan in the aughts, after all) for three days;
- Move the hard disk to the laptop;
- Run the installer from DOS mode, overwriting the existing Windows.
The plan collides with reality
Off we head to the bazaar in town (a good few miles away) to see what we can find. It turns out there is a dearth of tech shops, and the closest we get to an IDE adapter is a place that sells desktop-sized HDDs. They're IDE, certainly, but the wrong number of pins and the wrong physical size.
Scrap that idea, then. I went back to the laptop looking for inspiration, and I found it in the form of a serial port on the back: this machine wasn't utterly bereft of ways to get data into it, after all.
I'd heard of XMODEM as a method of serial-port transfer, and I'd also come across the concept of null modem cables which connect the Receive end of one machine to the Transmit end of the other without needing a modem in the middle (thus null modem). So the plan re-congealed as follows:
- Procure a null modem cable somehow;
- Download a Fully Legitimate copy of Windows 98 to the desktop machine;
- Start up an XMODEM client on both machines;
- Transfer the '98 install files to the laptop;
- Run the installer from DOS mode, overwriting the existing Windows.
First step, that cable. Back into town, we get significantly closer to what we need in those few tech shops: I end the day having scrounged up a straight-through serial cable, which is what you'd need if you did have a modem in the middle... There'd be a little rewiring involved. Fortunately this was the era of working search engines, and some quick work with a pinout diagram, a knife and some tape turned the cable into an (untested) janky mess that might suffice.
The second step wasn't so terrible either, it just took a while to download the twenty or so disk images that made up Windows 98 over dialup, after I asked my brother to temporarily Make Available a copy he had on hand. So we came to step three:
How do you transfer a file transfer client?
You'll recall that Windows itself wouldn't boot, so if Hyperterminal was even installed with '98 it wasn't available. The only way to get a program onto this machine in DOS mode was to resort to DEBUG.COM
's data entry mode, which works a little like this[A]Many thanks to The Starman's Realm for still having a DEBUG
tutorial available as a refresher.:
Enter hexadecimal data into memory, after the 256-byte Program Segment Prefix-e 100 SO ME DA TA IN HE XP AI RSOpen a new file and write the entered number of bytes to it-n OUTPUT.DAT -rcx CX0000 :0009 -w -q
DEBUG
offers a very terse entry mechanism, but its advantage is that it's built into DOS as the only way to get binary data into a file through the keyboard alone. So it became imperative to find a serial transfer client that's as small as possible, and some trawling through dump sites that were still available back in '08 turned up an XMODEM client that was (if memory serves) a single executable of 12kB.
I don't know about you, but the thought of reading over twelve thousand hex numbers off a screen and typing them into another screen made my eyes swim, and I was certain I'd make typos. Not just that, but (again, this being rural Pakistan) we only had power for half the day, so the screen I was reading hex numbers from would be prone to vanishing without warning. I needed three things to make life a little easier for this endurance event:
- A way to break the file up into chunks, which was relatively easy: stop typing after 256 bytes, and save the files as
XMODEM.001
,XMODEM.002
, etc; - A way to recombine the pieces on the laptop after I'd typed them in, which was also simple: the DOS
COPY
command supports multiple source files separated by +'s[B]With the caveat thatCOPY
will convert line endings unless you provide the/B
switch (for "binary copy").; - A way to checksum each chunk to be sure I'd typed it in properly, which wasn't a built-in.
And so to work
Our first dependency moves back a step, to a program that can perform checksums on a file. And this one I'd need to type in perfectly, because it was the one thing I couldn't double-check...
Having discounted the complicated algorithms like the SHA's of the world, on account of their executable filesize, I eventually came across an implementation of CRC-32 that squeezed itself into perhaps 700 bytes of DOS code. That was manageable (though I had a sneaking suspicion that it could be smaller, and that eventually yielded a post on this very blog[1]"CRC32 Calculation in 256 Bytes", Imran Nazar, Feb 2009 when I got back after this whole adventure).
The next couple of days are a blur, but I do recall it took three attempts to get the CRC32 program typed in and working, which then made transferring the 50 or so pages of XMODEM client relatively painless, if a little RSI-inducing. At the end of it, I had a program I could start up at both ends of the null modem cable, to send over the disk images of Windows I'd downloaded nearly a week prior.
Astoundingly, the installation of Windows itself went fine: the installer was perfectly happy to run from hard disk, installing to the same hard disk, and I handed the fresh machine back over with a day to spare before flying back out from a vacation that turned into a rescue mission, and still the only time I've ever needed XMODEM in a pinch.
Epilogue
We heard back from my cousin a few months later: the new Windows installation had been running great, until the hard disk gave up the ghost. They were quite happy not to drag us back out to fix it again, instead resolving to pick up a machine that hadn't started its life as e-waste from a corporate refresh.
It is possible to commit no mistakes and still lose.
--Picard