moria.de Michael's home page Computing CP/M 3 with real BIOS on YAZE

Using CP/M 3.0 on YAZE

Introduction

YAZE is an excellent Z80 simulator, written in ANSI C, that works on many architectures. It is fast, simulates undocumented opcodes and passes instruction regression tests against real Z80 hardware. This page explains how to set up CP/M 3.0 using YAZE.

Building yaze and cpmtools

Modify the yaze Makefile by removing -DBIOS from OPTIONS, add -DMEMSIZE=128 to OPTIONS, comment out the line with YAZE_OBJS for Link with CP/M BIOS support and uncomment the YAZE_OBJS for or link as a naked Z80. Compile yaze. That should be all that's needed.

Further get, compile and install cpmtools. You will need it to transfer files between UNIX and CP/M file systems and to generate your boot disk image.

Building a boot disk

If you want to boot from a (virtual) floppy, then you need a disk boot loader that resides in ROM. The Z80 starts execution at address 0x0000, so that's where the loader has to be. Real hardware often contains a ROM there, that is disabled after booting. I simply boot yaze with the boot loader being loaded at that address. The loader relocates itself to address 0x2000, then loads the first sector of the floppy to 0x0000. Finally it transfers control to the boot sector of the floppy it just loaded by jumping to address 0x0000. This disk boot loader is independent of the used operating system. The assembled version diskboot.rom is part of the CP/M 3.0 distribution for YAZE. Download the distribution and unpack it.

The boot sector is the first sector of the floppy. It will load CPMLDR from the system tracks to memory and start it. For that reason, it needs to know how long CPMLDR is, so it is OS specific. It further needs to know the floppy format. I use a 3740 format with 77 tracks, 26 sectors a 128 byte and a skew factor of 6 for the virtual floppy drives A and B, like Udo Munk's z80pack, so I can use a modified version of his boot sector. bootload.com.

If you bring up CP/M 3.0 using CP/M 2.2 as development system, then CPMLDR.COM is used to boot CP/M 3.0 from CP/M 2.2. To make things easier, I modified the boot sector to load CPMLDR at address 0x100, like CCP would.

I started by using Udo Munk's BIOS from z80pack, but hacked it to use virtual 4MB HDs as drives C and D and make use of the virtual MMU to simulate bank switching of the first 15 4k pages.

If you were running CP/M 3.0, then you would have to modify COPYSYS to copy the boot sector and CPMLDR to the system tracks. You can also use mkfs.cpm to do so, after all your floppy is simulated by an image file of its contents:

mkfs.cpm -b bootload.com -b cpmldr.com cpm-3

Now you have a floppy image called cpm-3, that can be booted. But wait, first copy CCP to the floppy. Further, you need to be able to halt yaze somehow. The halt program does exactly that. Copy both files to your image:

cpmcp cpm-3 cpm3.sys ccp.com halt.com 0:

It may be a good idea to copy some CP/M 3.0 transient commands to the same disk, but that is not neccessary to check that all works. Now you are done.

Starting the system

You need to tell the I/O port simulation in yaze which files to use. I have a default configuration file in /usr/cpm/etc/cpm-3:

mount a cpm-3
mount b scratch
mount c hdc
mount d hdd
attach rdr /dev/null
attach lst lst
attach pun /dev/null
Adapt it for your system. Then generate blank disk images using mkfs.cpm. Use the flag -f 4mb-hd for drive C and D. That's it, you are ready to boot:

/usr/cpm/bin/yaze -l 0 -b diskboot.rom -s /usr/cpm/etc/cpm-3

CP/M V3.0 Loader
Copyright (C) 1998, Caldera Inc.    

 61K TPA
        

CP/M Version 3.0
BIOS Copyright (C) 1989 by Udo Munk

A>
If you are done, start the command halt and yaze will exit. To simplify live, I keep my disk images in $HOME/cpm and use the following shell script:
#!/bin/sh

if [ ! -d $HOME/cpm ]
then
  echo Creating $HOME/cpm ...
  mkdir $HOME/cpm
  cp /usr/cpm/disks/cpm-3 $HOME/cpm/cpm-3
  cp /usr/cpm/disks/scratch $HOME/cpm/scratch
  cp /usr/cpm/disks/hd $HOME/cpm/hd
fi

cd $HOME/cpm

if [ x$1 = x ]
then
  RC=/usr/cpm/etc/cpm-3
else
  RC=$HOME/cpm/$1
fi

exec /usr/cpm/bin/yaze -l 0 -b /usr/cpm/rom/diskboot.rom -s $RC
You will probably have to adapt it to your needs.