From 3fa972fc676cdeb2b6bb82f51d5ca29d1cc061e0 Mon Sep 17 00:00:00 2001 From: Jonathan Creekmore Date: Thu, 6 Mar 2014 09:21:52 -0600 Subject: [PATCH] 16-bits is not large enough if using RAMPZ The RAMPZ register allows the effective address to be up to 24-bit, so a 16-bit variable is not large enough to hold it. --- simavr/sim/avr_flash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simavr/sim/avr_flash.c b/simavr/sim/avr_flash.c index 5b8a615..b754f1f 100644 --- a/simavr/sim/avr_flash.c +++ b/simavr/sim/avr_flash.c @@ -53,7 +53,7 @@ static int avr_flash_ioctl(struct avr_io_t * port, uint32_t ctl, void * io_param avr_flash_t * p = (avr_flash_t *)port; avr_t * avr = p->io.avr; - uint16_t z = avr->data[R_ZL] | (avr->data[R_ZH] << 8); + avr_flashaddr_t z = avr->data[R_ZL] | (avr->data[R_ZH] << 8); if (avr->rampz) z |= avr->data[avr->rampz] << 16; uint16_t r01 = avr->data[0] | (avr->data[1] << 8); -- 2.39.5