replaced addresses by defines

This commit is contained in:
folkert van heusden 2022-06-28 17:57:48 +02:00
parent 55ad46c55c
commit 0d7cbe3da9
4 changed files with 140 additions and 110 deletions

161
bus.cpp
View file

@ -20,7 +20,6 @@ constexpr int n_pages = 12;
constexpr int n_pages = 16; constexpr int n_pages = 16;
#endif #endif
bus::bus() bus::bus()
{ {
m = new memory(n_pages * 8192); m = new memory(n_pages * 8192);
@ -83,158 +82,156 @@ uint16_t bus::read(const uint16_t a, const bool word_mode, const bool use_prev,
if (word_mode) if (word_mode)
DOLOG(debug, false, "READ I/O %06o in byte mode", a); DOLOG(debug, false, "READ I/O %06o in byte mode", a);
if (a == 0177750) { // MAINT if (a == ADDR_MAINT) { // MAINT
DOLOG(debug, !peek_only, "read MAINT"); DOLOG(debug, !peek_only, "read MAINT");
return 1; // POWER OK return 1; // POWER OK
} }
if (a == 0177570) { // console switch & display register if (a == ADDR_CONSW) { // console switch & display register
DOLOG(debug, !peek_only, "read console switch (%06o)", console_switches); DOLOG(debug, !peek_only, "read console switch (%06o)", console_switches);
return console_switches; return console_switches;
} }
if (a == 0172540) { // KW11P programmable clock if (a == ADDR_KW11P) { // KW11P programmable clock
DOLOG(debug, !peek_only, "read programmable clock"); DOLOG(debug, !peek_only, "read programmable clock");
return 128; return 128;
} }
if (a == 0177772) { // PIR if (a == ADDR_PIR) { // PIR
DOLOG(debug, !peek_only, "read PIT"); DOLOG(debug, !peek_only, "read PIT");
return PIR; return PIR;
} }
if (a == 0177546) { // line frequency clock and status register if (a == ADDR_LFC) { // line frequency clock and status register
DOLOG(debug, !peek_only, "read line freq clock"); DOLOG(debug, !peek_only, "read line freq clock");
return lf_csr; return lf_csr;
} }
if (a == 0177514) { // printer, CSR register, LP11 if (a == ADDR_LP11CSR) { // printer, CSR register, LP11
DOLOG(debug, !peek_only, "read LP11 CSR"); DOLOG(debug, !peek_only, "read LP11 CSR");
return 0x80; return 0x80;
} }
/// MMU /// /// MMU ///
if (a >= 0172200 && a < 0172240) if (a >= ADDR_PDR_SV_START && a < ADDR_PDR_SV_END)
return read_pdr(a, 1, word_mode, peek_only); return read_pdr(a, 1, word_mode, peek_only);
else if (a >= 0172240 && a < 0172300) else if (a >= ADDR_PAR_SV_START && a < ADDR_PAR_SV_END)
return read_par(a, 1, word_mode, peek_only); return read_par(a, 1, word_mode, peek_only);
else if (a >= 0172300 && a < 0172340) else if (a >= ADDR_PDR_K_START && a < ADDR_PDR_K_END)
return read_pdr(a, 0, word_mode, peek_only); return read_pdr(a, 0, word_mode, peek_only);
else if (a >= 0172340 && a < 0172400) else if (a >= ADDR_PAR_K_START && a < ADDR_PAR_K_END)
return read_par(a, 0, word_mode, peek_only); return read_par(a, 0, word_mode, peek_only);
else if (a >= 0177600 && a < 0177640) else if (a >= ADDR_PDR_U_START && a < ADDR_PDR_U_END)
return read_pdr(a, 3, word_mode, peek_only); return read_pdr(a, 3, word_mode, peek_only);
else if (a >= 0177640 && a < 0177700) else if (a >= ADDR_PAR_U_START && a < ADDR_PAR_U_END)
return read_par(a, 3, word_mode, peek_only); return read_par(a, 3, word_mode, peek_only);
/////////// ///////////
if (word_mode) { if (word_mode) {
if (a == 0177776) { // PSW if (a == ADDR_PSW) { // PSW
DOLOG(debug, !peek_only, "readb PSW LSB"); DOLOG(debug, !peek_only, "readb PSW LSB");
return c -> getPSW() & 255; return c -> getPSW() & 255;
} }
if (a == 0177777) { if (a == ADDR_PSW + 1) {
DOLOG(debug, !peek_only, "readb PSW MSB"); DOLOG(debug, !peek_only, "readb PSW MSB");
return c -> getPSW() >> 8; return c -> getPSW() >> 8;
} }
if (a == ADDR_STACKLIM) { // stack limit register
if (a == 0177774) { // stack limit register
DOLOG(debug, !peek_only, "readb stack limit register"); DOLOG(debug, !peek_only, "readb stack limit register");
return c -> getStackLimitRegister() & 0xff; return c -> getStackLimitRegister() & 0xff;
} }
if (a == 0177775) { // stack limit register if (a == ADDR_STACKLIM + 1) { // stack limit register
DOLOG(debug, !peek_only, "readb stack limit register"); DOLOG(debug, !peek_only, "readb stack limit register");
return c -> getStackLimitRegister() >> 8; return c -> getStackLimitRegister() >> 8;
} }
if (a >= 0177700 && a <= 0177705) { // kernel R0-R5 if (a >= ADDR_KERNEL_R && a <= ADDR_KERNEL_R + 5) { // kernel R0-R5
DOLOG(debug, !peek_only, "readb kernel R%d", a - 0177700); DOLOG(debug, !peek_only, "readb kernel R%d", a - ADDR_KERNEL_R);
return c -> getRegister(a - 0177700, 0, false) & 0xff; return c -> getRegister(a - ADDR_KERNEL_R, 0, false) & 0xff;
} }
if (a >= 0177710 && a <= 0177715) { // user R0-R5 if (a >= ADDR_USER_R && a <= ADDR_USER_R + 5) { // user R0-R5
DOLOG(debug, !peek_only, "readb user R%d", a - 0177710); DOLOG(debug, !peek_only, "readb user R%d", a - ADDR_USER_R);
return c -> getRegister(a - 0177710, 3, false) & 0xff; return c -> getRegister(a - ADDR_USER_R, 3, false) & 0xff;
} }
if (a == 0177706) { // kernel SP if (a == ADDR_KERNEL_SP) { // kernel SP
DOLOG(debug, !peek_only, "readb kernel sp"); DOLOG(debug, !peek_only, "readb kernel sp");
return c -> getStackPointer(0) & 0xff; return c -> getStackPointer(0) & 0xff;
} }
if (a == 0177707) { // PC if (a == ADDR_PC) { // PC
DOLOG(debug, !peek_only, "readb pc"); DOLOG(debug, !peek_only, "readb pc");
return c -> getPC() & 0xff; return c -> getPC() & 0xff;
} }
if (a == 0177716) { // supervisor SP if (a == ADDR_SV_SP) { // supervisor SP
DOLOG(debug, !peek_only, "readb supervisor sp"); DOLOG(debug, !peek_only, "readb supervisor sp");
return c -> getStackPointer(1) & 0xff; return c -> getStackPointer(1) & 0xff;
} }
if (a == 0177717) { // user SP if (a == ADDR_USER_SP) { // user SP
DOLOG(debug, !peek_only, "readb user sp"); DOLOG(debug, !peek_only, "readb user sp");
return c -> getStackPointer(3) & 0xff; return c -> getStackPointer(3) & 0xff;
} }
if (a == ADDR_CPU_ERR) { // cpu error register
if (a == 0177766) { // cpu error register
DOLOG(debug, !peek_only, "readb cpuerr"); DOLOG(debug, !peek_only, "readb cpuerr");
return CPUERR & 0xff; return CPUERR & 0xff;
} }
} }
else { else {
if (a == 0177572) { if (a == ADDR_MMR0) {
DOLOG(debug, !peek_only, "read MMR0"); DOLOG(debug, !peek_only, "read MMR0");
return MMR0; return MMR0;
} }
if (a == 0177574) { // MMR1 if (a == ADDR_MMR1) { // MMR1
DOLOG(debug, !peek_only, "read MMR1"); DOLOG(debug, !peek_only, "read MMR1");
return MMR1; return MMR1;
} }
if (a == 0177576) { // MMR2 if (a == ADDR_MMR2) { // MMR2
DOLOG(debug, !peek_only, "read MMR2"); DOLOG(debug, !peek_only, "read MMR2");
return MMR2; return MMR2;
} }
if (a == 0172516) { // MMR3 if (a == ADDR_MMR3) { // MMR3
DOLOG(debug, !peek_only, "read MMR3"); DOLOG(debug, !peek_only, "read MMR3");
return MMR3; return MMR3;
} }
if (a == 0177776) { // PSW if (a == ADDR_PSW) { // PSW
DOLOG(debug, !peek_only, "read PSW"); DOLOG(debug, !peek_only, "read PSW");
return c -> getPSW(); return c -> getPSW();
} }
if (a == 0177774) { // stack limit register if (a == ADDR_STACKLIM) { // stack limit register
return c -> getStackLimitRegister(); return c -> getStackLimitRegister();
} }
if (a >= 0177700 && a <= 0177705) { // kernel R0-R5 if (a >= ADDR_KERNEL_R && a <= ADDR_KERNEL_R + 5) { // kernel R0-R5
DOLOG(debug, !peek_only, "read kernel R%d", a - 0177700); DOLOG(debug, !peek_only, "read kernel R%d", a - ADDR_KERNEL_R);
return c -> getRegister(a - 0177700, 0, false); return c -> getRegister(a - ADDR_KERNEL_R, 0, false);
} }
if (a >= 0177710 && a <= 0177715) { // user R0-R5 if (a >= ADDR_USER_R && a <= ADDR_USER_R + 5) { // user R0-R5
DOLOG(debug, !peek_only, "read user R%d", a - 0177710); DOLOG(debug, !peek_only, "read user R%d", a - ADDR_USER_R);
return c -> getRegister(a - 0177710, 3, false); return c -> getRegister(a - ADDR_USER_R, 3, false);
} }
if (a == 0177706) { // kernel SP if (a == ADDR_KERNEL_SP) { // kernel SP
DOLOG(debug, !peek_only, "read kernel sp"); DOLOG(debug, !peek_only, "read kernel sp");
return c -> getStackPointer(0); return c -> getStackPointer(0);
} }
if (a == 0177707) { // PC if (a == ADDR_PC) { // PC
DOLOG(debug, !peek_only, "read pc"); DOLOG(debug, !peek_only, "read pc");
return c -> getPC(); return c -> getPC();
} }
if (a == 0177716) { // supervisor SP if (a == ADDR_SV_SP) { // supervisor SP
DOLOG(debug, !peek_only, "read supervisor sp"); DOLOG(debug, !peek_only, "read supervisor sp");
return c -> getStackPointer(1); return c -> getStackPointer(1);
} }
if (a == 0177717) { // user SP if (a == ADDR_USER_SP) { // user SP
DOLOG(debug, !peek_only, "read user sp"); DOLOG(debug, !peek_only, "read user sp");
return c -> getStackPointer(3); return c -> getStackPointer(3);
} }
if (a == 0177766) { // cpu error register if (a == ADDR_CPU_ERR) { // cpu error register
DOLOG(debug, !peek_only, "read CPUERR"); DOLOG(debug, !peek_only, "read CPUERR");
return CPUERR; return CPUERR;
} }
@ -259,10 +256,10 @@ uint16_t bus::read(const uint16_t a, const bool word_mode, const bool use_prev,
// LO size register field must be all 1s, so subtract 1 // LO size register field must be all 1s, so subtract 1
constexpr uint32_t system_size = n_pages * 8192 / 64 - 1; constexpr uint32_t system_size = n_pages * 8192 / 64 - 1;
if (a == 0177762) // system size HI if (a == ADDR_SYSSIZE + 2) // system size HI
return system_size >> 16; return system_size >> 16;
if (a == 0177760) // system size LO if (a == ADDR_SYSSIZE) // system size LO
return system_size & 65535; return system_size & 65535;
if (a & 1) if (a & 1)
@ -531,7 +528,7 @@ void bus::write(const uint16_t a, const bool word_mode, uint16_t value, const bo
{ {
int run_mode = (c->getPSW() >> (use_prev ? 12 : 14)) & 3; int run_mode = (c->getPSW() >> (use_prev ? 12 : 14)) & 3;
if ((MMR0 & 1) == 1 && (a & 1) == 0 && a != 0177572) { if ((MMR0 & 1) == 1 && (a & 1) == 0 && a != ADDR_MMR0) {
const uint8_t apf = a >> 13; // active page field const uint8_t apf = a >> 13; // active page field
// TODO: D/I // TODO: D/I
@ -545,7 +542,7 @@ void bus::write(const uint16_t a, const bool word_mode, uint16_t value, const bo
} }
if (word_mode) { if (word_mode) {
if (a == 0177776 || a == 0177777) { // PSW if (a == ADDR_PSW || a == ADDR_PSW + 1) { // PSW
DOLOG(debug, true, "writeb PSW %s", a & 1 ? "MSB" : "LSB"); DOLOG(debug, true, "writeb PSW %s", a & 1 ? "MSB" : "LSB");
uint16_t vtemp = c -> getPSW(); uint16_t vtemp = c -> getPSW();
@ -561,7 +558,7 @@ void bus::write(const uint16_t a, const bool word_mode, uint16_t value, const bo
return; return;
} }
if (a == 0177774 || a == 0177775) { // stack limit register if (a == ADDR_STACKLIM || a == ADDR_STACKLIM + 1) { // stack limit register
DOLOG(debug, true, "writeb Set stack limit register: %o", value); DOLOG(debug, true, "writeb Set stack limit register: %o", value);
uint16_t v = c -> getStackLimitRegister(); uint16_t v = c -> getStackLimitRegister();
@ -575,67 +572,67 @@ void bus::write(const uint16_t a, const bool word_mode, uint16_t value, const bo
} }
} }
else { else {
if (a == 0177776) { // PSW if (a == ADDR_PSW) { // PSW
DOLOG(debug, true, "write PSW %o", value); DOLOG(debug, true, "write PSW %o", value);
c -> setPSW(value & ~16, false); c -> setPSW(value & ~16, false);
return; return;
} }
if (a == 0177774) { // stack limit register if (a == ADDR_STACKLIM) { // stack limit register
DOLOG(debug, true, "write Set stack limit register: %o", value); DOLOG(debug, true, "write Set stack limit register: %o", value);
c -> setStackLimitRegister(value); c -> setStackLimitRegister(value);
return; return;
} }
if (a >= 0177700 && a <= 0177705) { // kernel R0-R5 if (a >= ADDR_KERNEL_R && a <= ADDR_KERNEL_R + 5) { // kernel R0-R5
DOLOG(debug, true, "write kernel R%d: %o", a - 01777700, value); DOLOG(debug, true, "write kernel R%d: %o", a - ADDR_KERNEL_R, value);
c -> setRegister(a - 0177700, false, false, value); c -> setRegister(a - ADDR_KERNEL_R, false, false, value);
return; return;
} }
if (a >= 0177710 && a <= 0177715) { // user R0-R5 if (a >= ADDR_USER_R && a <= ADDR_USER_R + 5) { // user R0-R5
DOLOG(debug, true, "write user R%d: %o", a - 01777710, value); DOLOG(debug, true, "write user R%d: %o", a - ADDR_USER_R, value);
c -> setRegister(a - 0177710, true, false, value); c -> setRegister(a - ADDR_USER_R, true, false, value);
return; return;
} }
if (a == 0177706) { // kernel SP if (a == ADDR_KERNEL_SP) { // kernel SP
DOLOG(debug, true, "write kernel SP: %o", value); DOLOG(debug, true, "write kernel SP: %o", value);
c -> setStackPointer(0, value); c -> setStackPointer(0, value);
return; return;
} }
if (a == 0177707) { // PC if (a == ADDR_PC) { // PC
DOLOG(debug, true, "write PC: %o", value); DOLOG(debug, true, "write PC: %o", value);
c -> setPC(value); c -> setPC(value);
return; return;
} }
if (a == 0177716) { // supervisor SP if (a == ADDR_SV_SP) { // supervisor SP
DOLOG(debug, true, "write supervisor sp: %o", value); DOLOG(debug, true, "write supervisor sp: %o", value);
c -> setStackPointer(1, value); c -> setStackPointer(1, value);
return; return;
} }
if (a == 0177717) { // user SP if (a == ADDR_USER_SP) { // user SP
DOLOG(debug, true, "write user sp: %o", value); DOLOG(debug, true, "write user sp: %o", value);
c -> setStackPointer(3, value); c -> setStackPointer(3, value);
return; return;
} }
if (a == 0177770) { // microprogram break register if (a == ADDR_MICROPROG_BREAK_REG) { // microprogram break register
return; return;
} }
} }
if (a == 0177766) { // cpu error register if (a == ADDR_CPU_ERR) { // cpu error register
DOLOG(debug, true, "write CPUERR: %o", value); DOLOG(debug, true, "write CPUERR: %o", value);
CPUERR = 0; CPUERR = 0;
return; return;
} }
if (a == 0172516) { // MMR3 if (a == ADDR_MMR3) { // MMR3
DOLOG(debug, true, "write set MMR3: %o", value); DOLOG(debug, true, "write set MMR3: %o", value);
MMR3 = value & 067; MMR3 = value & 067;
return; return;
} }
if (a == 0177572) { // MMR0 if (a == ADDR_MMR0) { // MMR0
DOLOG(debug, true, "write set MMR0: %o", value); DOLOG(debug, true, "write set MMR0: %o", value);
setMMR0(value); setMMR0(value);
@ -643,13 +640,13 @@ void bus::write(const uint16_t a, const bool word_mode, uint16_t value, const bo
return; return;
} }
if (a == 0177772) { // PIR if (a == ADDR_PIR) { // PIR
DOLOG(debug, true, "write set PIR: %o", value); DOLOG(debug, true, "write set PIR: %o", value);
PIR = value; // TODO PIR = value; // TODO
return; return;
} }
if (a == 0177546) { // line frequency clock and status register if (a == ADDR_LFC) { // line frequency clock and status register
DOLOG(debug, true, "write set LFC/SR: %o", value); DOLOG(debug, true, "write set LFC/SR: %o", value);
lf_csr = value; lf_csr = value;
return; return;
@ -677,56 +674,48 @@ void bus::write(const uint16_t a, const bool word_mode, uint16_t value, const bo
/// MMU /// /// MMU ///
// supervisor // supervisor
if (a >= 0172200 && a < 0172240) { if (a >= ADDR_PDR_SV_START && a < ADDR_PDR_SV_END) {
write_pdr(a, 1, value, word_mode); write_pdr(a, 1, value, word_mode);
return; return;
} }
if (a >= 0172240 && a < 0172300) { if (a >= ADDR_PAR_SV_START && a < ADDR_PAR_SV_END) {
write_par(a, 1, value, word_mode); write_par(a, 1, value, word_mode);
return; return;
} }
// kernel // kernel
if (a >= 0172300 && a < 0172340) { if (a >= ADDR_PDR_K_START && a < ADDR_PDR_K_END) {
write_pdr(a, 0, value, word_mode); write_pdr(a, 0, value, word_mode);
return; return;
} }
if (a >= 0172340 && a < 0172400) { if (a >= ADDR_PAR_K_START && a < ADDR_PAR_K_END) {
write_par(a, 0, value, word_mode); write_par(a, 0, value, word_mode);
return; return;
} }
// user // user
if (a >= 0177600 && a < 0177640) { if (a >= ADDR_PDR_U_START && a < ADDR_PDR_U_END) {
write_pdr(a, 3, value, word_mode); write_pdr(a, 3, value, word_mode);
return; return;
} }
if (a >= 0177640 && a < 0177700) { if (a >= ADDR_PAR_U_START && a < ADDR_PAR_U_END) {
write_par(a, 3, value, word_mode); write_par(a, 3, value, word_mode);
return; return;
} }
//// ////
if (a == 0177746) { // cache control register if (a == ADDR_CCR) { // cache control register
// TODO // TODO
return; return;
} }
if (a == 0177570) { // switch register if (a == ADDR_CONSW) { // switch register
switch_register = value; switch_register = value;
return; return;
} }
/////////// ///////////
if (a == 0177374) { // TODO
DOLOG(debug, true, "char: %c", value & 127);
return;
}
if (a & 1)
DOLOG(debug, true, "bus::writeWord: odd address UNHANDLED");
DOLOG(debug, true, "UNHANDLED write %o(%c): %o", a, word_mode ? 'B' : ' ', value); DOLOG(debug, true, "UNHANDLED write %o(%c): %o", a, word_mode ? 'B' : ' ', value);
// c -> busError(); // c -> busError();

41
bus.h
View file

@ -10,6 +10,47 @@
#include "rk05.h" #include "rk05.h"
#include "rl02.h" #include "rl02.h"
#define ADDR_MMR0 0177572
#define ADDR_MMR1 0177574
#define ADDR_MMR2 0177576
#define ADDR_MMR3 0172516
#define ADDR_PIR 0177772
#define ADDR_LFC 0177546 // line frequency
#define ADDR_MAINT 0177750
#define ADDR_CONSW 0177570
#define ADDR_KW11P 0172540
#define ADDR_LP11CSR 0177514 // printer
#define ADDR_PDR_SV_START 0172200
#define ADDR_PDR_SV_END 0172240
#define ADDR_PAR_SV_START 0172240
#define ADDR_PAR_SV_END 0172300
#define ADDR_PDR_K_START 0172300
#define ADDR_PDR_K_END 0172340
#define ADDR_PAR_K_START 0172340
#define ADDR_PAR_K_END 0172400
#define ADDR_PDR_U_START 0177600
#define ADDR_PDR_U_END 0177640
#define ADDR_PAR_U_START 0177640
#define ADDR_PAR_U_END 0177700
#define ADDR_PSW 0177776
#define ADDR_STACKLIM 0177774
#define ADDR_KERNEL_R 0177700
#define ADDR_USER_R 0177710
#define ADDR_KERNEL_SP 0177706
#define ADDR_PC 0177707
#define ADDR_SV_SP 0177716
#define ADDR_USER_SP 0177717
#define ADDR_CPU_ERR 0177766
#define ADDR_SYSSIZE 0177760
#define ADDR_MICROPROG_BREAK_REG 0177770
#define ADDR_CCR 0177746
class cpu; class cpu;
class memory; class memory;
class tty; class tty;

36
cpu.cpp
View file

@ -162,7 +162,7 @@ bool cpu::put_result(const uint16_t a, const uint8_t dst_mode, const uint8_t dst
b->write(a, word_mode, value, false); b->write(a, word_mode, value, false);
return a != 0177776; return a != ADDR_PSW;
} }
uint16_t cpu::addRegister(const int nr, const bool prev_mode, const uint16_t value) uint16_t cpu::addRegister(const int nr, const bool prev_mode, const uint16_t value)
@ -404,7 +404,7 @@ bool cpu::putGAM(const uint8_t mode, const int reg, const bool word_mode, const
break; break;
} }
return addr == -1 || addr != 0177776; return addr == -1 || addr != ADDR_PSW;
} }
uint16_t cpu::getGAMAddress(const uint8_t mode, const int reg, const bool word_mode, const bool prev_mode) uint16_t cpu::getGAMAddress(const uint8_t mode, const int reg, const bool word_mode, const bool prev_mode)
@ -554,7 +554,7 @@ bool cpu::double_operand_instructions(const uint16_t instr)
int16_t dst_value = b->readWord(dst_addr); int16_t dst_value = b->readWord(dst_addr);
int16_t result = 0; int16_t result = 0;
bool set_flags = dst_addr != 0177776; bool set_flags = dst_addr != ADDR_PSW;
if (instr & 0x8000) { if (instr & 0x8000) {
result = (dst_value - ssrc_value) & 0xffff; result = (dst_value - ssrc_value) & 0xffff;
@ -759,7 +759,7 @@ bool cpu::additional_double_operand_instructions(const uint16_t instr)
else { else {
b->write(a, false, vl, false); b->write(a, false, vl, false);
set_flags = a != 0177776; set_flags = a != ADDR_PSW;
} }
if (set_flags) { if (set_flags) {
@ -816,7 +816,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
v = ((v & 0xff) << 8) | (v >> 8); v = ((v & 0xff) << 8) | (v >> 8);
set_flags = a != 0177776; set_flags = a != ADDR_PSW;
b->writeWord(a, v); b->writeWord(a, v);
} }
@ -845,7 +845,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
else { else {
uint16_t a = getGAMAddress(dst_mode, dst_reg, word_mode, false); uint16_t a = getGAMAddress(dst_mode, dst_reg, word_mode, false);
set_flags = a != 0177776; set_flags = a != ADDR_PSW;
b -> write(a, word_mode, 0, false); b -> write(a, word_mode, 0, false);
} }
@ -885,7 +885,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
else else
v ^= 0xffff; v ^= 0xffff;
bool set_flags = a != 0177776; bool set_flags = a != ADDR_PSW;
if (set_flags) { if (set_flags) {
setPSW_n(SIGN(v, word_mode)); setPSW_n(SIGN(v, word_mode));
@ -918,7 +918,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
uint16_t v = b -> read(a, word_mode, false); uint16_t v = b -> read(a, word_mode, false);
int32_t vl = (v + 1) & (word_mode ? 0xff : 0xffff); int32_t vl = (v + 1) & (word_mode ? 0xff : 0xffff);
bool set_flags = a != 0177776; bool set_flags = a != ADDR_PSW;
if (set_flags) { if (set_flags) {
setPSW_n(SIGN(vl, word_mode)); setPSW_n(SIGN(vl, word_mode));
@ -951,7 +951,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
uint16_t v = b -> read(a, word_mode, false); uint16_t v = b -> read(a, word_mode, false);
int32_t vl = (v - 1) & (word_mode ? 0xff : 0xffff); int32_t vl = (v - 1) & (word_mode ? 0xff : 0xffff);
bool set_flags = a != 0177776; bool set_flags = a != ADDR_PSW;
if (set_flags) { if (set_flags) {
setPSW_n(SIGN(vl, word_mode)); setPSW_n(SIGN(vl, word_mode));
@ -986,7 +986,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
b->write(a, word_mode, v, false); b->write(a, word_mode, v, false);
bool set_flags = a != 0177776; bool set_flags = a != ADDR_PSW;
if (set_flags) { if (set_flags) {
setPSW_n(SIGN(v, word_mode)); setPSW_n(SIGN(v, word_mode));
@ -1024,7 +1024,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
b->write(a, word_mode, v, false); b->write(a, word_mode, v, false);
bool set_flags = a != 0177776; bool set_flags = a != ADDR_PSW;
if (set_flags) { if (set_flags) {
setPSW_n(SIGN(v, word_mode)); setPSW_n(SIGN(v, word_mode));
@ -1066,7 +1066,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
b->write(a, word_mode, v, false); b->write(a, word_mode, v, false);
bool set_flags = a != 0177776; bool set_flags = a != ADDR_PSW;
if (set_flags) { if (set_flags) {
setPSW_n(SIGN(v, word_mode)); setPSW_n(SIGN(v, word_mode));
@ -1128,7 +1128,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
b->write(a, word_mode, temp, false); b->write(a, word_mode, temp, false);
bool set_flags = a != 0177776; bool set_flags = a != ADDR_PSW;
if (set_flags) { if (set_flags) {
setPSW_c(new_carry); setPSW_c(new_carry);
@ -1179,7 +1179,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
b->write(a, word_mode, temp, false); b->write(a, word_mode, temp, false);
bool set_flags = a != 0177776; bool set_flags = a != ADDR_PSW;
if (set_flags) { if (set_flags) {
setPSW_c(new_carry); setPSW_c(new_carry);
@ -1238,7 +1238,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
b->write(a, word_mode, v, false); b->write(a, word_mode, v, false);
bool set_flags = a != 0177776; bool set_flags = a != ADDR_PSW;
if (set_flags) { if (set_flags) {
setPSW_n(SIGN(v, word_mode)); setPSW_n(SIGN(v, word_mode));
@ -1269,7 +1269,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
uint16_t vl = b -> read(a, word_mode, false); uint16_t vl = b -> read(a, word_mode, false);
uint16_t v = (vl << 1) & (word_mode ? 0xff : 0xffff); uint16_t v = (vl << 1) & (word_mode ? 0xff : 0xffff);
bool set_flags = a != 0177776; bool set_flags = a != ADDR_PSW;
if (set_flags) { if (set_flags) {
setPSW_n(SIGN(v, word_mode)); setPSW_n(SIGN(v, word_mode));
@ -1299,7 +1299,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
// calculate address in current address space // calculate address in current address space
uint16_t a = getGAMAddress(dst_mode, dst_reg, false, false); uint16_t a = getGAMAddress(dst_mode, dst_reg, false, false);
set_flags = a != 0177776; set_flags = a != ADDR_PSW;
// read from previous space // read from previous space
v = b -> read(a, false, true); v = b -> read(a, false, true);
@ -1334,7 +1334,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
else { else {
uint16_t a = getGAMAddress(dst_mode, dst_reg, false, false); uint16_t a = getGAMAddress(dst_mode, dst_reg, false, false);
set_flags = a != 0177776; set_flags = a != ADDR_PSW;
b -> write(a, false, v, true); // put in '13/12' address space b -> write(a, false, v, true); // put in '13/12' address space
} }

View file

@ -106,14 +106,14 @@ void mmu_dump(console *const cnsl, bus *const b)
cnsl->put_string_lf(format("MMR2: %06o", b->getMMR2())); cnsl->put_string_lf(format("MMR2: %06o", b->getMMR2()));
cnsl->put_string_lf(format("MMR3: %06o", mmr3)); cnsl->put_string_lf(format("MMR3: %06o", mmr3));
dump_par_pdr(cnsl, b, 0172200, 0172240, "supervisor i-space", 0); dump_par_pdr(cnsl, b, ADDR_PDR_SV_START, ADDR_PAR_SV_START, "supervisor i-space", 0);
dump_par_pdr(cnsl, b, 0172220, 0172260, "supervisor d-space", 1 + (!!(mmr3 & 2))); dump_par_pdr(cnsl, b, ADDR_PDR_SV_START + 020, ADDR_PAR_SV_START + 020, "supervisor d-space", 1 + (!!(mmr3 & 2)));
dump_par_pdr(cnsl, b, 0172300, 0172340, "kernel i-space", 0); dump_par_pdr(cnsl, b, ADDR_PDR_K_START, ADDR_PAR_K_START, "kernel i-space", 0);
dump_par_pdr(cnsl, b, 0172320, 0172360, "kernel d-space", 1 + (!!(mmr3 & 4))); dump_par_pdr(cnsl, b, ADDR_PDR_K_START + 020, ADDR_PAR_K_START + 020, "kernel d-space", 1 + (!!(mmr3 & 4)));
dump_par_pdr(cnsl, b, 0177600, 0177640, "user i-space", 0); dump_par_pdr(cnsl, b, ADDR_PDR_U_START, ADDR_PAR_U_START, "user i-space", 0);
dump_par_pdr(cnsl, b, 0177620, 0177660, "user d-space", 1 + (!!(mmr3 & 1))); dump_par_pdr(cnsl, b, ADDR_PDR_U_START + 020, ADDR_PAR_U_START + 020, "user d-space", 1 + (!!(mmr3 & 1)));
} }
void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const stop_event, const bool tracing_in) void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const stop_event, const bool tracing_in)