From: Daniƫl Geelen Date: Thu, 5 Apr 2018 15:54:34 +0000 (+0200) Subject: On actual hardware, memory accesses seem to wrap. X-Git-Tag: v1.7~46^2~1 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=b91f456ed0417269068a3ff5469df28bbdfacda8;p=sx%2Fsimavr.git On actual hardware, memory accesses seem to wrap. --- diff --git a/simavr/sim/sim_core.c b/simavr/sim/sim_core.c index 7be739b..1d53668 100644 --- a/simavr/sim/sim_core.c +++ b/simavr/sim/sim_core.c @@ -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) {