polmon: add r command
This commit is contained in:
35
polmon.cc
35
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;
|
||||
|
Reference in New Issue
Block a user