The oldest CP/M ‘simulator’ out there.

I was surprised to come across this little simulator simply called ‘com‘ tonight. This program started out as a 8080 instruction simulator for a mc68000 machine running CP/M, back in 1984, and was written by one Jim Cathey.

‘Com’ was then later written up, and published in Dr. Dobb’s Journal.

From there it’s evolved it’s assembly core to some other 68000 cpu families and platforms, then the MIPS and PowerPC. Then in 2006 the CPU core was re-written in C.

For a while it’s primary platform was a 68000 based Unix, and it still has a lot of unix’isims buried in the source. I’m sure it’d build in MinGW though.

But in the meantime I figured it was yet another reason to fire up the old gcc 1.37.1 for Xenix to give this thing a go.

The biggest, and dumbest thing I fought was without realizing there was both a ‘Makefile’, and a ‘makefile’, and gmake kept running the lowercase one, while I was editing the Makefile in vain… But with that out of the way, and a few includes to fix, it was VERY straight forward to build. Not to mention running Xenix on Virtual PC 2007 on my new intel core i7 cpu, it compiles the C version just about as quickly as I can hit the enter key.

Because it’s on Virtual PC the last few lines of the console are garbled.. Oh well, at least the floppy controller works (as long as you hard code /dev/fd0 to 2,60).

So, here is a picture:

Xenix 2.3.4 with ccom zork1

Xenix 2.3.4 with ccom zork1

And a disk image. All I’ve really done is tweaked a few things, and built this with gcc so it includes a binary for Xenix systems. Also the ‘com.tar.gz’ package did include quite a few sample programs… mandog.com is fun, along with zork 1,2 &3!

On a final note, I thought the Xenix thing was a good road to head down because in the 1990’s there was this BIG push for ibcs2 compatibility across all these Unix platforms on the i386 cpu. Well it’s been largely abandoned work, and the best I got was OpenBSD complaining that its always out of memory, and NetBSD kernel panics!.. Open Solaris has *NO* ibcs2 compatibility even left.

I suspect it doesn’t matter, esp now that you can run some real ibcs2 OS’s in a VM, who needs 3rd party emulation?

I guess I’m just too late to the party.

Frotz on Xenix

Well after having some fun with gcc, I wanted to try something a little more… “fun”. I’ve had good luck in the past with ‘dumb frotz‘ on the old BSD stuff (4.2/4.3 etc) but surprisingly I had no luck at all with gcc & xenix.

Well that was rather odd.

So in some crazed attempt I tried the regular version of Unix Frotz 2.32. Xenix was lacking the memmove procedure, but thanks to an old post here, I was able to get it running under Xenix.

Ok, fair warning it is SLOW. It’ runs the cpu into 1.0 levels… I don’t know why. My attempts at building gdb and using it from that old Soviet site hasn’t met with much luck.

Oh, and it was easier to massage some make files with gnumake.

But it does run!

If anyone want’s to give it a whirl it’s available here.

gzip for Xenix

sorry I didn’t realize that IIS was blocking the gzip download because of it haveing no extension…

I really need to redo that whole install.

Meanwhile you can download it here:

gzip-i386-xenix

Also I found on some old “Soviet Union” website (no really it’s a .su!) a binary version of GCC for Xenix… I’ll post more later as I get a chance to go through the thing….

For the adventurous it’s here:

ftp://ftp.kiae.su/pub/unix/os/xenix/gnu/  (now offline)

It’s kind of interesting to find such a thing, and if you see the dates, it’s from January 28th 1991… In the last days of the Soviet Union… Well lucky for us, someone in Russia is a packrat! I guess they were starting to switch out from homemade PDP-11’s into 386’s and they didn’t bother porting their ‘pirated’ versions of Unix v6…

Xenix, K&R and f2c…

Well a friend of mine let me have access to a Xenix 386 machine with a C compiler! Which was great, The first thing I built was gzip, as I couldn’t imagine a machine without it…

then I spent the better part of 3 hours ‘fixing’ f2c/libf2c for some Zork fun. Well let me say that while it was fun and all, the C environment from Xenix is…. old. No stdlib.h.. Among other things. Also gzip and f2c had issues where some programs would use ‘local’ copies of procedures… Naturally whatever compiler (MS?) my friend had wouldn’t have any of that!

Not to mention the other slight stumbling block, was that this was a K&R Compiler… Ouch.

However I was able to bash together a version of f2c that ran!

However it left me fixing the prototypes for the output… Because by default f2c outputs in ANSI.

It’s no biggie for ‘hello’ or even the textcnv program for Dungeon, but there was no way I was going to do this for the 100’s of procedures in Dungeon…

But the upshot is that the simple answer was a man page away…

Use the -K flag, instead of the -C flag, and all will be well.

I didn’t bother trying to clean up the gettim.C thing, maybe some other day, but I can’t promise much.

But in the meantime, here it is, for the 2 or 3 people with some kind of legacy Xenix thing out there..

 

Dungeon-2.5.6 for Xenix.

This is an 80386 exe, so you 80286 users would be out of luck… I don’t know if I even can make 80286 stuff.. I think the next thing I’ll have to see how hard it is to build is that ACK as it says it supports Xenix… And free compilers are always ‘good’ things.

Printing within Qemu

For a while I was unsure of the syntax of printing from within Qemu. I know for the Xenix crowd this is kind of ‘a big deal’. Along with more serial ports for consoles & stuff…

Anyways for the printer I found an example on line, and it’s quite easy:

qemu xenix_hard_disk.vhd -parallel file:lpt1: -M isapc -m 16 -k en-us

Now I’ve seen it actually spool stuff to the printer once the emulator is exited… I’m sure there is some way to kick these jobs better… I’ve also been trying to keep it as dumb as possible and there is a chance my HP printer /scanner thing doesn’t talk like a 1970’s style printer.. I’ll know more tomorrow..

But at the moment this should serve enough to get people started. Also you could redirect the parallel port out to a file, and then open that file in say word and print from there as well.
This is becoming a bigger deal now that future versions of Virtual PC no longer support things like parallel ports, floppy disks & sound blasters…. Qemu will be the only out for a few people.

back to fun with pread.c

Well I know this topic keeps comming up over & over that the pread.c that I had used to build my Xenix on Qemu is long lost.

Anyways someone else was asking me for it, and I stumbled accross this Microsoft Memo:

http://support.microsoft.com/kb/100027

which means the device name I was listing was wrong… I’m unsure if it means in 2003 it change from what it was since 1991….

Anyways here is my new ‘pread’.

#include <stdio.h>
#include <stdlib.h>

define BUFFSIZE 1024*1024
void main(void)
{
FILE *disk;
FILE *ofile;
int disknumber;
char fname[255];
char oname[255];
char *buffer;
int rc;
int pass;
buffer=(char)malloc(BUFFSIZE); if(buffer==(char)NULL)
{printf("\nError allocating buffer!!\n");return;}
printf("please tell me the disk NUMBER that you want to read\n");
printf("for \\.\PhysicalDrive1 just answer 1\n\n:");
memset(fname,0x0,sizeof(fname));
scanf("%d",&disknumber);
sprintf(fname,"\\.\PhysicalDrive%d",disknumber);
printf("reading the device %s\n",fname);
disk=fopen(fname,"rb");
memset(oname,0x0,sizeof(oname));
printf("\nWhat is the output file name?\n\n:");
scanf("%s",oname);
ofile=fopen(oname,"wb");
if(ofile==NULL){printf("\n\nERROR with %s\n",oname);return;}
if(disk==NULL){printf("\n\nERROR with disk %s\n",fname);return;}
rc=5;
pass = 0;
while(rc!=0)
{
memset(buffer,0x0,sizeof(buffer));
rc=fread(buffer,1,BUFFSIZE,disk);
printf("\r%d\t%d:Megabytes processed",rc,pass);
fwrite(buffer,1,rc,ofile);
pass++;
}
fclose(disk);
fclose(ofile);
printf("\n\n\nDone!%c",7);
}

Apple Lisa Xenix

Wow I’m surprised a few hours googleing about and I got it running….
I found this ‘idle’ emulator (“Incomplete Draft of a Lisa Emulator”
http://sourceforge.net/projects/idle-lisa-emu ), which can infact run Xenix! It also says it can run the uniplus SYSV (so says the readme)..

Searching around I found the following site:
http://unixsadm.blogspot.com/2007/12/xenix-blast-from-past-looking-back-at.html

Whas Xenix 3.0 disk images in the DART format… which as luck would have it idle cannot mount. However I found another lisa emulator, lisaem ( http://www.sunder.net/ ) which has a tool to convert the disks from DART to DC42 (disk copy 4.2). So it was a simple matter of converting the disks

lisafsh-tool.exe “Xenix OS Boot Floppy”
quit

… etc etc… ad nasium…

Then firing up idle, setting the CPU to max speed, and booting up whenver I was going to answer a question I toggled it back to 5Mhz.. otherwise it would take FOREVER to boot… lol like the ‘good old days’.

Once the boot floppy had formatted the 5mb hard disk image, and transfered on reboot I had to tell the bootloader to boot from the profile disk..

pf(0,0)xenix

And away it went. After installing the OS & the C compiler I’m left with 23 blocks free!.. which I guess for a 5mb disk, is pretty cool.. Anyways there are assorted Xenix PDF’s which can be found here:

http://www.tenox.tc/docs/

Namely these two for Apple Lisa Xenix..
http://www.tenox.tc/docs/apple_lisa_xenix_programmers_guide.pdf
http://www.tenox.tc/docs/apple_lisa_xenix_programmers_reference.pdf
It’s amazing that lisa emulators were sort of capable of running Lisa Office System, now they can run the old unix stuff… it’s still impressive.

Running Xenix on qemu

Neither Bochs nor Qemu can boot the Xenix floppy diskettes all the way. Virtual PC & VMWare seemed to have no luck when the kernel transitions to protected mode. While on the way to work I had an idea. What if you had an old hard disk and a machine capapble of installing? Simply imaging the hard disk may be enough, since after that point you don’t need any floppy disks!

So this is what I have to show for the work today:

Freaking awesome, if I do say so myself.

OK, now how to do it? First you need an existing system running Xenix. If you have any plans on migrating an existing installation take note! This will preserve your install, just don’t format! On the Xenix boot screen take note of the geometry of the disk. We will need the geometry for later. Although I did a test boot without it, its a good thing to preserve it.

For virgin users, you will need a small disk to install on. I had a 2.5 GB disk that was too big, and 132MB disk that worked fine. I used a dell pc with 2 ide controllers for this. The longest task honestly was installing Xenix. I think that ran about 20 minutes. Once I was done, shutdown xenix, and put the disk in a machine running Windows (Linux fans can put it in their box, and just dd the Xenix disk into an image). Us poor Windows users don’t have dd. Anyways take not of what disk # it is, as Windows of course will not assign it a drive letter since it does not understand Xenix’s filesystem.

As you can see it’s disk #2 in this computer. Ok now we need to read the disk and write it into a disk image. I couldn’t find a util offhand to do it, so I wrote one real quick. Here is the source code, you’ll need a C compiler on your PC to compile it. I guess I could ‘neaten it up’ some, but for now here you go:

Source code

Executable

Yes I know its horrible, and blogger does a wonderfull job of formatting my program. Anyways compile it & run it. Now you’ll have a disk image of your hard disk!

Now for the fun part, running Xenix! We simply specifiy the hard disk geometry that we got earlier, and pass it the disk image that we created! I’m using an Quantum Pro drive ELS with the following geometry:

919 Cylinders
16 heads
17 bytes/sector

That translates into the following command:

qemu -M isapc -m 16 -hda xenix386-2.3.4.disk -hdachs 919,16,17 -L .

 

Let the good times roll!

–Update from 2011!

It is *NOW* possible to install Xenix in Qemu 0.14.0. You can read more about it here.