Compare address with I/O end address in _avr_set_ram
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 22 May 2020 16:55:10 +0000 (12:55 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Fri, 22 May 2020 16:59:51 +0000 (12:59 -0400)
commitf421abbabc712ad058f917c8e78d89122e8cd181
tree789210c89a192c6f1ef6c971906aca6d9a3c00a6
parentba721226ba869e7a1a168686cf53d4efefa4e439
Compare address with I/O end address in _avr_set_ram

In _avr_set_ram, we check if the address is smaller than `MAX_IOs + 31`
to know if it is a register or SRAM location.  In reality, many devices
have less I/Os than that, so the SRAM begins before this address.

As shown in issue #372, this causes watchpoints to not be triggered when
writing to an SRAM location that is smaller than `MAX_IOs + 31`.  For
example, a global variable on an atmega328 gets placed at address 0x100,
which is less than `MAX_IOs + 31`.

Fix this by comparing the address to the `ioend` property of `avr`.

Fixes #372
simavr/sim/sim_core.c