console switches/leds work
This commit is contained in:
parent
b7512ae3cd
commit
daf5e27842
4 changed files with 35 additions and 10 deletions
1
bus.h
1
bus.h
|
@ -101,6 +101,7 @@ public:
|
||||||
void clearmem();
|
void clearmem();
|
||||||
|
|
||||||
void set_console_switches(const uint16_t new_state) { console_switches = new_state; }
|
void set_console_switches(const uint16_t new_state) { console_switches = new_state; }
|
||||||
|
void set_console_switch(const int bit, const bool state) { console_switches &= ~(1 << bit); console_switches |= state << bit; }
|
||||||
uint16_t get_console_switches() { return console_switches; }
|
uint16_t get_console_switches() { return console_switches; }
|
||||||
void set_debug_mode() { console_switches |= 128; }
|
void set_debug_mode() { console_switches |= 128; }
|
||||||
|
|
||||||
|
|
9
cpu.cpp
9
cpu.cpp
|
@ -10,8 +10,6 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
uint16_t oldpc = 0;
|
|
||||||
|
|
||||||
#define SIGN(x, wm) ((wm) ? (x) & 0x80 : (x) & 0x8000)
|
#define SIGN(x, wm) ((wm) ? (x) & 0x80 : (x) & 0x8000)
|
||||||
|
|
||||||
#define IS_0(x, wm) ((wm) ? ((x) & 0xff) == 0 : (x) == 0)
|
#define IS_0(x, wm) ((wm) ? ((x) & 0xff) == 0 : (x) == 0)
|
||||||
|
@ -1264,7 +1262,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
|
||||||
// FILE *fh = fopen("og2-kek.dat", "a+");
|
// FILE *fh = fopen("og2-kek.dat", "a+");
|
||||||
// fprintf(fh, "%lu %06o MTPI %06o: %06o\n", mtpi_count, oldpc, a, v);
|
// fprintf(fh, "%lu %06o MTPI %06o: %06o\n", mtpi_count, oldpc, a, v);
|
||||||
// fclose(fh);
|
// fclose(fh);
|
||||||
DOLOG(debug, true, "%lu %06o MTPI %06o: %06o", mtpi_count, oldpc, a.addr.value(), v);
|
DOLOG(debug, true, "%lu %06o MTPI %06o: %06o", mtpi_count, pc-2, a.addr.value(), v);
|
||||||
|
|
||||||
mtpi_count++;
|
mtpi_count++;
|
||||||
|
|
||||||
|
@ -1489,7 +1487,7 @@ bool cpu::misc_operations(const uint16_t instr)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 0b0000000000000100: // IOT
|
case 0b0000000000000100: // IOT
|
||||||
//trap(020); disabled for debugging TODO
|
trap(020);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 0b0000000000000110: // RTT
|
case 0b0000000000000110: // RTT
|
||||||
|
@ -2149,7 +2147,6 @@ void cpu::step_b()
|
||||||
instruction_count++;
|
instruction_count++;
|
||||||
|
|
||||||
uint16_t temp_pc = getPC();
|
uint16_t temp_pc = getPC();
|
||||||
oldpc = temp_pc;
|
|
||||||
|
|
||||||
if ((b->getMMR0() & 0160000) == 0)
|
if ((b->getMMR0() & 0160000) == 0)
|
||||||
b->setMMR2(temp_pc);
|
b->setMMR2(temp_pc);
|
||||||
|
@ -2171,7 +2168,7 @@ void cpu::step_b()
|
||||||
if (misc_operations(instr))
|
if (misc_operations(instr))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DOLOG(warning, true, "UNHANDLED instruction %o", instr);
|
DOLOG(warning, true, "UNHANDLED instruction %06o @ %06o", instr, temp_pc);
|
||||||
|
|
||||||
trap(010);
|
trap(010);
|
||||||
}
|
}
|
||||||
|
|
18
debugger.cpp
18
debugger.cpp
|
@ -222,6 +222,23 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
else if (parts[0] == "toggle") {
|
||||||
|
auto s_it = kv.find("s");
|
||||||
|
auto t_it = kv.find("t");
|
||||||
|
|
||||||
|
if (s_it == kv.end() || t_it == kv.end())
|
||||||
|
cnsl->put_string_lf(format("toggle: parameter missing? current switches states: 0o%06o", c->getBus()->get_console_switches()));
|
||||||
|
else {
|
||||||
|
int s = std::stoi(s_it->second, nullptr, 8);
|
||||||
|
int t = std::stoi(t_it->second, nullptr, 8);
|
||||||
|
|
||||||
|
c->getBus()->set_console_switch(s, t);
|
||||||
|
|
||||||
|
cnsl->put_string_lf(format("Set switch %d to %d", s, t));
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
else if (parts[0] == "setmem") {
|
else if (parts[0] == "setmem") {
|
||||||
auto a_it = kv.find("a");
|
auto a_it = kv.find("a");
|
||||||
auto v_it = kv.find("v");
|
auto v_it = kv.find("v");
|
||||||
|
@ -345,6 +362,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
||||||
cnsl->put_string_lf("mmudump - dump MMU settings (PARs/PDRs)");
|
cnsl->put_string_lf("mmudump - dump MMU settings (PARs/PDRs)");
|
||||||
cnsl->put_string_lf("setpc - set PC to value");
|
cnsl->put_string_lf("setpc - set PC to value");
|
||||||
cnsl->put_string_lf("setmem - set memory (a=) to value (v=), both in octal, one byte");
|
cnsl->put_string_lf("setmem - set memory (a=) to value (v=), both in octal, one byte");
|
||||||
|
cnsl->put_string_lf("toggle - set switch (s=, 0...15 (decimal)) of the front panel to state (t=, 0 or 1)");
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
15
main.cpp
15
main.cpp
|
@ -49,7 +49,7 @@ void help()
|
||||||
printf("-b x enable bootloader (build-in), parameter must be \"rk05\" or \"rl02\"\n");
|
printf("-b x enable bootloader (build-in), parameter must be \"rk05\" or \"rl02\"\n");
|
||||||
printf("-n ncurses UI\n");
|
printf("-n ncurses UI\n");
|
||||||
printf("-d enable debugger\n");
|
printf("-d enable debugger\n");
|
||||||
printf("-s x set console switches state - octal number\n");
|
printf("-s x,y set console switche state: set bit x (0...15) to y (0/1)\n");
|
||||||
printf("-t enable tracing (disassemble to stderr, requires -d as well)\n");
|
printf("-t enable tracing (disassemble to stderr, requires -d as well)\n");
|
||||||
printf("-l x log to file x\n");
|
printf("-l x log to file x\n");
|
||||||
printf("-L x,y set log level for screen (x) and file (y)\n");
|
printf("-L x,y set log level for screen (x) and file (y)\n");
|
||||||
|
@ -94,9 +94,18 @@ int main(int argc, char *argv[])
|
||||||
test = optarg;
|
test = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's': {
|
||||||
console_switches = strtol(optarg, NULL, 8);
|
char *c = strchr(optarg, ',');
|
||||||
|
if (!c)
|
||||||
|
error_exit(false, "-s: parameter missing");
|
||||||
|
int bit = atoi(optarg);
|
||||||
|
int state = atoi(c + 1);
|
||||||
|
|
||||||
|
console_switches &= ~(1 << bit);
|
||||||
|
console_switches |= state << bit;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case '3':
|
case '3':
|
||||||
mode_34 = true; // switch from 11/70 to 11/34
|
mode_34 = true; // switch from 11/70 to 11/34
|
||||||
|
|
Loading…
Add table
Reference in a new issue