-d switch
This commit is contained in:
parent
3ac4decdc0
commit
4367cbe489
3 changed files with 26 additions and 12 deletions
8
cpu.cpp
8
cpu.cpp
|
@ -30,6 +30,11 @@ void cpu::reset()
|
||||||
runMode = resetFlag = haltFlag = false;
|
runMode = resetFlag = haltFlag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cpu::setDisassemble(const bool state)
|
||||||
|
{
|
||||||
|
disas = state;
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t cpu::getRegister(const int nr, const bool prev_mode) const
|
uint16_t cpu::getRegister(const int nr, const bool prev_mode) const
|
||||||
{
|
{
|
||||||
if (nr < 6)
|
if (nr < 6)
|
||||||
|
@ -299,7 +304,7 @@ bool cpu::double_operand_instructions(const uint16_t instr)
|
||||||
const uint8_t src_mode = (src >> 3) & 7;
|
const uint8_t src_mode = (src >> 3) & 7;
|
||||||
const uint8_t src_reg = src & 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 = instr & 63;
|
||||||
const uint8_t dst_mode = (dst >> 3) & 7;
|
const uint8_t dst_mode = (dst >> 3) & 7;
|
||||||
|
@ -1509,6 +1514,7 @@ bool cpu::step()
|
||||||
if (getPC() & 1)
|
if (getPC() & 1)
|
||||||
busError();
|
busError();
|
||||||
|
|
||||||
|
if (disas)
|
||||||
disassemble();
|
disassemble();
|
||||||
|
|
||||||
b -> setMMR2(getPC());
|
b -> setMMR2(getPC());
|
||||||
|
|
3
cpu.h
3
cpu.h
|
@ -10,6 +10,7 @@
|
||||||
class cpu
|
class cpu
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
bool disas { false };
|
||||||
uint16_t regs0_5[2][6]; // R0...5, selected by bit 11 in PSW,
|
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 pc { 0 };
|
||||||
|
@ -44,6 +45,8 @@ public:
|
||||||
explicit cpu(bus *const b);
|
explicit cpu(bus *const b);
|
||||||
~cpu();
|
~cpu();
|
||||||
|
|
||||||
|
void setDisassemble(const bool state);
|
||||||
|
|
||||||
bus *getBus() { return b; }
|
bus *getBus() { return b; }
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
11
main.cpp
11
main.cpp
|
@ -217,6 +217,7 @@ void help()
|
||||||
printf("-p 123 set CPU start pointer to decimal(!) value\n");
|
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("-L f.bin load file into memory at address given by -p (and run it)\n");
|
||||||
printf("-n ncurses UI\n");
|
printf("-n ncurses UI\n");
|
||||||
|
printf("-d enable disassemble\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@ -231,13 +232,17 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
bool testMode = false, testCases = false;
|
bool testMode = false, testCases = false;
|
||||||
int opt = -1;
|
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) {
|
switch(opt) {
|
||||||
case 'h':
|
case 'h':
|
||||||
help();
|
help();
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
case 'd':
|
||||||
|
c->setDisassemble(true);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
withUI = true;
|
withUI = true;
|
||||||
break;
|
break;
|
||||||
|
@ -336,7 +341,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
icount++;
|
icount++;
|
||||||
|
|
||||||
if (icount % 1000 == 0) {
|
if ((icount & 4095) == 0) {
|
||||||
if (poll(fds, 1, 0) == 1 && fds[0].revents) {
|
if (poll(fds, 1, 0) == 1 && fds[0].revents) {
|
||||||
int ch = 0;
|
int ch = 0;
|
||||||
|
|
||||||
|
@ -352,7 +357,7 @@ int main(int argc, char *argv[])
|
||||||
tty_->sendChar(ch);
|
tty_->sendChar(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (icount % 100000 == 0 && withUI) {
|
if ((icount & 262143) == 0 && withUI) {
|
||||||
unsigned long now = get_ms();
|
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, 24, "%.1f/s ", icount * 1000.0 / (now - start));
|
||||||
mvwprintw(w_main_b -> win, 0, 42, "%06o", b->get_switch_register());
|
mvwprintw(w_main_b -> win, 0, 42, "%06o", b->get_switch_register());
|
||||||
|
|
Loading…
Add table
Reference in a new issue