From 8ba9f2dd698d7b5b221e50302e3f424f9a176f99 Mon Sep 17 00:00:00 2001 From: julianb0 Date: Mon, 8 Jul 2019 17:46:10 +0200 Subject: [PATCH] fix --- vm/pc/exec.c | 7 +++++-- vm/pc/keybd.c | 38 ++++++++++++++++++++++++-------------- vm/pc/mem.c | 22 +++++----------------- 3 files changed, 34 insertions(+), 33 deletions(-) diff --git a/vm/pc/exec.c b/vm/pc/exec.c index ad71768..e7babd6 100644 --- a/vm/pc/exec.c +++ b/vm/pc/exec.c @@ -57,7 +57,7 @@ void exec_instr(ctx_t *ctx, ulong r1 = 0, r2 = 0, r3 = 0; // Global instruction counter - ctx->ninstrs++; + fc0++; // Current frame instruction counter fc2++; // since last frame change @@ -135,7 +135,10 @@ do_rep: if (rcx == 0) return; - ctx->ninstrs++; + // Should we really count REP's in instruction count? + fc0++; + fc1++; + fc2++; #if 0 // Show that we're REP'ing diff --git a/vm/pc/keybd.c b/vm/pc/keybd.c index 9981ff4..0255ddc 100644 --- a/vm/pc/keybd.c +++ b/vm/pc/keybd.c @@ -126,16 +126,6 @@ void console_handle_input(ctx_t *ctx, SDL_Keycode key) QKEY(BACKSLASH, '\\', '|', 0, 0, 0); QKEY(PERIOD, '.', '>', 0, 0, 0); QKEY(SLASH, '/', '?', 0, 0, 0); - QKEY(1, '1', '!', 0, 0, 0); - QKEY(2, '2', '@', 0, 0, 0); - QKEY(3, '3', '#', 0, 0, 0); - QKEY(4, '4', '$', 0, 0, 0); - QKEY(5, '5', '%', 0, 0, 0); - QKEY(6, '6', '^', 0, 0, 0); - QKEY(7, '7', '&', 0, 0, 0); - QKEY(8, '8', '*', 0, 0, 0); - QKEY(9, '9', '(', 0, 0, 0); - QKEY(0, '0', ')', 0, 0, 0); QKEY(LEFTBRACKET, '[', '{', 0, 0, 0); QKEY(RIGHTBRACKET, ']', '}', 0, 0, 0); QKEY(BACKQUOTE, '`', '~', 0, 0, 0); @@ -149,14 +139,34 @@ void console_handle_input(ctx_t *ctx, SDL_Keycode key) QKEY(SEMICOLON, ';', ':', 0, 0, 0); QKEY(EQUALS, '=', '+', 0, 0, 0); QKEY(MINUS, '-', '_', 0, 0, 0); + QKEY(1, '1', '!', 0, 0, 0); + QKEY(2, '2', '@', 0, 0, 0); + QKEY(3, '3', '#', 0, 0, 0); + QKEY(4, '4', '$', 0, 0, 0); + QKEY(5, '5', '%', 0, 0, 0); + QKEY(6, '6', '^', 0, 0, 0); + QKEY(7, '7', '&', 0, 0, 0); + QKEY(8, '8', '*', 0, 0, 0); + QKEY(9, '9', '(', 0, 0, 0); + QKEY(0, '0', ')', 0, 0, 0); #else QKEY(QUOTE, '\'', '4', '{', 0, 0); - QKEY(COMMA, ',', '?', 0, 0, 0); - QKEY(SEMICOLON, ';', '.', 0, 0, 0); - QKEY(EQUALS, '=', '+', '}', 0, 0); - QKEY(MINUS, '-', '6', '|', 0, 0); + QKEY(COMMA, ',', '?', 0, 0, 0); + QKEY(SEMICOLON, ';', '.', 0, 0, 0); + QKEY(EQUALS, '=', '+', '}', 0, 0); + QKEY(MINUS, '-', '6', '|', 0, 0); + QKEY(1, '&', '1', 0, 0, 0); + QKEY(2, 0, '2', '~', 0, 0); + QKEY(3, '"', '3', '#', 0, 0); + QKEY(4, '\'','4', '{', 0, 0); + QKEY(5, '(', '5', '[', 0, 0); + QKEY(6, '-', '6', '|', 0, 0); + QKEY(7, 0, '7', '`', 0, 0); + QKEY(8, '_', '8', '\\', 0, 0); + QKEY(9, 0, '9', '^', 0, 0); + QKEY(0, 0, '0', '@', 0, 0); #endif diff --git a/vm/pc/mem.c b/vm/pc/mem.c index 9c78749..1b4156f 100644 --- a/vm/pc/mem.c +++ b/vm/pc/mem.c @@ -128,17 +128,17 @@ ulong readmem(ctx_t *ctx, ulong addr, uint len) switch (len) { case 1: val = readmem8(ctx, real, addr); - val = SIGN_EXTEND(val, 0xFF); + val = (ulong)(long)(char)(val & 0xFF); break; case 2: val = readmem16(ctx, real, addr); - val = SIGN_EXTEND(val, 0xFFFF); + val = (ulong)(long)(short)(val & 0xFFFF); break; case 4: val = readmem32(ctx, real, addr); - val = SIGN_EXTEND(val, 0xFFFFFFFFUL); + val = (ulong)(long)(int)(val & 0xFFFFFFFF); break; case 8: @@ -169,7 +169,7 @@ void writemem(ctx_t *ctx, ulong val, ulong addr, uint len) //----------------------------------------------------------------------------// // -// The following functions zero-extend rather than sign-extend +// The following function zero-extend rather than sign-extend // ulong readmemzx(ctx_t *ctx, ulong addr, uint len) @@ -187,17 +187,5 @@ ulong readmemzx(ctx_t *ctx, ulong addr, uint len) } } -void writememzx(ctx_t *ctx, ulong val, ulong addr, uint len) -{ - GETREAL(); - CHK_RANGE(); - - switch (len) { - case 1: writemem8(ctx, val, real, addr); break; - case 2: writemem16(ctx, val, real, addr); break; - case 4: writemem32(ctx, val, real, addr); break; - case 8: writemem64(ctx, val, real, addr); break; - default: logerr("writememzx() bad length %d!\n", len); abort(); - } -} +//----------------------------------------------------------------------------//