diff --git a/erlang/apps/sim/src/sim_boolean.erl b/erlang/apps/sim/src/sim_boolean.erl index 2155aa2..94ec657 100644 --- a/erlang/apps/sim/src/sim_boolean.erl +++ b/erlang/apps/sim/src/sim_boolean.erl @@ -43,6 +43,7 @@ , handle_SETZB/4 , handle_SETZM/4 , handle_XOR/4 + , handle_XORI/4 ]). -include("sim_core.hrl"). @@ -306,6 +307,14 @@ handle_XOR(Core, Mem, IR, EA) -> fun(Core1, Mem1) -> handle_XOR(Core1, Mem1, IR, EA) end) end. +-spec handle_XORI(#core{}, sim_mem:mem(), IR :: word(), #ea{}) + -> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}. +handle_XORI(Core, Mem, IR, EA) -> + AC = IR band 8#17, + CA = sim_core:get_ac(Core, AC), + Word = CA bxor EA#ea.offset, + sim_core:next_pc(sim_core:set_ac(Core, AC, Word), Mem). + %% 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 e1c99d8..fc92978 100644 --- a/erlang/apps/sim/src/sim_core.erl +++ b/erlang/apps/sim/src/sim_core.erl @@ -278,6 +278,7 @@ dispatch(Core, Mem, IR, EA) -> 8#426 -> sim_moves:handle_MOVEM(Core, Mem, IR, EA); % SETAM = MOVEM 8#427 -> sim_moves:handle_MOVEM(Core, Mem, IR, EA); % SETAB = MOVEM 8#430 -> sim_boolean:handle_XOR(Core, Mem, IR, EA); + 8#431 -> sim_boolean:handle_XORI(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 591dca1..72febb4 100644 --- a/erlang/apps/sim/test/sim_boolean_tests.erl +++ b/erlang/apps/sim/test/sim_boolean_tests.erl @@ -69,6 +69,7 @@ -define(OP_SETAM, 8#426). -define(OP_SETAB, 8#426). -define(OP_XOR, 8#430). +-define(OP_XORI, 8#431). %% 2.4 Boolean Functions ======================================================= @@ -388,6 +389,16 @@ xor_test() -> [ {#ea{section = 1, offset = 1, islocal = false}, 8#434343} % AC1 = 0,,434343 ]). +xori_test() -> + Prog = + [ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 8#707070)} % 1,,100/ MOVEI 1,707070 + , {1, 8#101, ?INSN(?OP_XORI, 1, 0, 0, 8#333333)} % 1,,101/ XORI 1,333333 + , {1, 8#102, ?INSN_INVALID} % 1,,102/ + ], + expect(Prog, [], {1, 8#102}, ?DEFAULT_FLAGS, + [ {#ea{section = 1, offset = 1, islocal = false}, 8#434343} % AC1 = 0,,434343 + ]). + %% Common code to run short sequences ========================================== expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->