console switches/leds work

This commit is contained in:
folkert van heusden 2023-03-19 15:33:39 +01:00
parent b7512ae3cd
commit daf5e27842
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1
4 changed files with 35 additions and 10 deletions

1
bus.h
View file

@ -101,6 +101,7 @@ public:
void clearmem();
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; }
void set_debug_mode() { console_switches |= 128; }

View file

@ -10,8 +10,6 @@
#include "log.h"
#include "utils.h"
uint16_t oldpc = 0;
#define SIGN(x, wm) ((wm) ? (x) & 0x80 : (x) & 0x8000)
#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+");
// fprintf(fh, "%lu %06o MTPI %06o: %06o\n", mtpi_count, oldpc, a, v);
// 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++;
@ -1489,7 +1487,7 @@ bool cpu::misc_operations(const uint16_t instr)
return true;
case 0b0000000000000100: // IOT
//trap(020); disabled for debugging TODO
trap(020);
return true;
case 0b0000000000000110: // RTT
@ -2149,7 +2147,6 @@ void cpu::step_b()
instruction_count++;
uint16_t temp_pc = getPC();
oldpc = temp_pc;
if ((b->getMMR0() & 0160000) == 0)
b->setMMR2(temp_pc);
@ -2171,7 +2168,7 @@ void cpu::step_b()
if (misc_operations(instr))
return;
DOLOG(warning, true, "UNHANDLED instruction %o", instr);
DOLOG(warning, true, "UNHANDLED instruction %06o @ %06o", instr, temp_pc);
trap(010);
}

View file

@ -222,6 +222,23 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
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") {
auto a_it = kv.find("a");
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("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("toggle - set switch (s=, 0...15 (decimal)) of the front panel to state (t=, 0 or 1)");
continue;
}

View file

@ -49,7 +49,7 @@ void help()
printf("-b x enable bootloader (build-in), parameter must be \"rk05\" or \"rl02\"\n");
printf("-n ncurses UI\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("-l x log to file x\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;
break;
case 's':
console_switches = strtol(optarg, NULL, 8);
case 's': {
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;
}
case '3':
mode_34 = true; // switch from 11/70 to 11/34