diff --git a/erlang/apps/sim/src/sim_boolean.erl b/erlang/apps/sim/src/sim_boolean.erl index f926cb9..79afe7f 100644 --- a/erlang/apps/sim/src/sim_boolean.erl +++ b/erlang/apps/sim/src/sim_boolean.erl @@ -32,6 +32,7 @@ , handle_ANDCAM/4 , handle_ANDCM/4 , handle_ANDCMI/4 + , handle_ANDCMM/4 , handle_ANDI/4 , handle_ANDM/4 , handle_SETMB/4 @@ -259,6 +260,20 @@ handle_ANDCMI(Core, Mem, IR, EA) -> Word = CA band bnot EA#ea.offset, sim_core:next_pc(sim_core:set_ac(Core, AC, Word), Mem). +-spec handle_ANDCMM(#core{}, sim_mem:mem(), IR :: word(), #ea{}) + -> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}. +handle_ANDCMM(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 = CA band bnot CE, + handle_ANDM_1(Core, Mem, EA, Word); + {error, Reason} -> + sim_core:page_fault(Core, Mem, ea_address(EA), read, Reason, + fun(Core1, Mem1) -> handle_ANDCMM(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 097cd67..20512a4 100644 --- a/erlang/apps/sim/src/sim_core.erl +++ b/erlang/apps/sim/src/sim_core.erl @@ -271,6 +271,7 @@ dispatch(Core, Mem, IR, EA) -> 8#417 -> sim_boolean:handle_SETMB(Core, Mem, IR, EA); 8#420 -> sim_boolean:handle_ANDCM(Core, Mem, IR, EA); 8#421 -> sim_boolean:handle_ANDCMI(Core, Mem, IR, EA); + 8#422 -> sim_boolean:handle_ANDCMM(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 e7e3f49..618ef42 100644 --- a/erlang/apps/sim/test/sim_boolean_tests.erl +++ b/erlang/apps/sim/test/sim_boolean_tests.erl @@ -62,6 +62,7 @@ -define(OP_SETMB, 8#417). -define(OP_ANDCM, 8#420). -define(OP_ANDCMI, 8#421). +-define(OP_ANDCMM, 8#422). %% 2.4 Boolean Functions ======================================================= @@ -309,6 +310,17 @@ andcmi_test() -> [ {#ea{section = 1, offset = 1, islocal = false}, 8#030303} % AC1 = 0,,030303 ]). +andcmm_test() -> + Prog = + [ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 8#333333)} % 1,,100/ MOVEI 1,333333 + , {1, 8#101, ?INSN(?OP_ANDCMM, 1, 0, 0, 8#200)} % 1,,101/ ANDCMM 1,200 + , {1, 8#102, ?INSN_INVALID} % 1,,102/ + , {1, 8#200, ?COMMA2(0, 8#707070)} % 1,,200/ 0,,707070 + ], + expect(Prog, [], {1, 8#102}, ?DEFAULT_FLAGS, + [ {#ea{section = 1, offset = 8#200, islocal = false}, ?COMMA2(0, 8#030303)} % C(1,,200) = 0,,030303 + ]). + %% Common code to run short sequences ========================================== expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->