sim: sim_boolean: handle IORI, add unit test

This commit is contained in:
Mikael Pettersson
2020-07-24 19:37:46 +02:00
parent f2fd1ffde0
commit 2698bd1366
3 changed files with 21 additions and 0 deletions

View File

@@ -37,6 +37,7 @@
, handle_ANDI/4
, handle_ANDM/4
, handle_IOR/4
, handle_IORI/4
, handle_SETMB/4
, handle_SETMI/4
, handle_SETMM/4
@@ -362,6 +363,14 @@ handle_IOR(Core, Mem, IR, EA) ->
fun(Core1, Mem1) -> handle_IOR(Core1, Mem1, IR, EA) end)
end.
-spec handle_IORI(#core{}, sim_mem:mem(), IR :: word(), #ea{})
-> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}.
handle_IORI(Core, Mem, IR, EA) ->
AC = IR band 8#17,
CA = sim_core:get_ac(Core, AC),
Word = CA bor EA#ea.offset,
sim_core:next_pc(sim_core:set_ac(Core, AC, Word), Mem).
%% Miscellaneous ===============================================================
ea_address(#ea{section = Section, offset = Offset}) ->

View File

@@ -282,6 +282,7 @@ dispatch(Core, Mem, IR, EA) ->
8#432 -> sim_boolean:handle_XORM(Core, Mem, IR, EA);
8#433 -> sim_boolean:handle_XORB(Core, Mem, IR, EA);
8#434 -> sim_boolean:handle_IOR(Core, Mem, IR, EA);
8#435 -> sim_boolean:handle_IORI(Core, Mem, IR, EA);
_ ->
PC = (Core#core.pc_section bsl 18) bor Core#core.pc_offset,
{Core, Mem, {error, {?MODULE, {dispatch, PC, IR, EA}}}}

View File

@@ -73,6 +73,7 @@
-define(OP_XORM, 8#432).
-define(OP_XORB, 8#433).
-define(OP_IOR, 8#434).
-define(OP_IORI, 8#435).
%% 2.4 Boolean Functions =======================================================
@@ -438,6 +439,16 @@ ior_test() ->
[ {#ea{section = 1, offset = 1, islocal = false}, 8#777777} % AC1 = 0,,-1
]).
iori_test() ->
Prog =
[ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 8#707070)} % 1,,100/ MOVEI 1,707070
, {1, 8#101, ?INSN(?OP_IORI, 1, 0, 0, 8#070707)} % 1,,101/ IORI 1,070707
, {1, 8#102, ?INSN_INVALID} % 1,,102/ <invalid>
],
expect(Prog, [], {1, 8#102}, ?DEFAULT_FLAGS,
[ {#ea{section = 1, offset = 1, islocal = false}, 8#777777} % AC1 = 0,,-1
]).
%% Common code to run short sequences ==========================================
expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->