aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}