Close

CP/M on Badge, Quick Guide

A project log for 2018 Hackaday Superconference Badge

Based on the Hackaday Conference in Belgrade, this badge will be a stand-alone, battery powered vintage computer packed with features

Mike SzczysMike Szczys 10/16/2018 at 16:2012 Comments

After you start Z80 emulator with CP/M, the machine boots up on A drive greeting you by prompt

A>

There is not much to do with this drive, as it is 22kB RAM disk. It is empty after boot, as you can try with command

dir

that prints what is in current directory. You can switch to disk B, where is more to be found

b:

and system will respond with

B>

meaning you are there. You can now list content of this directory again and discover a few executable (.COM) files, like XMDM, MBASIC or FORTH. You can play around with those; notice that some of them expect different line (CR) end than what badge uses (LF). You can do CR line end by hitting SHIFT+ENTER. Exit MBASIC by typing system<CR>.

On disk C you have some more goodies, namely famous ZORK game and SARGON chess game.

Disk D is empty, with 512kB of capacity. You can copy files to/from disks utilizing PIP program, with syntax of

pip d:=c:zork1.com

that will copy file zork1.com to drive d. Notice you should run this one from disk B, where pip resides, or explicitly set path to pip program.

If you want to erase the file, just type

era d:zork1.com

If you happen to need to list ASCII file, invoke command

type file.txt

or dump binary file in hexa form by running

dump file.bin

Stat command is used to display statistics of a file or drive; you can run

b:stat

to display info of drives or

b:stat *.*

to display information about all files on particular drive. Notice the wildcards - you can use it when copying or erasing the files too.

If you want to transfer files from computer (or perhaps another badge), you may use XMODEM program. Run

b:xmdm r d:filename

to start saving received file on D drive, and start XMODEM transfer on other side. The transfer speed is 19200 baud. You may try to archive files into ARC format and un-arc it on CP/M side with dedicated software, if you want to transfer more files. On linux, you may want to use sx to transfer files, or moserial or cutecom for GUI access, with windows, teraterm is good option.

You may want to try assembler toolchain consisting of ED editor, ASM assembler, LOAD program to convert hex to .COM file and DDT debugger. There is quite a lot of Z80 CP/M software on the interwebs, you may want to look for "walnut creek CP/M CD". Be prepared that a lot of CP/M software was designed for modified machines, sidetracking BIOS, so it may not run on this particular machine.

Notice badge has option to switch from local standard input/output (keyboard/display) to serial port (on pins C13 and C14 on expansion port, 3,3V levels, don't forget ground) by pressing LSHIFT+RSHIFT+BRK; with the same combination taking you back to local access. You may access the command line using terminal emulator on your PC, gaining somehow more comfortable access.

You can find more details about the CP/M commands and programs here and here.

Discussions

Mikael ☉. Bonnier wrote 11/09/2018 at 19:44 point

It seems to be possible to use serial communication using CP/M. It works from XModem. Does serial also work from FORTH and MBASIC? Is it possible to use GPIO to e.g. blink LEDs from FORTH and MBASIC under CP/M. E.g. the emulator could emulate a Z80 PIO on some IO ports.

  Are you sure? yes | no

James Newton wrote 11/10/2018 at 04:12 point

Serial works from FORTH, but I can't seem to switch from keyboard/LCD to serial on the fly. If I start from the menu, then use the serial comms to select 2, and "B:", "FORTH D:SCREENS.FRT", then I'm able to use the terminal program to enter FORTH code. 

I've put together some documentation here:
http://techref.massmind.org/techref/language/FORTH/z80fig-Forth1_1g.htm

I did find in the FORTH code, there is a place where it will use the IN and OUT Z80 instructions, but I don't know what the Z80 emulator does with that, e.g. what ports are mapped.


  Are you sure? yes | no

James Newton wrote 11/10/2018 at 04:26 point

It looks like the Z80 sim just calls this code, which implements a few virtual devices like the disk, and console. It would have to be expanded to support the other onboard hardware.

https://github.com/Hack-a-Day/2018-Supercon-Badge/blob/fd0b49988b37b262aaa4500b2aaae71faff5dade/firmware/badge-supercon18.X/src/Z80/iosim.c#L134

  Are you sure? yes | no

James Newton wrote 11/08/2018 at 20:03 point

To use e.g. pip and other programs, you always want to start with 
b:
so you are in the B: drive where those programs are. To have a place to store FORTH blocks, you can do 
pip d:screens.frt=c:zork1.com
(just using zork1.com because it's a pretty good sized file)
Then you can start forth with:
forth d:screens.frt
which should start without the "no file" warning. I'll reply here as I figure out how to write stuff to that file. 

  Are you sure? yes | no

James Newton wrote 11/08/2018 at 19:55 point

Also rather useful as I was having this error:

* If CP/M OS screams at you "NO DIRECTORY SPACE" when copying files to FLASH disk, run formatting first.
* Reset your badge while holding BRK key. Badge will reset into test mode. This fills screen, allows to * test keyboard, spekaer, IO pins, etc. Screen will instruct you to press LSHIFT+ENTER to get to next test. * After all are passed, you can format your CP/M flash portion by hitting F key. If you do it, you r CP/M
* disk are formatted, it takes a few seconds.

  Are you sure? yes | no

James Newton wrote 11/08/2018 at 18:53 point

Found this in the source and I think it's useful here if only because the E: and F: drives aren't mentioned here. 

"CP/M machine is setup to use six different drives:
* A: - 22kB in size, RAM disk. Fast, no wearout, ideal for temporary storage. Trashed on reboot.
* B: - 128kB ROM disk, contains a lot of goodies. You could pack a lot of software into 128kB then.
* C: - 128kB ROM disk, contains Zork and Sargon. You know, games.
* D: - 510kB FLASH disk, free for your use
* E: - 510kB FLASH disk, free for your use
* F: - 510kB FLASH disk, free for your use"
There is also an undocumented G: drive... may not be functional. Don't try to switch to H: there isn't anyway to get out of that apparently... no Ctrl-C because no Ctrl on the keyboard.

  Are you sure? yes | no

James Newton wrote 11/05/2018 at 19:56 point

Sorry I wasn't clear: "Any information on 'Z80 fig-FORTH 1.1g'?" Google knows about an 8080 fig-FORTH 1.1 (no g):
http://www.forth.org/fig-forth/fig-forth_8080_ver_11.pdf
but Forth.org doesn't appear to be aware of a z80 implementation or a version number with a 'g'
http://www.forth.org/fig-forth/contents.html
There IS a fig-FORTH 1.1g manual but it's in another language...
http://www.ep128.hu/Ep_Util/fig-Forth.htm
google translate isn't bad, but english would be nice. Seems like a good manual. Trying to work out the BLOCK editing stuff, but the translation isn't helping. Maybe that's standard to all FORTH's? 

I messed about with FORTH when I was 16 or 17... I'm 54. So I've forgotten 99% of what I knew, but wanted to mess about with it on the badge because... um... I have no idea. I just do. 

  Are you sure? yes | no

James Newton wrote 11/09/2018 at 05:24 point

I've extracted, translated (well... google did) and written up what I've learned here:

http://techref.massmind.org/techref/language/FORTH/z80fig-Forth1_1g.htm

For the 2 people in the entire world who care about FORTH on this thing. Why did I do this?

  Are you sure? yes | no

Roger wrote 11/11/2018 at 03:40 point

I confess that's more FORTH than I understand... but I appreciate you spending the effort to dig in to this!

  Are you sure? yes | no

James Newton wrote 11/05/2018 at 06:07 point

Any info on the FORTH language supplied? 

  Are you sure? yes | no

Roger wrote 11/05/2018 at 06:17 point

When I launch it, it says "Z80 fig-FORTH 1.1g"

  Are you sure? yes | no