From 62db05d8ec93d990209b1595b427e2f0dc208ead Mon Sep 17 00:00:00 2001 From: Max Schwarz Date: Thu, 5 Feb 2015 23:17:25 +0100 Subject: [PATCH] sim_core: don't hardcode max io register address, use MAX_IOs --- simavr/sim/sim_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simavr/sim/sim_core.c b/simavr/sim/sim_core.c index 0cc3000..e58b86f 100644 --- a/simavr/sim/sim_core.c +++ b/simavr/sim/sim_core.c @@ -206,7 +206,7 @@ inline void _avr_sp_set(avr_t * avr, uint16_t sp) */ static inline void _avr_set_ram(avr_t * avr, uint16_t addr, uint8_t v) { - if (addr < 256) + if (addr < MAX_IOs + 31) _avr_set_r(avr, addr, v); else avr_core_watch_write(avr, addr, v); @@ -224,7 +224,7 @@ static inline uint8_t _avr_get_ram(avr_t * avr, uint16_t addr) */ READ_SREG_INTO(avr, avr->data[R_SREG]); - } else if (addr > 31 && addr < 256) { + } else if (addr > 31 && addr < 31 + MAX_IOs) { uint8_t io = AVR_DATA_TO_IO(addr); if (avr->io[io].r.c) -- 2.39.5