Skip to content

Commit

Permalink
Added new Debugcommand: jc <cycle offset> (Cycle Jump).
Browse files Browse the repository at this point in the history
  • Loading branch information
Milo-D committed Nov 17, 2020
1 parent ae14d07 commit 31681b8
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

## v.0.4.3 - 2020-11-17

- Added new Debugcommand: jc <cycle offset n> (jump cycles)
- Fast forwarding simulation without the need for setting breakpoints
- Useful when waiting for an event in an endless loop, like EEPROM Ready or a Timer Overflow.

- Bugfix: Timer increments now, even when executing illegal opcode.
- Timer Interrupts are now handled in TIFR0 and TIMSK0, too.

Expand Down
4 changes: 2 additions & 2 deletions include/parser/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#define COMMANDS_H

#define NCON 3
#define NCOM 26
#define NCOM 27

extern const int ncmd[2];
extern const char *commands[NCON][NCOM];

#endif
#endif
3 changes: 2 additions & 1 deletion include/state/debug/debugcommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ typedef struct _debugwindow debugwindow_t;
typedef struct _system system_t;

extern void jump_forward(debugwindow_t *window, system_t *sys, const int delay);
extern void jump_cycles(debugwindow_t *window, system_t *sys, const int n);
extern void set_breakpoint(debugwindow_t *window, system_t *sys, const char *bp);
extern void remove_breakpoint(debugwindow_t *window, system_t *sys, const char *bp);
extern void examine_data(debugwindow_t *window, system_t *sys, const char *mem_cell);
Expand All @@ -20,4 +21,4 @@ extern void show_clock(debugwindow_t *window, system_t *sys);
extern void show_time(debugwindow_t *window, system_t *sys);
extern void examine_data_byte(debugwindow_t *window, system_t *sys, const char *mem_cell);

#endif
#endif
4 changes: 4 additions & 0 deletions include/state/debug/stdmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#define BREAK_REACHED "(mdx) <--- Breakpoint reached --->\n"
#define DELAY_ERR "(mdx) Invalid delay. Usage: jb <delay in ms>\n"

#define CYCLE_JUMP_START "(mdx) Jumping to desired Cycle...\n"
#define CYCLE_REACHED "(mdx) <--- Cycle reached --->\n"
#define CYCLE_ERR "(mdx) Invalid cycle. Usage: jc <cycle offset>\n"

#define MEM_CELL_ERR "(mdx) Illegal memory cell.\n"
#define MEM_RANGE_ERR "(mdx) Literal length must be > 0.\n"
#define EEP_DECODE_ERR "(mdx) Could not decode EEPROM Hex File.\n"
Expand Down
4 changes: 2 additions & 2 deletions src/parser/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ const char *commands[NCON][NCOM] = {
/* DEBUG CONTEXT */
{ "n", "b", "rn", "rp", "dn", "dp", "jb", "en", "ep", "xd", "xe", "xdc",
"xec", "leep", "clear", "q", "?", "break", "unbreak", "def", "pn",
"pp", "cycles", "clock", "time", "xdb" }
};
"pp", "cycles", "clock", "time", "xdb", "jc" }
};
2 changes: 1 addition & 1 deletion src/parser/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static bool parser_parse_debug(const struct _parser *this, list_t *items) {
break;

case 6: case 9: case 10: case 13: case 17:
case 18: case 25:
case 18: case 25: case 26:

if(argc != 1)
return false;
Expand Down
17 changes: 17 additions & 0 deletions src/state/debug/debugcommands.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ void jump_forward(debugwindow_t *window, system_t *sys, const int delay) {
dwin_write(window, OPNL, BREAK_REACHED, G);
}

void jump_cycles(debugwindow_t *window, system_t *sys, const int n) {

if(n < 0) {

dwin_write(window, OPNL, CYCLE_ERR, D);
return;
}

const uint64_t end = (sys->cycles + n);
dwin_write(window, OPNL, CYCLE_JUMP_START, D);

while(sys->cycles < end)
sys_step(sys);

dwin_write(window, OPNL, CYCLE_REACHED, G);
}

void set_breakpoint(debugwindow_t *window, system_t *sys, const char *bp) {

if(sys_add_breakp(sys, bp) < 0) {
Expand Down
1 change: 1 addition & 0 deletions src/state/debug/debugstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ void debug(system_t *sys, const char *file) {
case 23: show_clock(window, sys); break;
case 24: show_time(window, sys); break;
case 25: examine_data_byte(window, sys, at(com, 1)); break;
case 26: jump_cycles(window, sys, get_int(at(com, 1))); break;

default: /* ignoring invalid input */ break;
}
Expand Down

0 comments on commit 31681b8

Please sign in to comment.