diff --git a/erlang/apps/sim/src/sim_boolean.erl b/erlang/apps/sim/src/sim_boolean.erl index 47e1799..54eb570 100644 --- a/erlang/apps/sim/src/sim_boolean.erl +++ b/erlang/apps/sim/src/sim_boolean.erl @@ -42,6 +42,7 @@ , handle_ANDM/4 , handle_EQV/4 , handle_EQVI/4 + , handle_EQVM/4 , handle_IOR/4 , handle_IORB/4 , handle_IORI/4 @@ -483,6 +484,20 @@ handle_EQVI(Core, Mem, IR, EA) -> Word = (bnot (CA bxor EA#ea.offset)) band ((1 bsl 36) - 1), sim_core:next_pc(sim_core:set_ac(Core, AC, Word), Mem). +-spec handle_EQVM(#core{}, sim_mem:mem(), IR :: word(), #ea{}) + -> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}. +handle_EQVM(Core, Mem, IR, EA) -> + case sim_core:c(Core, Mem, EA) of + {ok, CE} -> + AC = IR band 8#17, + CA = sim_core:get_ac(Core, AC), + Word = (bnot (CE bxor CA)) band ((1 bsl 36) - 1), + handle_ANDM_1(Core, Mem, EA, Word); + {error, Reason} -> + sim_core:page_fault(Core, Mem, ea_address(EA), read, Reason, + fun(Core1, Mem1) -> handle_EQVM(Core1, Mem1, IR, EA) end) + end. + %% Miscellaneous =============================================================== ea_address(#ea{section = Section, offset = Offset}) -> diff --git a/erlang/apps/sim/src/sim_core.erl b/erlang/apps/sim/src/sim_core.erl index ade3ccd..03ba4fa 100644 --- a/erlang/apps/sim/src/sim_core.erl +++ b/erlang/apps/sim/src/sim_core.erl @@ -291,6 +291,7 @@ dispatch(Core, Mem, IR, EA) -> 8#443 -> sim_boolean:handle_ANDCBB(Core, Mem, IR, EA); 8#444 -> sim_boolean:handle_EQV(Core, Mem, IR, EA); 8#445 -> sim_boolean:handle_EQVI(Core, Mem, IR, EA); + 8#446 -> sim_boolean:handle_EQVM(Core, Mem, IR, EA); _ -> 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 a8fb096..e7cd9a4 100644 --- a/erlang/apps/sim/test/sim_boolean_tests.erl +++ b/erlang/apps/sim/test/sim_boolean_tests.erl @@ -82,6 +82,7 @@ -define(OP_ANDCBB, 8#443). -define(OP_EQV, 8#444). -define(OP_EQVI, 8#445). +-define(OP_EQVM, 8#446). %% 2.4 Boolean Functions ======================================================= @@ -549,6 +550,17 @@ eqvi_test() -> [ {#ea{section = 1, offset = 1, islocal = false}, ?COMMA2(-1, 8#343434)} % AC1 = -1,,343434 ]). +eqvm_test() -> + Prog = + [ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 8#707070)} % 1,,100/ MOVEI 1,707070 + , {1, 8#101, ?INSN(?OP_EQVM, 1, 0, 0, 8#200)} % 1,,101/ EQVM 1,200 + , {1, 8#102, ?INSN_INVALID} % 1,,102/ + , {1, 8#200, ?COMMA2(0, 8#333333)} % 1,,200/ 0,,333333 + ], + expect(Prog, [], {1, 8#102}, ?DEFAULT_FLAGS, + [ {#ea{section = 1, offset = 8#200, islocal = false}, ?COMMA2(-1, 8#343434)} % C(1,,200) = -1,,343434 + ]). + %% Common code to run short sequences ========================================== expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->