From 27816cc72a775c29cb469c0e934643e34c407956 Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Sat, 25 Jul 2020 17:52:15 +0200 Subject: [PATCH] sim: sim_boolean: handle ORCMM, add unit test --- erlang/apps/sim/src/sim_boolean.erl | 15 +++++++++++++++ erlang/apps/sim/src/sim_core.erl | 1 + erlang/apps/sim/test/sim_boolean_tests.erl | 12 ++++++++++++ 3 files changed, 28 insertions(+) diff --git a/erlang/apps/sim/src/sim_boolean.erl b/erlang/apps/sim/src/sim_boolean.erl index fe56fab..717ddc0 100644 --- a/erlang/apps/sim/src/sim_boolean.erl +++ b/erlang/apps/sim/src/sim_boolean.erl @@ -54,6 +54,7 @@ , handle_ORCAM/4 , handle_ORCM/4 , handle_ORCMI/4 + , handle_ORCMM/4 , handle_SETCA/4 , handle_SETCAB/4 , handle_SETCAM/4 @@ -675,6 +676,20 @@ handle_ORCMI(Core, Mem, IR, EA) -> Word = (CA bor bnot EA#ea.offset) band ((1 bsl 36) - 1), sim_core:next_pc(sim_core:set_ac(Core, AC, Word), Mem). +-spec handle_ORCMM(#core{}, sim_mem:mem(), IR :: word(), #ea{}) + -> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}. +handle_ORCMM(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 bor bnot CE) 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_ORCMM(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 f2e2e28..32ddcf4 100644 --- a/erlang/apps/sim/src/sim_core.erl +++ b/erlang/apps/sim/src/sim_core.erl @@ -307,6 +307,7 @@ dispatch(Core, Mem, IR, EA) -> 8#463 -> sim_boolean:handle_SETCMB(Core, Mem, IR, EA); 8#464 -> sim_boolean:handle_ORCM(Core, Mem, IR, EA); 8#465 -> sim_boolean:handle_ORCMI(Core, Mem, IR, EA); + 8#466 -> sim_boolean:handle_ORCMM(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 db319df..1346ede 100644 --- a/erlang/apps/sim/test/sim_boolean_tests.erl +++ b/erlang/apps/sim/test/sim_boolean_tests.erl @@ -98,6 +98,7 @@ -define(OP_SETCMB, 8#463). -define(OP_ORCM, 8#464). -define(OP_ORCMI, 8#465). +-define(OP_ORCMM, 8#466). %% 2.4 Boolean Functions ======================================================= @@ -744,6 +745,17 @@ orcmi_test() -> [ {#ea{section = 1, offset = 1, islocal = false}, ?COMMA2(-1, -1)} % AC1 = -1,,-1 ]). +orcmm_test() -> + Prog = + [ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 8#707070)} % 1,,100/ MOVEI 1,707070 + , {1, 8#101, ?INSN(?OP_ORCMM, 1, 0, 0, 8#200)} % 1,,101/ ORCMM 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(-1, -1)} % C(1,,200) = -1,,-1 + ]). + %% Common code to run short sequences ========================================== expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->