From 0fbfaac3e606728c816dd56fbb8a19201619190c Mon Sep 17 00:00:00 2001 From: bsekisser Date: Sun, 13 Oct 2013 11:26:17 -0400 Subject: [PATCH] sim_core.c: fix implimentation of inc/dec to match specification the avr instruction manual states that overflow be set _before_ the operation takes place, however the core tests based on the result. values checked adjusted accordingly. bug find credit goes to: Shay Green --- 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 03d46ff..366ca7d 100644 --- a/simavr/sim/sim_core.c +++ b/simavr/sim/sim_core.c @@ -1080,7 +1080,7 @@ avr_flashaddr_t avr_run_one(avr_t * avr) _avr_set_r(avr, r, res); avr->sreg[S_Z] = res == 0; avr->sreg[S_N] = res >> 7; - avr->sreg[S_V] = res == 0x7f; + avr->sreg[S_V] = res == 0x80; avr->sreg[S_S] = avr->sreg[S_N] ^ avr->sreg[S_V]; SREG(); } break; @@ -1130,7 +1130,7 @@ avr_flashaddr_t avr_run_one(avr_t * avr) _avr_set_r(avr, r, res); avr->sreg[S_Z] = res == 0; avr->sreg[S_N] = res >> 7; - avr->sreg[S_V] = res == 0x80; + avr->sreg[S_V] = res == 0x7f; avr->sreg[S_S] = avr->sreg[S_N] ^ avr->sreg[S_V]; SREG(); } break; -- 2.39.5