From 6a69215c9015b53a5fc4c8de1212b24eab22bef9 Mon Sep 17 00:00:00 2001 From: Paul Mathieu Date: Wed, 1 Oct 2025 14:45:45 +0200 Subject: [PATCH] polmon: add r command --- polmon.cc | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/polmon.cc b/polmon.cc index 20a2088..2f18441 100644 --- a/polmon.cc +++ b/polmon.cc @@ -12,6 +12,7 @@ #define INT80H 0 #define SHOWTITLE 0 #define BOOTSTRAP 0 +#define LAUNCH 0 #endif // WOZMON #ifndef BACKSPACE @@ -38,6 +39,10 @@ #define BOOTSTRAP 1 #endif +#ifndef LAUNCH +#define LAUNCH 1 +#endif + namespace { #if WOZMON @@ -213,6 +218,22 @@ void Status(uint8_t status) { : "ax", "bh", "dx", "cx", "di", "cc"); } +void LaunchFile(const char* name) { + constexpr uint16_t kSegment = 0x200; + constexpr uint16_t kAddress = 0x100; + constexpr uint16_t kFlatAddress = (kSegment << 4) + kAddress; + + asm volatile("mov %1, %%ax \n\t" + "push %%ax \n\t" + "mov %0, %%ax \n\t" + "push %%ax \n\t" + "mov $04, %%ah \n\t" + "int $0x80 \n\t" + "ljmp %2,%3" ::"rmi"(name), + "rmi"(kFlatAddress), "i"(kSegment), "i"(kAddress) + : "ax", "memory"); +} + bool ParseCommand(const char* buf, uint16_t& cur_addr, uint16_t& cur_seg) { bool dump = true; for (const char* ptr = buf; *ptr;) { @@ -259,7 +280,19 @@ bool ParseCommand(const char* buf, uint16_t& cur_addr, uint16_t& cur_seg) { dump = false; ClearScreen(); ptr++; -#endif +#endif // CLEARSCREENCMD +#if LAUNCH + } else if (*ptr == 'r') { + dump = false; + ptr++; + int l = 0; + for (; ptr[l]; l++) { + } + if (l >= 11) { + LaunchFile(ptr); + } + ptr += l; +#endif // LAUNCH } else if (*ptr == 'w') { dump = false; uint16_t addr = cur_addr;