diff --git a/erlang/apps/sim/src/sim_boolean.erl b/erlang/apps/sim/src/sim_boolean.erl index b19d4f0..5cc49c1 100644 --- a/erlang/apps/sim/src/sim_boolean.erl +++ b/erlang/apps/sim/src/sim_boolean.erl @@ -49,6 +49,7 @@ , handle_IORI/4 , handle_IORM/4 , handle_ORCA/4 + , handle_ORCAI/4 , handle_SETCA/4 , handle_SETCAB/4 , handle_SETCAM/4 @@ -559,6 +560,14 @@ handle_ORCA(Core, Mem, IR, EA) -> fun(Core1, Mem1) -> handle_ORCA(Core1, Mem1, IR, EA) end) end. +-spec handle_ORCAI(#core{}, sim_mem:mem(), IR :: word(), #ea{}) + -> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}. +handle_ORCAI(Core, Mem, IR, EA) -> + AC = IR band 8#17, + CA = sim_core:get_ac(Core, AC), + Word = (EA#ea.offset bor bnot CA) band ((1 bsl 36) - 1), + 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 39fc875..384438c 100644 --- a/erlang/apps/sim/src/sim_core.erl +++ b/erlang/apps/sim/src/sim_core.erl @@ -298,6 +298,7 @@ dispatch(Core, Mem, IR, EA) -> 8#452 -> sim_boolean:handle_SETCAM(Core, Mem, IR, EA); 8#453 -> sim_boolean:handle_SETCAB(Core, Mem, IR, EA); 8#454 -> sim_boolean:handle_ORCA(Core, Mem, IR, EA); + 8#455 -> sim_boolean:handle_ORCAI(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 075dff8..c611f6c 100644 --- a/erlang/apps/sim/test/sim_boolean_tests.erl +++ b/erlang/apps/sim/test/sim_boolean_tests.erl @@ -89,6 +89,7 @@ -define(OP_SETCAM, 8#452). -define(OP_SETCAB, 8#453). -define(OP_ORCA, 8#454). +-define(OP_ORCAI, 8#455). %% 2.4 Boolean Functions ======================================================= @@ -637,6 +638,16 @@ orca_test() -> [ {#ea{section = 1, offset = 1, islocal = false}, ?COMMA2(-1, 8#373737)} % AC1 = -1,,373737 ]). +orcai_test() -> + Prog = + [ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 8#707070)} % 1,,100/ MOVEI 1,707070 + , {1, 8#101, ?INSN(?OP_ORCAI, 1, 0, 0, 8#303030)} % 1,,101/ ORCAI 1,303030 + , {1, 8#102, ?INSN_INVALID} % 1,,102/ + ], + expect(Prog, [], {1, 8#102}, ?DEFAULT_FLAGS, + [ {#ea{section = 1, offset = 1, islocal = false}, ?COMMA2(-1, 8#373737)} % AC1 = -1,,373737 + ]). + %% Common code to run short sequences ========================================== expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->