polmon: now with ctrl+break!
This commit is contained in:
42
polmon.cc
42
polmon.cc
@@ -1,5 +1,6 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#ifndef WOZMON
|
#ifndef WOZMON
|
||||||
#define WOZMON 0
|
#define WOZMON 0
|
||||||
@@ -13,6 +14,7 @@
|
|||||||
#define SHOWTITLE 0
|
#define SHOWTITLE 0
|
||||||
#define BOOTSTRAP 0
|
#define BOOTSTRAP 0
|
||||||
#define LAUNCH 0
|
#define LAUNCH 0
|
||||||
|
#define CTRLBREAK 0
|
||||||
#endif // WOZMON
|
#endif // WOZMON
|
||||||
|
|
||||||
#ifndef BACKSPACE
|
#ifndef BACKSPACE
|
||||||
@@ -43,6 +45,10 @@
|
|||||||
#define LAUNCH 1
|
#define LAUNCH 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef CTRLBREAK
|
||||||
|
#define CTRLBREAK 1
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
#if WOZMON
|
#if WOZMON
|
||||||
@@ -234,6 +240,35 @@ void LaunchFile(const char* name) {
|
|||||||
: "ax", "memory");
|
: "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 ParseCommand(const char* buf, uint16_t& cur_addr, uint16_t& cur_seg) {
|
||||||
bool dump = true;
|
bool dump = true;
|
||||||
for (const char* ptr = buf; *ptr;) {
|
for (const char* ptr = buf; *ptr;) {
|
||||||
@@ -372,7 +407,12 @@ void polmon() {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int main() { polmon(); }
|
int main() {
|
||||||
|
#if CTRLBREAK
|
||||||
|
InstallCtrlBreak();
|
||||||
|
#endif // CTRLBREAK
|
||||||
|
polmon();
|
||||||
|
}
|
||||||
|
|
||||||
#if BOOTSTRAP
|
#if BOOTSTRAP
|
||||||
__attribute__((section(".init"), noreturn, used)) void _start() {
|
__attribute__((section(".init"), noreturn, used)) void _start() {
|
||||||
|
Reference in New Issue
Block a user