Commit 0fbfaac3e606728c816dd56fbb8a19201619190c
authorbsekisser <squirmyworms@embarqmail.com>
Sun, 13 Oct 2013 15:26:17 +0000 (11:26 -0400)
committerbsekisser <squirmyworms@embarqmail.com>
Sun, 13 Oct 2013 15:26:17 +0000 (11:26 -0400)
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 <gblargg@gmail.com>

simavr/sim/sim_core.c

index 03d46ffd6fe83e512a56451ecbf15a321897d419..366ca7d9c1264e65c4c4ee6e2381b3ed03d102c5 100644 (file)
@@ -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;