From f929e396dfabad7e137777b65f32e92560f3b0ef Mon Sep 17 00:00:00 2001 From: Karol Stasiak Date: Tue, 31 Jul 2018 01:02:55 +0200 Subject: [PATCH] Preliminary CP/M support --- .gitignore | 1 + README.md | 2 ++ docs/api/target-platforms.md | 4 +++ include/cpm.ini | 25 +++++++++++++++ include/cpm_bdos.mfk | 62 ++++++++++++++++++++++++++++++++++++ include/cpm_z80.ini | 25 +++++++++++++++ 6 files changed, 119 insertions(+) create mode 100644 include/cpm.ini create mode 100644 include/cpm_bdos.mfk create mode 100644 include/cpm_z80.ini diff --git a/.gitignore b/.gitignore index 1150eb98..627c21d2 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ examples/lunix/ *.inf *.tap *.d88 +*.com HELLO diff --git a/README.md b/README.md index faf168a8..dd6c7669 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,8 @@ For binary releases, see: https://github.com/KarolS/millfork/releases * ZX Spectrum 48k * NEC PC-88 + + * CP/M * inline assembly diff --git a/docs/api/target-platforms.md b/docs/api/target-platforms.md index 8f6e60b8..a71b1725 100644 --- a/docs/api/target-platforms.md +++ b/docs/api/target-platforms.md @@ -61,6 +61,10 @@ Read [the Apple 2 programming guide](./apple2-programming-guide.md) for more inf * `zxspectrum_8080` – Sinclair ZX Spectrum 48k, using only Intel 8080 instructions +* `cpm` – CP/M on Intel 8080 + +* `cpm_z80` – CP/M on Z80 + The primary and most tested platform is Commodore 64. Currently, targets that assume that the program will be loaded from disk or tape are better tested. diff --git a/include/cpm.ini b/include/cpm.ini new file mode 100644 index 00000000..29f6fae2 --- /dev/null +++ b/include/cpm.ini @@ -0,0 +1,25 @@ +;a single-load CP/M program +[compilation] +arch=i8080 +encoding=ascii +modules=default_panic,stdlib,cpm_bdos + +[allocation] +segment_default_start=$100 +segment_default_datastart=after_code +segment_default_end=$ffff +; TODO: actual end? + +[define] +CPM=1 +WIDESCREEN=1 +KEYBOARD=1 +JOYSTICKS=0 +HAS_BITMAP_MODE=0 + +[output] +style=single +format=allocated +extension=com + + diff --git a/include/cpm_bdos.mfk b/include/cpm_bdos.mfk new file mode 100644 index 00000000..98df0258 --- /dev/null +++ b/include/cpm_bdos.mfk @@ -0,0 +1,62 @@ + +inline asm void exit() { + ? ld c, 0 + call 5 + ? ret +} +inline asm void putchar (byte e) { + ? ld c, 2 + call 5 + ? ret +} + +inline asm byte getchar() { + ? ld c, 1 + call 5 + ? ret +} + +#if 0 +inline asm void putstr_cpm(pointer de) { + ? ld c, 9 + call 5 + ? ret +} +#endif + +inline asm byte readychar() { + ? ld c, 11 + call 5 + ? ret +} + +inline asm word cpm_version() { + ? ld c, 12 + call 5 + ? ret +} +inline asm void reset_disk_system() { + ? ld c, 13 + call 5 + ? ret +} +inline asm byte current_disk() { + ? ld c,25 + call 5 + ? ret +} + +#if 0 +inline asm word console_mode(word de) { + ? ld c, 109 + call 5 + ? ret +} +inline word get_console_mode() { + return console_mode($ffff) +} +inline asm void set_console_mode(word de) { + console_mode(mode) +} +#endif + diff --git a/include/cpm_z80.ini b/include/cpm_z80.ini new file mode 100644 index 00000000..99788b43 --- /dev/null +++ b/include/cpm_z80.ini @@ -0,0 +1,25 @@ +;a single-load CP/M program for Z80-based machines +[compilation] +arch=z80 +encoding=ascii +modules=default_panic,stdlib,cpm_bdos + +[allocation] +segment_default_start=$100 +segment_default_datastart=after_code +segment_default_end=$ffff +; TODO: actual end? + +[define] +CPM=1 +WIDESCREEN=1 +KEYBOARD=1 +JOYSTICKS=0 +HAS_BITMAP_MODE=0 + +[output] +style=single +format=allocated +extension=com + +