diff --git a/erlang/apps/sim/src/sim_boolean.erl b/erlang/apps/sim/src/sim_boolean.erl index 3af5ae5..b7e8493 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_SETCA/4 + , handle_SETCAB/4 , handle_SETCAM/4 , handle_SETMB/4 , handle_SETMI/4 @@ -533,6 +534,14 @@ handle_SETCAM(Core, Mem, IR, EA) -> Word = (bnot CA) band ((1 bsl 36) - 1), handle_ANDM_1(Core, Mem, EA, Word). +-spec handle_SETCAB(#core{}, sim_mem:mem(), IR :: word(), #ea{}) + -> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}. +handle_SETCAB(Core, Mem, IR, EA) -> + AC = IR band 8#17, + CA = sim_core:get_ac(Core, AC), + Word = (bnot CA) band ((1 bsl 36) - 1), + handle_ANDB(Core, Mem, AC, EA, Word). + %% 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 5812a96..07dd4cb 100644 --- a/erlang/apps/sim/src/sim_core.erl +++ b/erlang/apps/sim/src/sim_core.erl @@ -296,6 +296,7 @@ dispatch(Core, Mem, IR, EA) -> 8#450 -> sim_boolean:handle_SETCA(Core, Mem, IR, EA); 8#451 -> sim_boolean:handle_SETCA(Core, Mem, IR, EA); % SETCAI = SETCA 8#452 -> sim_boolean:handle_SETCAM(Core, Mem, IR, EA); + 8#453 -> sim_boolean:handle_SETCAB(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 ecb11a3..a39d838 100644 --- a/erlang/apps/sim/test/sim_boolean_tests.erl +++ b/erlang/apps/sim/test/sim_boolean_tests.erl @@ -87,6 +87,7 @@ -define(OP_SETCA, 8#450). -define(OP_SETCAI, 8#451). -define(OP_SETCAM, 8#452). +-define(OP_SETCAB, 8#453). %% 2.4 Boolean Functions ======================================================= @@ -610,6 +611,18 @@ setcam_test() -> [ {#ea{section = 1, offset = 8#200, islocal = false}, ?COMMA2(-1, 8#070707)} % C(1,,200) = -1,,070707 ]). +setcab_test() -> + Prog = + [ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 8#707070)} % 1,,100/ MOVEI 1,707070 + , {1, 8#101, ?INSN(?OP_SETCAB, 1, 0, 0, 8#200)} % 1,,101/ SETCAB 1,200 + , {1, 8#102, ?INSN_INVALID} % 1,,102/ + , {1, 8#200, 0} % 1,,200/ 0 + ], + expect(Prog, [], {1, 8#102}, ?DEFAULT_FLAGS, + [ {#ea{section = 1, offset = 8#200, islocal = false}, ?COMMA2(-1, 8#070707)} % C(1,,200) = -1,,070707 + , {#ea{section = 1, offset = 8#200, islocal = false}, ?COMMA2(-1, 8#070707)} % C(1,,200) = -1,,070707 + ]). + %% Common code to run short sequences ========================================== expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->