From 4a0b920c9d26cbbb9732955c36e04e277260ca82 Mon Sep 17 00:00:00 2001 From: Mikael Pettersson Date: Sat, 25 Jul 2020 19:26:12 +0200 Subject: [PATCH] sim: sim_boolean: handle SETO, add unit test --- erlang/apps/sim/src/sim_boolean.erl | 10 ++++++++++ erlang/apps/sim/src/sim_core.erl | 1 + erlang/apps/sim/test/sim_boolean_tests.erl | 12 ++++++++++++ 3 files changed, 23 insertions(+) diff --git a/erlang/apps/sim/src/sim_boolean.erl b/erlang/apps/sim/src/sim_boolean.erl index 829da8c..6be587f 100644 --- a/erlang/apps/sim/src/sim_boolean.erl +++ b/erlang/apps/sim/src/sim_boolean.erl @@ -70,6 +70,7 @@ , handle_SETMB/4 , handle_SETMI/4 , handle_SETMM/4 + , handle_SETO/4 , handle_SETZ/4 , handle_SETZB/4 , handle_SETZM/4 @@ -761,6 +762,15 @@ handle_ORCBB(Core, Mem, IR, EA) -> fun(Core1, Mem1) -> handle_ORCBB(Core1, Mem1, IR, EA) end) end. +%% SETO - Set to Ones + +-spec handle_SETO(#core{}, sim_mem:mem(), IR :: word(), #ea{}) + -> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}. +handle_SETO(Core, Mem, IR, _EA) -> + AC = IR band 8#17, + Word = (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 1b05c62..cab0488 100644 --- a/erlang/apps/sim/src/sim_core.erl +++ b/erlang/apps/sim/src/sim_core.erl @@ -313,6 +313,7 @@ dispatch(Core, Mem, IR, EA) -> 8#471 -> sim_boolean:handle_ORCBI(Core, Mem, IR, EA); 8#472 -> sim_boolean:handle_ORCBM(Core, Mem, IR, EA); 8#473 -> sim_boolean:handle_ORCBB(Core, Mem, IR, EA); + 8#474 -> sim_boolean:handle_SETO(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 6d4fe16..6e9fef1 100644 --- a/erlang/apps/sim/test/sim_boolean_tests.erl +++ b/erlang/apps/sim/test/sim_boolean_tests.erl @@ -104,6 +104,7 @@ -define(OP_ORCBI, 8#471). -define(OP_ORCBM, 8#472). -define(OP_ORCBB, 8#473). +-define(OP_SETO, 8#474). %% 2.4 Boolean Functions ======================================================= @@ -819,6 +820,17 @@ orcbb_test() -> , {#ea{section = 1, offset = 1, islocal = false}, ?COMMA2(-1, -1)} % AC1 = -1,,-1 ]). +%% SETO - Set to Ones + +seto_test() -> + Prog = + [ {1, 8#100, ?INSN(?OP_SETO, 1, 0, 0, 0)} % 1,,100/ SETO 1, + , {1, 8#101, ?INSN_INVALID} % 1,,101/ + ], + expect(Prog, [], {1, 8#101}, ?DEFAULT_FLAGS, + [ {#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) ->