From f0e609390fc7781a701fa8a0ad42280b6a0cbf6f Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Thu, 26 Apr 2012 20:36:43 +0000 Subject: limit number of errors --- emu.c | 12 ++++++++++-- 1 file 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; } -- cgit v1.2.3