aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2012-04-26 20:36:43 +0000
committerDimitri Sokolyuk <demon@dim13.org>2012-04-26 20:36:43 +0000
commitf0e609390fc7781a701fa8a0ad42280b6a0cbf6f (patch)
tree276c663f2c26677b4c6f27086ee6d445feb457e3
parent8ec09e69f9df0377191350de22cf05e01b3358d2 (diff)
limit number of errors
-rw-r--r--emu.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/emu.c b/emu.c
index d5690b0..2b626f6 100644
--- a/emu.c
+++ b/emu.c
@@ -25,6 +25,7 @@ static unsigned short *reg;
static unsigned short skip = 0;
static unsigned short run = 1;
static unsigned short cycle = 0;
+static int errors = 0;
void
nop(unsigned short *a)
@@ -133,8 +134,10 @@ ext(unsigned short *b, unsigned short *a)
{
if (extop[*b])
extop[*b](a);
- else
+ else {
warnx("wrong extended opcode 0x%x", *b);
+ ++errors;
+ }
}
void
@@ -534,11 +537,16 @@ step(unsigned short *m, unsigned short *r)
} else {
if (op[o])
op[o](b, a);
- else
+ else {
warnx("wrong opcode 0x%x", o);
+ ++errors;
+ }
}
usleep(10 * cycle); /* 100kHz */
+ if (errors > 3)
+ return -1;
+
return cycle;
}