diff --git a/erlang/apps/sim/src/sim_boolean.erl b/erlang/apps/sim/src/sim_boolean.erl index 54eb570..a441ae7 100644 --- a/erlang/apps/sim/src/sim_boolean.erl +++ b/erlang/apps/sim/src/sim_boolean.erl @@ -41,6 +41,7 @@ , handle_ANDI/4 , handle_ANDM/4 , handle_EQV/4 + , handle_EQVB/4 , handle_EQVI/4 , handle_EQVM/4 , handle_IOR/4 @@ -498,6 +499,20 @@ handle_EQVM(Core, Mem, IR, EA) -> fun(Core1, Mem1) -> handle_EQVM(Core1, Mem1, IR, EA) end) end. +-spec handle_EQVB(#core{}, sim_mem:mem(), IR :: word(), #ea{}) + -> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}. +handle_EQVB(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_ANDB(Core, Mem, AC, EA, Word); + {error, Reason} -> + sim_core:page_fault(Core, Mem, ea_address(EA), read, Reason, + fun(Core1, Mem1) -> handle_EQVB(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 03ba4fa..9f63d86 100644 --- a/erlang/apps/sim/src/sim_core.erl +++ b/erlang/apps/sim/src/sim_core.erl @@ -292,6 +292,7 @@ dispatch(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); + 8#447 -> sim_boolean:handle_EQVB(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 e7cd9a4..9e23bb2 100644 --- a/erlang/apps/sim/test/sim_boolean_tests.erl +++ b/erlang/apps/sim/test/sim_boolean_tests.erl @@ -83,6 +83,7 @@ -define(OP_EQV, 8#444). -define(OP_EQVI, 8#445). -define(OP_EQVM, 8#446). +-define(OP_EQVB, 8#447). %% 2.4 Boolean Functions ======================================================= @@ -561,6 +562,18 @@ eqvm_test() -> [ {#ea{section = 1, offset = 8#200, islocal = false}, ?COMMA2(-1, 8#343434)} % C(1,,200) = -1,,343434 ]). +eqvb_test() -> + Prog = + [ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 8#707070)} % 1,,100/ MOVEI 1,707070 + , {1, 8#101, ?INSN(?OP_EQVB, 1, 0, 0, 8#200)} % 1,,101/ EQVB 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 + , {#ea{section = 1, offset = 1, islocal = false}, ?COMMA2(-1, 8#343434)} % AC1 = -1,,343434 + ]). + %% Common code to run short sequences ========================================== expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->