From cc90c106a8d0b277749df0505d910903e05ceec6 Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Sat, 25 Jul 2020 15:03:12 +0200 Subject: [PATCH] sim: sim_core: handle SETCAI as SETCA, add unit tests --- erlang/apps/sim/src/sim_core.erl | 1 + erlang/apps/sim/test/sim_boolean_tests.erl | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/erlang/apps/sim/src/sim_core.erl b/erlang/apps/sim/src/sim_core.erl index 2aafadc..6577a50 100644 --- a/erlang/apps/sim/src/sim_core.erl +++ b/erlang/apps/sim/src/sim_core.erl @@ -294,6 +294,7 @@ dispatch(Core, Mem, IR, EA) -> 8#446 -> sim_boolean:handle_EQVM(Core, Mem, IR, EA); 8#447 -> sim_boolean:handle_EQVB(Core, Mem, IR, EA); 8#450 -> sim_boolean:handle_SETCA(Core, Mem, IR, EA); + 8#451 -> sim_boolean:handle_SETCA(Core, Mem, IR, EA); % SETCAI = SETCA _ -> PC = (Core#core.pc_section bsl 18) bor Core#core.pc_offset, {Core, Mem, {error, {?MODULE, {dispatch, PC, IR, EA}}}} diff --git a/erlang/apps/sim/test/sim_boolean_tests.erl b/erlang/apps/sim/test/sim_boolean_tests.erl index 1f59fa9..e95706b 100644 --- a/erlang/apps/sim/test/sim_boolean_tests.erl +++ b/erlang/apps/sim/test/sim_boolean_tests.erl @@ -85,6 +85,7 @@ -define(OP_EQVM, 8#446). -define(OP_EQVB, 8#447). -define(OP_SETCA, 8#450). +-define(OP_SETCAI, 8#451). %% 2.4 Boolean Functions ======================================================= @@ -587,6 +588,16 @@ setca_test() -> [ {#ea{section = 1, offset = 1, islocal = false}, ?COMMA2(-1, 8#070707)} % AC1 = -1,,070707 ]). +setcai_test() -> + Prog = + [ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 8#707070)} % 1,,100/ MOVEI 1,707070 + , {1, 8#101, ?INSN(?OP_SETCAI, 1, 0, 0, 0)} % 1,,101/ SETCAI 1, + , {1, 8#102, ?INSN_INVALID} % 1,,102/ + ], + expect(Prog, [], {1, 8#102}, ?DEFAULT_FLAGS, + [ {#ea{section = 1, offset = 1, islocal = false}, ?COMMA2(-1, 8#070707)} % AC1 = -1,,070707 + ]). + %% Common code to run short sequences ========================================== expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->