-d switch

This commit is contained in:
folkert van heusden 2022-03-20 12:30:08 +01:00
parent 3ac4decdc0
commit 4367cbe489
3 changed files with 26 additions and 12 deletions

22
cpu.cpp
View file

@ -30,6 +30,11 @@ void cpu::reset()
runMode = resetFlag = haltFlag = false;
}
void cpu::setDisassemble(const bool state)
{
disas = state;
}
uint16_t cpu::getRegister(const int nr, const bool prev_mode) const
{
if (nr < 6)
@ -295,15 +300,15 @@ bool cpu::double_operand_instructions(const uint16_t instr)
if (operation == 0b111)
return additional_double_operand_instructions(instr);
const uint8_t src = (instr >> 6) & 63;
const uint8_t src_mode = (src >> 3) & 7;
const uint8_t src_reg = src & 7;
const uint8_t src = (instr >> 6) & 63;
const uint8_t src_mode = (src >> 3) & 7;
const uint8_t src_reg = src & 7;
uint16_t src_value;
uint16_t src_value = 0;
const uint8_t dst = instr & 63;
const uint8_t dst_mode = (dst >> 3) & 7;
const uint8_t dst_reg = dst & 7;
const uint8_t dst = instr & 63;
const uint8_t dst_mode = (dst >> 3) & 7;
const uint8_t dst_reg = dst & 7;
switch(operation) {
case 0b001: // MOV/MOVB Move Word/Byte
@ -1509,7 +1514,8 @@ bool cpu::step()
if (getPC() & 1)
busError();
disassemble();
if (disas)
disassemble();
b -> setMMR2(getPC());
uint16_t instr = b->readWord(getPC());

5
cpu.h
View file

@ -10,8 +10,9 @@
class cpu
{
private:
bool disas { false };
uint16_t regs0_5[2][6]; // R0...5, selected by bit 11 in PSW,
uint16_t sp[3+1]; // stackpointers, MF../MT.. select via 12/13 from PSW, others via 14/15
uint16_t sp[3 + 1]; // stackpointers, MF../MT.. select via 12/13 from PSW, others via 14/15
uint16_t pc { 0 };
uint16_t psw { 0 }, fpsr { 0 };
uint16_t stackLimitRegister { 0 };
@ -44,6 +45,8 @@ public:
explicit cpu(bus *const b);
~cpu();
void setDisassemble(const bool state);
bus *getBus() { return b; }
void reset();

View file

@ -217,6 +217,7 @@ void help()
printf("-p 123 set CPU start pointer to decimal(!) value\n");
printf("-L f.bin load file into memory at address given by -p (and run it)\n");
printf("-n ncurses UI\n");
printf("-d enable disassemble\n");
}
int main(int argc, char *argv[])
@ -231,13 +232,17 @@ int main(int argc, char *argv[])
bool testMode = false, testCases = false;
int opt = -1;
while((opt = getopt(argc, argv, "hm:T:R:p:nL:")) != -1)
while((opt = getopt(argc, argv, "hm:T:R:p:ndL:")) != -1)
{
switch(opt) {
case 'h':
help();
return 1;
case 'd':
c->setDisassemble(true);
break;
case 'n':
withUI = true;
break;
@ -336,7 +341,7 @@ int main(int argc, char *argv[])
icount++;
if (icount % 1000 == 0) {
if ((icount & 4095) == 0) {
if (poll(fds, 1, 0) == 1 && fds[0].revents) {
int ch = 0;
@ -352,7 +357,7 @@ int main(int argc, char *argv[])
tty_->sendChar(ch);
}
if (icount % 100000 == 0 && withUI) {
if ((icount & 262143) == 0 && withUI) {
unsigned long now = get_ms();
mvwprintw(w_main_b -> win, 0, 24, "%.1f/s ", icount * 1000.0 / (now - start));
mvwprintw(w_main_b -> win, 0, 42, "%06o", b->get_switch_register());