From 68eb4b2f6d5d7a98d270e12c4b8ff065c07f5e94 Mon Sep 17 00:00:00 2001 From: Ben Smith Date: Sun, 27 Jan 2019 00:13:06 -0800 Subject: [PATCH] Small optimization: remove use of s_opcode_bytes --- demo/binjgb.wasm | Bin 119382 -> 118929 bytes src/emulator-debug.c | 20 ++++++++++++++++++++ src/emulator.c | 29 +++++------------------------ 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/demo/binjgb.wasm b/demo/binjgb.wasm index 04a7c73cde39ec2a698306bbd57f3bf9a29f54d5..b7b0a3ea87105132eedc44e7f5b848bfcb2bfee7 100644 GIT binary patch delta 23775 zcmcJ134B!575BSuX0lC|0kT0zcry^z0AYt9kOu-P3W!1lm8C9}pw+lwsYrl?pnw8i z=~x5>wH2*pk^03}luf_d)&*@<#45P7B9+CjYK4k?|8w4UGnq*O)cO79ZRebO&;6fs z&%N)y^WHm;C$HL&yyaAqUcGnQ>7*Tc`mesx^_Er1^VG^; zym{dqLm26mhN!PV8WgZ<GFEdHgeg1$* z3ZhZRv-+fH=F(kSMMRgW8A}WOh6uGWG{X;0!{0;rLpi}9kO*WX8M@q(Q6!)3)KZV6 z$S+Gq2wkqawC!Zw%$#HDw^fjYj<#x*w^RU)fRV5)BLx76N@$#9YCtzVIbZ}k1hRr! zP_Kd)B%`R28Jhee)Vc-s(EgRb1}gwWxRoj7%bCWt%x!3)wniG40G8+8LIVXPO>rx5 z5$phV1$GH&M;a_EhU>s~xQ^1Gr5Ns~Ge4c7sXBNWk2JZpQ(JjmR$Ey*vb6|MQ{{VI zTPJLlp5adq*qG)fTV7)|&nb}+?vN0b44 zPl4R?!zA!87N{n_^sC(y7W5nP&4t<0Xw!x{565s;*&SKs49Ki-UM7|MIk>Hg<&5&) z(#UJsN;emL4?Pxq=Nnb&uQICw@bj%}`i%8M(FQ$%g99~{bVhlHxb_FBVS(=_@r2C*l$vDq9yfT=Ta6o1A_fAoQ*^9 z9=H_<=Jh`(2-X$m=laQA$N|DW#}(jGvM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z?}YQKdiif~{u+Mg^=n_QBxS*G9Q>xjZ$5b9t60Ui4$6gF;jjmO`{DN${C)-C*(9Z# z3XSH#ZxsA)fZyI;lJpV$4#V#o`27Sw{3fm!e)yf5w!I~7ce3J}1ogMTZvp&P!tWvY z?dk=|Dp}duVoKEEqoZS@;15hiI?o|7OAS>x@k@Z%X3j~20mteHFw-O$MVO$&@;V%N7OB@lctbuca2P^3ip*pp=o$EQ@Q8uH_UM`NtKMh*!u}u3P2$f0 diff --git a/src/emulator-debug.c b/src/emulator-debug.c index 245d180..293d9b7 100644 --- a/src/emulator-debug.c +++ b/src/emulator-debug.c @@ -220,6 +220,26 @@ static void sprint_hex(char* buffer, u8 val) { buffer[1] = hex_digits[val & 0xf]; } +static u8 s_opcode_bytes[] = { + /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ + /* 00 */ 1, 3, 1, 1, 1, 1, 2, 1, 3, 1, 1, 1, 1, 1, 2, 1, + /* 10 */ 1, 3, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, + /* 20 */ 2, 3, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, + /* 30 */ 2, 3, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, + /* 40 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + /* 50 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + /* 60 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + /* 70 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + /* 80 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + /* 90 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + /* a0 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + /* b0 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + /* c0 */ 1, 1, 3, 3, 3, 1, 2, 1, 1, 1, 3, 2, 3, 3, 2, 1, + /* d0 */ 1, 1, 3, 1, 3, 1, 2, 1, 1, 1, 3, 1, 3, 1, 2, 1, + /* e0 */ 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 1, 1, 2, 1, + /* f0 */ 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 1, 1, 2, 1, +}; + int opcode_bytes(u8 opcode) { return s_opcode_bytes[opcode]; } void emulator_get_opcode_mnemonic(u16 opcode, char* buffer, size_t size) { diff --git a/src/emulator.c b/src/emulator.c index 056646b..50cf4c8 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -3531,26 +3531,6 @@ static void set_af_reg(Emulator* e, u16 af) { REG.F.C = UNPACK(af, CPU_FLAG_C); } -static u8 s_opcode_bytes[] = { - /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ - /* 00 */ 1, 3, 1, 1, 1, 1, 2, 1, 3, 1, 1, 1, 1, 1, 2, 1, - /* 10 */ 1, 3, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, - /* 20 */ 2, 3, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, - /* 30 */ 2, 3, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, - /* 40 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - /* 50 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - /* 60 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - /* 70 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - /* 80 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - /* 90 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - /* a0 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - /* b0 */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - /* c0 */ 1, 1, 3, 3, 3, 1, 2, 1, 1, 1, 3, 2, 3, 3, 2, 1, - /* d0 */ 1, 1, 3, 1, 3, 1, 2, 1, 1, 1, 3, 1, 3, 1, 2, 1, - /* e0 */ 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 1, 1, 2, 1, - /* f0 */ 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 1, 1, 2, 1, -}; - #define TICK tick(e) #define RA REG.A #define RSP REG.SP @@ -3566,8 +3546,8 @@ static u8 s_opcode_bytes[] = { #define READ16(X) read_u16_tick(e, X) #define WRITE8(X, V) write_u8_tick(e, X, V) #define WRITE16(X, V) write_u16_tick(e, X, V) -#define READ_N READ8(REG.PC + 1) -#define READ_NN READ16(REG.PC + 1) +#define READ_N (new_pc += 1, READ8(REG.PC)) +#define READ_NN (new_pc += 2, READ16(REG.PC)) #define READMR(MR) READ8(REG.MR) #define WRITEMR(MR, V) WRITE8(REG.MR, V) #define BASIC_OP_R(R, OP) u = REG.R; OP; REG.R = u @@ -3910,7 +3890,7 @@ static void execute_instruction(Emulator* e) { #define LD_R_OPS(code, R) REG_OPS_N(code, LD_R, R) HOOK(exec_op_ai, REG.PC, opcode); - new_pc = REG.PC + s_opcode_bytes[opcode]; + new_pc = ++REG.PC; switch (opcode) { case 0x00: break; @@ -4012,7 +3992,8 @@ static void execute_instruction(Emulator* e) { case 0xc9: RET; break; case 0xca: JP_F_NN(FZ); break; case 0xcb: { - u8 cb = read_u8_tick(e, REG.PC + 1); + new_pc += 1; + u8 cb = read_u8_tick(e, REG.PC); HOOK(exec_cb_op_i, cb); switch (cb) { REG_OPS(0x00, RLC)