Skip to content

Commit

Permalink
Debugger: Breakpoints now respect HALT/USER CPU mode (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
nzeemin committed Nov 17, 2024
1 parent 78c3e73 commit f842965
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![CodeFactor](https://www.codefactor.io/repository/github/nzeemin/neonbtl/badge)](https://www.codefactor.io/repository/github/nzeemin/neonbtl)

**Neon Back to Life!** is an emulator of Soviet computer **Sojuz-Neon PK 11/16**.
This computer was manufactured in 1991-1992 at the "Kvant" plant in Zelenograd (near Moscow), and a total of 200-1000 units were produced.
This computer was manufactured in 1991-1992 at the "Kvant" plant in Zelenograd (near Moscow), and a total of 200 units were produced.

Soyuz-Neon is based on the N1806VM2 processor, so it is partially compatible with machines such as DVK, UKNC, NEMIGA, and in general inherits the instruction set and architecture from the DEC PDP-11 line of machines.

Expand Down
16 changes: 11 additions & 5 deletions docs/user-manual-ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,21 +147,27 @@ COPY *.* FD1:

*c* — очистка лога отладочной консоли

*r* — показать содержимое регистров.
*r1* — показать содержимое регистра R1.
*r* — показать содержимое регистров.<br>
*r1* — показать содержимое регистра R1.<br>
*r1 1000* либо *r1=1000* — изменить значение регистра R1 на 1000.

*m* — дамп памяти с текущего адреса.
*m1000* — дамп памяти с адреса 1000.
*m* — дамп памяти с текущего адреса.<br>
*m1000* — дамп памяти с адреса 1000.<br>
*mr1* — дамп памяти с адреса из регистра R1.

*d* — дизассемблировать несколько инструкций, начиная с текущего адреса.<br>
*d1000* — дизассемблировать несколько инструкций, начиная с адреса 1000.

*g* — пуск эмулятора, то же что команда *Emulator* > *Run*.
*g* — пуск эмулятора, то же что команда *Emulator* > *Run*.<br>
*g1000* — поставить точку останова на адрес 1000 и пуск эмулятора.

*s* — шаг отладчика.

*b* — показать список точек останова.<br>
*b1000* — поставить точку останова на адрес 1000, режим H/U этой точки останова берётся из текущего режима процевссора.<br>
*bc1000* — убрать точку останова с адреса 1000, режим H/U берётся из текущего режима процевссора.<br>
*bc* — удалить все точки останова.

*so* — шаг отладчика с обходом подпрограмм: дизассемблером вычисляется адрес следующей инструкции, ставится точка останова на следующую инструкцию и запускается эмулятор.

*u* — сохранение дампа памяти в файл `memdump.bin`.
Expand Down
50 changes: 50 additions & 0 deletions emulator/ConsoleView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,9 @@ void ConsoleView_CmdShowHelp(const ConsoleCommandParams& /*params*/)
_T(" so Step Over; executes and stops after the current instruction\r\n")
_T(" b List all breakpoints\r\n")
_T(" bXXXXXX Set breakpoint at address XXXXXX\r\n")
_T(" bUXXXXXX or bHXXXXXX Set breakpoint at USER or HALT address XXXXXX\r\n")
_T(" bcXXXXXX Remove breakpoint at address XXXXXX\r\n")
_T(" bcUXXXXXX or bcHXXXXXX Remove breakpoint at USER or HALT address XXXXXX\r\n")
_T(" bc Remove all breakpoints\r\n")
_T(" w List all watches\r\n")
_T(" wXXXXXX Set watch at address XXXXXX\r\n")
Expand Down Expand Up @@ -647,6 +649,29 @@ void ConsoleView_CmdRemoveAllBreakpoints(const ConsoleCommandParams& /*params*/)
DebugView_Redraw();
DisasmView_Redraw();
}

void ConsoleView_CmdSetBreakpointUserAtAddress(const ConsoleCommandParams& params)
{
uint16_t address = params.paramOct1;

bool result = Emulator_AddCPUBreakpoint(address, false);
if (!result)
ConsoleView_Print(_T(" Failed to add breakpoint.\r\n"));

DebugView_Redraw();
DisasmView_Redraw();
}
void ConsoleView_CmdSetBreakpointHaltAtAddress(const ConsoleCommandParams& params)
{
uint16_t address = params.paramOct1;

bool result = Emulator_AddCPUBreakpoint(address, true);
if (!result)
ConsoleView_Print(_T(" Failed to add breakpoint.\r\n"));

DebugView_Redraw();
DisasmView_Redraw();
}
void ConsoleView_CmdSetBreakpointAtAddress(const ConsoleCommandParams& params)
{
uint16_t address = params.paramOct1;
Expand All @@ -660,6 +685,27 @@ void ConsoleView_CmdSetBreakpointAtAddress(const ConsoleCommandParams& params)
DebugView_Redraw();
DisasmView_Redraw();
}

void ConsoleView_CmdRemoveBreakpointUserAtAddress(const ConsoleCommandParams& params)
{
uint16_t address = params.paramOct1;

bool result = Emulator_RemoveCPUBreakpoint(address, false);
if (!result)
ConsoleView_Print(_T(" Failed to remove breakpoint.\r\n"));
DebugView_Redraw();
DisasmView_Redraw();
}
void ConsoleView_CmdRemoveBreakpointHaltAtAddress(const ConsoleCommandParams& params)
{
uint16_t address = params.paramOct1;

bool result = Emulator_RemoveCPUBreakpoint(address, true);
if (!result)
ConsoleView_Print(_T(" Failed to remove breakpoint.\r\n"));
DebugView_Redraw();
DisasmView_Redraw();
}
void ConsoleView_CmdRemoveBreakpointAtAddress(const ConsoleCommandParams& params)
{
uint16_t address = params.paramOct1;
Expand Down Expand Up @@ -780,8 +826,12 @@ static ConsoleCommands[] =
{ _T("m"), ARGINFO_NONE, ConsoleView_CmdPrintMemoryDumpAtPC },
{ _T("g%ho"), ARGINFO_OCT, ConsoleView_CmdRunToAddress },
{ _T("g"), ARGINFO_NONE, ConsoleView_CmdRun },
{ _T("bU%ho"), ARGINFO_OCT, ConsoleView_CmdSetBreakpointUserAtAddress },
{ _T("bH%ho"), ARGINFO_OCT, ConsoleView_CmdSetBreakpointHaltAtAddress },
{ _T("b%ho"), ARGINFO_OCT, ConsoleView_CmdSetBreakpointAtAddress },
{ _T("b"), ARGINFO_NONE, ConsoleView_CmdPrintAllBreakpoints },
{ _T("bcU%ho"), ARGINFO_OCT, ConsoleView_CmdRemoveBreakpointUserAtAddress },
{ _T("bcH%ho"), ARGINFO_OCT, ConsoleView_CmdRemoveBreakpointHaltAtAddress },
{ _T("bc%ho"), ARGINFO_OCT, ConsoleView_CmdRemoveBreakpointAtAddress },
{ _T("bc"), ARGINFO_NONE, ConsoleView_CmdRemoveAllBreakpoints },
{ _T("w%ho"), ARGINFO_OCT, ConsoleView_CmdSetWatchAtAddress },
Expand Down
2 changes: 1 addition & 1 deletion emulator/Emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ bool Emulator_AddCPUBreakpoint(uint16_t address, bool ishalt)
{
if (m_EmulatorCPUBps[i] > bpvalue) // found the place
{
memcpy(m_EmulatorCPUBps + i + 1, m_EmulatorCPUBps + i, sizeof(uint16_t) * (m_wEmulatorCPUBpsCount - i));
memcpy(m_EmulatorCPUBps + i + 1, m_EmulatorCPUBps + i, sizeof(uint32_t) * (m_wEmulatorCPUBpsCount - i));
m_EmulatorCPUBps[i] = bpvalue;
break;
}
Expand Down

0 comments on commit f842965

Please sign in to comment.