Commit b91f456ed0417269068a3ff5469df28bbdfacda8
authorDaniël Geelen <daniel.geelen+github@gmail.com>
Thu, 5 Apr 2018 15:54:34 +0000 (17:54 +0200)
committerDaniël Geelen <daniel.geelen+github@gmail.com>
Fri, 20 Apr 2018 17:11:44 +0000 (19:11 +0200)
simavr/sim/sim_core.c

index 7be739b49b8555dabf4665b2d7531f5d908448bb..1d53668f79a275e2d8a47e89cb74e82dc1fbacdd 100644 (file)
@@ -124,12 +124,11 @@ _avr_flash_read16le(
 void avr_core_watch_write(avr_t *avr, uint16_t addr, uint8_t v)
 {
        if (addr > avr->ramend) {
-               AVR_LOG(avr, LOG_ERROR, FONT_RED
-                               "CORE: *** Invalid write address "
-                               "PC=%04x SP=%04x O=%04x Address %04x=%02x out of ram\n"
-                               FONT_DEFAULT,
-                               avr->pc, _avr_sp_get(avr), _avr_flash_read16le(avr, avr->pc), addr, v);
-               crash(avr);
+               AVR_LOG(avr, LOG_WARNING,
+                               "CORE: *** Wrapping write address "
+                               "PC=%04x SP=%04x O=%04x v=%02x Address %04x %% %04x --> %04x\n",
+                               avr->pc, _avr_sp_get(avr), _avr_flash_read16le(avr, avr->pc), v, addr, (avr->ramend+1), addr % (avr->ramend+1));
+               addr = addr % (avr->ramend+1);
        }
        if (addr < 32) {
                AVR_LOG(avr, LOG_ERROR, FONT_RED
@@ -161,12 +160,12 @@ void avr_core_watch_write(avr_t *avr, uint16_t addr, uint8_t v)
 uint8_t avr_core_watch_read(avr_t *avr, uint16_t addr)
 {
        if (addr > avr->ramend) {
-               AVR_LOG(avr, LOG_ERROR, FONT_RED
-                               "CORE: *** Invalid read address "
-                               "PC=%04x SP=%04x O=%04x Address %04x out of ram (%04x)\n"
+               AVR_LOG(avr, LOG_WARNING,
+                               "CORE: *** Wrapping read address "
+                               "PC=%04x SP=%04x O=%04x Address %04x %% %04x --> %04x\n"
                                FONT_DEFAULT,
-                               avr->pc, _avr_sp_get(avr), _avr_flash_read16le(avr, avr->pc), addr, avr->ramend);
-               crash(avr);
+                               avr->pc, _avr_sp_get(avr), _avr_flash_read16le(avr, avr->pc), addr, (avr->ramend+1), addr % (avr->ramend+1));
+               addr = addr % (avr->ramend+1);
        }
 
        if (avr->gdb) {