diff --git a/erlang/apps/sim/src/sim_boolean.erl b/erlang/apps/sim/src/sim_boolean.erl index fbb41b6..1314474 100644 --- a/erlang/apps/sim/src/sim_boolean.erl +++ b/erlang/apps/sim/src/sim_boolean.erl @@ -71,6 +71,7 @@ , handle_SETMI/4 , handle_SETMM/4 , handle_SETO/4 + , handle_SETOB/4 , handle_SETOM/4 , handle_SETZ/4 , handle_SETZB/4 @@ -778,6 +779,13 @@ handle_SETOM(Core, Mem, _IR, EA) -> Word = (1 bsl 36) - 1, handle_ANDM_1(Core, Mem, EA, Word). +-spec handle_SETOB(#core{}, sim_mem:mem(), IR :: word(), #ea{}) + -> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}. +handle_SETOB(Core, Mem, IR, EA) -> + AC = IR band 8#17, + Word = (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 a4efb01..490eb6f 100644 --- a/erlang/apps/sim/src/sim_core.erl +++ b/erlang/apps/sim/src/sim_core.erl @@ -316,6 +316,7 @@ dispatch(Core, Mem, IR, EA) -> 8#474 -> sim_boolean:handle_SETO(Core, Mem, IR, EA); 8#475 -> sim_boolean:handle_SETO(Core, Mem, IR, EA); % SETOI = SETO 8#476 -> sim_boolean:handle_SETOM(Core, Mem, IR, EA); + 8#477 -> sim_boolean:handle_SETOB(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 e3b1946..1db9bb0 100644 --- a/erlang/apps/sim/test/sim_boolean_tests.erl +++ b/erlang/apps/sim/test/sim_boolean_tests.erl @@ -107,6 +107,7 @@ -define(OP_SETO, 8#474). -define(OP_SETOI, 8#475). -define(OP_SETOM, 8#476). +-define(OP_SETOB, 8#477). %% 2.4 Boolean Functions ======================================================= @@ -852,6 +853,17 @@ setom_test() -> [ {#ea{section = 1, offset = 8#200, islocal = false}, ?COMMA2(-1, -1)} % C(1,,200) = -1,,-1 ]). +setob_test() -> + Prog = + [ {1, 8#100, ?INSN(?OP_SETOB, 1, 0, 0, 8#200)} % 1,,100/ SETOB 1,200 + , {1, 8#101, ?INSN_INVALID} % 1,,101/ + , {1, 8#200, 0} % 1,,200/ 0 + ], + expect(Prog, [], {1, 8#101}, ?DEFAULT_FLAGS, + [ {#ea{section = 1, offset = 8#200, islocal = false}, ?COMMA2(-1, -1)} % C(1,,200) = -1,,-1 + , {#ea{section = 1, offset = 1, islocal = false}, ?COMMA2(-1, -1)} % AC1 = -1,,-1 + ]). + %% Common code to run short sequences ========================================== expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->