diff options
author | Michael Pavone <pavone@retrodev.com> | 2015-07-29 00:05:21 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2015-07-29 00:05:21 -0700 |
commit | ee2438c01d298a90d61f2fcde4e0394d51c89088 (patch) | |
tree | de4356c634df9a146b7f3486d1000e2ef84208a7 /fake_cpm.sz8 | |
parent | 7f3358e31c30e519a45258917fc419e57b4ca422 (diff) |
Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Diffstat (limited to 'fake_cpm.sz8')
-rw-r--r-- | fake_cpm.sz8 | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/fake_cpm.sz8 b/fake_cpm.sz8 new file mode 100644 index 0000000..24e32ae --- /dev/null +++ b/fake_cpm.sz8 @@ -0,0 +1,105 @@ +CONSOLE_PORT equ 0 +STATUS_PORT equ 1 +EXIT_PORT equ 2 + org $E400 + jp handle_call + ld a, (should_exit) + dec a + jr z, do_exit + ld a, 1 + ld (should_exit), a + jp $100 +do_exit: +no_impl + out (EXIT_PORT), a +should_exit: + dc.b 0 + +console_in: + in a, (CONSOLE_PORT) + ld l, a + ret +console_out: + ld a, e + out (CONSOLE_PORT), a + ret +get_iobyte: + ld a, (3) + ld l, a + ret +set_iobyte: + ld a, e + ld (3), a + ret +write_string: + ld c, '$' + jp .start +.continue + out (CONSOLE_PORT), a + inc de +.start + ld a, (de) + cp c + jr nz, .continue + ;flush output + out (STATUS_PORT),a + ret +read_string: + ld a, (de) + ld c, a + ld b, $A ;newline + inc c + inc de + push de + inc de + jp .start +.continue + in a, (CONSOLE_PORT) + cp b + jr z, .end + ld (de), a + inc de +.start + dec c + jr nz, .continue + ;todo: consume excess characters +.end + pop hl + ex de, hl + sbc hl, de + ld a, l + ld (de), a + ret + +console_status: + in a, (STATUS_PORT) + ld l, a + ret + +handle_call: + ld a, c + or a + jr z, do_exit + dec a + jr z, console_in + dec a + jr z, console_out + dec a + jr z, no_impl ;aux reader input + dec a + jr z, no_impl ;aux punch output + dec a + jr z, no_impl ;printer output + dec a + jr z, no_impl ;direct console IO + dec a + jr z, get_iobyte + dec a + jr z, set_iobyte + dec a + jr z, write_string + dec a + jr z, read_string + dec a + jr z, console_status + jp no_impl
\ No newline at end of file |