polmon: now with ctrl+break!

This commit is contained in:
2025-10-01 23:33:18 +02:00
parent 2ba1546dec
commit b1e7fde1a3

View File

@@ -1,5 +1,6 @@
#include <cstdint>
#include <cstdio>
#include <cstring>
#ifndef WOZMON
#define WOZMON 0
@@ -13,6 +14,7 @@
#define SHOWTITLE 0
#define BOOTSTRAP 0
#define LAUNCH 0
#define CTRLBREAK 0
#endif // WOZMON
#ifndef BACKSPACE
@@ -43,6 +45,10 @@
#define LAUNCH 1
#endif
#ifndef CTRLBREAK
#define CTRLBREAK 1
#endif
namespace {
#if WOZMON
@@ -234,6 +240,35 @@ void LaunchFile(const char* name) {
: "ax", "memory");
}
#if CTRLBREAK
constexpr uint16_t kCtrlBreakVector = (0x1b * 4);
extern "C" void cbreak();
asm(" .section .text.cbreak \n"
"cbreak: \n"
" xor %ax, %ax \n"
" mov %ds, %ax \n"
" cli \n"
" mov %ss, %ax \n"
" mov $0x2000, %sp \n"
" sti \n"
" pushf \n"
" push %ax \n"
" mov $0x1000, %ax \n"
" push %ax \n"
" mov $0x20, %al \n"
" out %al, $0x20 \n"
" iret \n");
void InstallCtrlBreak() {
auto vec = reinterpret_cast<void (**)()>(kCtrlBreakVector);
vec[0] = cbreak;
vec[1] = 0;
}
#endif // CTRLBREAK
bool ParseCommand(const char* buf, uint16_t& cur_addr, uint16_t& cur_seg) {
bool dump = true;
for (const char* ptr = buf; *ptr;) {
@@ -372,7 +407,12 @@ void polmon() {
} // namespace
int main() { polmon(); }
int main() {
#if CTRLBREAK
InstallCtrlBreak();
#endif // CTRLBREAK
polmon();
}
#if BOOTSTRAP
__attribute__((section(".init"), noreturn, used)) void _start() {