Modula-2 and the PDP-11

When looking round a second-hand bookshop yesterday, I found this book on Modula-2:

front cover

I seemed to remember that there was some connection between the PDP-11 and the Modula-2 programming language, so I took a chance and bought the book for £1.  I spare no expense on my computer history collection :-) Anyway, now that I've had a chance to check, I found this "The first Modula-2 compiler was completed in 1979 and ran on the DEC PDP-11" (taken from here).  So it does seem like a worthwhile addition to my collection of PDP-11 related objects.  This pleases me.

...and for the sake of completeness, here is the back cover too (even showing the original price tag):

back cover

MicroPDP-11 installed inside the case

It was a rainy Sunday afternoon, so I decided to have a tidy up in my office/workshop/third bedroom. What actually happened was that I saw the grotty looking dusty case for my PDP-11 and decided to clean it (it was in pretty bad shape since I bought it). Having cleaned it I then decided to put the machine inside the actual case. So now the office looks just the same, except the PDP-11 looks much better. Some progress I suppose. Here are some photos of the end result:

In the case, image #1

In the case, image #2

Isn't she beautiful? During this process I have learned:

- the machine is much heavier than I remember
- I really need to find a front cover to finish it off
- the word "PDP-11" in english is apparently feminine

Now it's in one piece, I have even fired the machine up and can report that it still runs fine.  Phew!  I didn't break it.

Some maths functions for DECUS C

For some reason I decided to rewrite the "wave" program that I wrote in Basic-11, but using DECUS C.  I thought that it would be easy, but I didn't count on there not being a math.h.  This means that I had to work out how to calculate a sine and cosine for myself.  Well, actually I went off to google to see if somebody had already done the hard work for me.  Indeed they had, I found it here: www.bsdlover.cn/study/unixtree/V7/usr/src/libm/sin.c.html

That code was already in K&R syntax, but it used modf(), I think that I went off and found some source code for that somewhere else...  Anyway, when I had it working, I decided that I might want to use these bits of maths code somewhere else - so I extracted it out into my own library and made "maths.h".  So I can now use sin/cos wherever I want.

Anyway, since I went to all that trouble, I thought that I had better post the results.  You need to compile maths.c into maths.obj, like this:

.CC
CC> MATHS.C/A
RUN C:AS DK:MATHS.S/D

Then, you can #include "maths.h" and link to the maths.obj we created above, like this example:

LINK WAVE.OBJ,MATHS.OBJ,C:SUPORT.OBJ,C:CLIB.OBJ

I expect I'll add more to my maths library as I go, but this is a start.

Unix v1: taking IsoCobbler for a spin

After finding that Unix v1 was out there, and that it can run on the PDP-11, I thought that it was an ideal target for taking my IsoCobbler tool for a spin. So this is how I used IsoCobbler to make a bootable CD containing the first version of Unix, circa 1972:

1) Download a copy of SIMH 3.81 for DOS, from this location: http://sourceforge.net/projects/simh/files/simh%20binaries/3-8.1/
2) Inside the "simh-3.8-1_MS-DOSi386-exe.zip" file, find this path: simh/pdp11/unixv1. Extract the 6 files inside to a folder.
3) With the extracted files, rename unixv1.bat to start.bat. This will then be started automatically by the disk image.
4) Now add the files in the folder to a new zip file called content.zip. This zip file will be inflated automatically when your boot disk starts.
5) Get IsoCobbler and move your content.zip file into the same folder as the IsoCobbler binaries.
6) Run CobblerConsole (as an administrator), and enter these commands:
   INS content.zip
   SAVE unix1.iso
   EXIT
7) You should now see a file called UNIX1.ISO in the folder containing the IsoCobbler binaries.

That's it! You have made a bootable ISO containing First Edition Unix. When you boot from the ISO and you're prompted, login as root.  Oh, here's the one I created:

  IsoCobbler CD image with Unix v1
Download

PDP-11 Live CD running Zork

  Live CD image with Zork
Download


By popular demand, here is a PDP-11 Live CD that is configured to auto-run the 'Dungeon' game (aka Zork) in a PDP-11 emulator.  Well OK, when I say 'popular demand' I mean that a colleague of mine mentioned it in idle conversation...

I got the game files from here: http://www.dbit.com/pub/pdp11/rt11/games/

And if you don't know about the historic computer game of Zork, I suggest you have a read on wikipedia: http://en.wikipedia.org/wiki/Zork.

Improved PDP-11 Live CD

  Live CD image
Download


The previous PDP-11 Live CD that I made is great, but it only works with IDE CD-ROM drives, so you cannot use it if you have a SATA or USB CD-ROM.  Which is a shame.  So I wanted to make a version that doesn't rely on having CD-ROM drivers for DOS, since it's unlikely that I'd be able to support all of the different types of drive.  I have tried to get my external USB CD-ROM drive to work under DR-DOS and found that I couldn't make it go.

So, for a few days I have been struggling to create an "El Torito" hard disk image, so that I could make a CD bootable version of a hard disk.  I haven't gotten it to work yet.  I even tried this (twice actually) by taking the HxD hex editor to an ISO file.  I've given up for the time being, but I'll probably come back to it.

However, I can get floppy disk "El Torito" images to work perfectly, including the 2.88 Mb variety.  That's how I got the previous Live CD to start (but I was only using a 1.44 Mb image that time).  So with a bit of lateral thinking I realised that my PDP-11 disk compresses quite well.  So I went off an got an UNZIP program for DOS, from here ... or to be specific, I downloaded unz600x3.exe from: ftp://ftp.info-zip.org/pub/infozip/msdos/.

This means that I can fit DR-DOS into a 2.88 Mb floppy image along with a compressed copy of the PDP-11 emulator and disk.  Since everything is inside the 2.88 Mb image, we don't need to load CD-ROM drivers in DOS.  It means that this bootable ISO will work with SATA and USB CD-ROM drives, it doesn't need the drivers since it's all done by the BIOS and the magic of El Torito.  Cool.

PDP-11: RT-11 Live CD with Basic-11

  Live CD image
Download


[NOTE: I have since made a better version here.]

This ISO image of a bootable CD is the combination of two different threads I have been working on: how to make bootable CDs and how to set up RT-11 with Basic in SIMH, the PDP-11 emulator.  This CD only works if you have an IDE CD-DROM drive though.

So I took the bootable CD image that I had already made and added SIMH for MS-DOS.  Then I added my RT-11 / Basic-11 disk image.  I set SIMH to start up automatically from a 16Mb RAM disk.  It all seems to work. It is pretty fast in comparison to a real PDP-11!  Because it is running from a DOS RAM disk, you get read/write access under RT-11 (until you switch the power off).  But it does mean that you can't mess it up since you get a clean install each time you boot the CD. Oh, and if you're looking for a manual on Basic-11 I've posted some stuff here.

So... if you'd like to have a play with an ancient operating system, give it a try.  Burn the ISO to a CD or boot it directly in Virtual PC or VirtualBox.  I've tried it with as little as 32Mb RAM, and it works fine. When I get time, perhaps I'll do an ancient Unix Live CD as well.

Emulating from DR-DOS on a memory stick

I decided that it would be cool to have an emulated PDP that was bootable from a memory stick.  Then I could simply boot from a USB pen drive straight into a PDP-11.  To do this, I decided  to use a different emulator than SIMH - Ersatz-11.  It's free for hobbyist use.  Not only does Ersatz-11 have a good DOS based emulator (meaning that you don't have to boot into Windows first) but I believe that it will give access to the physical COM ports, althought I have not tried that feature yet.  I tried to get it to run under FreeDOS, but whilst Ersatz-11 would start; I could not get it to read any disk images.  So in the end I switched to DR-DOS, which was harder to install... but ran the emulator without any errors.

Here are some brief notes on how I got it working (from a Windows 7 machine):

- Make an empty FAT formatted USB pen drive bootable into FreeDOS with unetbootin
  Just select FreeDOS 1.0 under 'Distribution', and then select your pen drive at the bottom and click OK.
  This was the easiest way I found to make a DOS type boot disk, but we don't actually want FreeDOS.
- Now, make a DRDOS folder on your pen drive and save the DR-DOS binaries in there
  [I'm using version 7.01.06]
- Make a DRSYS folder on the pen drive and save the DR-DOS varant of FreeDOS SYS binaries in there
- Download and copy the Ersatz-11 DOS files onto an E11 folder on the pen drive
- Copy your own PDP-11 boot disk image to your pen drive

Now we can reboot and start FreeDOS from the pen drive.  When asked, boot into FreeDOS as a simple LiveCD, we don't need more than that.  It should boot to drive A: and your pen drive will appear as another drive (for me, it was drive C).  Now try the following (WARNING! this assumes your pen drive is now C, change the drive letter if your one is different, don't blame me if you mess up your hard disk):

 C:
 cd DRSYS
 sys C:\DRDOS C:\
 cd \

 copy C:\DRDOS\*.* C:\
 del C:\*.img
 del C:\ub*.*
 del C:\*.cfg
 del C:\*.c32

The pen drive should now be bootable in DR-DOS rather than FreeDOS, so reboot and start from the pen drive again.  [There will be a LDLINUX.SYS file left over from FreeDOS that we can't delete right now.  If you want to, come back and delete this file by plugging your pen drive into another machine with a better OS.]

You should now be able to start Ersatz-11, with something like this:

cd E11
E11
MOUNT DU0: C:\boot.dsk
BOOT DU0:

That's it!  You should be able to emulate a PDP-11 under DR-DOS.  In Ersatz-11, hit <SHIFT>+<ENTER> twice to stop emulating, then type 'exit' and press enter to quit to DOS.  If you put the 'mount' and 'boot' commands into a file called E11.ini inside the E11 folder and create an autoexec.bat file in the root of the pen drive to start the emulator, the pen drive should automatically boot into the emulation from now on.