sim: sim_boolean: handle ORCBB, add unit test

This commit is contained in:
Mikael Pettersson 2020-07-25 19:20:21 +02:00
parent 5fa5dc8ab8
commit 9271adedab
3 changed files with 29 additions and 0 deletions

View File

@ -53,6 +53,7 @@
, handle_ORCAI/4
, handle_ORCAM/4
, handle_ORCB/4
, handle_ORCBB/4
, handle_ORCBI/4
, handle_ORCBM/4
, handle_ORCM/4
@ -746,6 +747,20 @@ handle_ORCBM(Core, Mem, IR, EA) ->
fun(Core1, Mem1) -> handle_ORCBM(Core1, Mem1, IR, EA) end)
end.
-spec handle_ORCBB(#core{}, sim_mem:mem(), IR :: word(), #ea{})
-> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}.
handle_ORCBB(Core, Mem, IR, EA) ->
case sim_core:c(Core, Mem, EA) of
{ok, CE} ->
AC = IR band 8#17,
CA = sim_core:get_ac(Core, AC),
Word = ((bnot CA) bor (bnot CE)) band ((1 bsl 36) - 1),
handle_ANDB(Core, Mem, AC, EA, Word);
{error, Reason} ->
sim_core:page_fault(Core, Mem, ea_address(EA), read, Reason,
fun(Core1, Mem1) -> handle_ORCBB(Core1, Mem1, IR, EA) end)
end.
%% Miscellaneous ===============================================================
ea_address(#ea{section = Section, offset = Offset}) ->

View File

@ -312,6 +312,7 @@ dispatch(Core, Mem, IR, EA) ->
8#470 -> sim_boolean:handle_ORCB(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);
_ ->
PC = (Core#core.pc_section bsl 18) bor Core#core.pc_offset,
{Core, Mem, {error, {?MODULE, {dispatch, PC, IR, EA}}}}

View File

@ -103,6 +103,7 @@
-define(OP_ORCB, 8#470).
-define(OP_ORCBI, 8#471).
-define(OP_ORCBM, 8#472).
-define(OP_ORCBB, 8#473).
%% 2.4 Boolean Functions =======================================================
@ -806,6 +807,18 @@ orcbm_test() ->
[ {#ea{section = 1, offset = 8#200, islocal = false}, ?COMMA2(-1, -1)} % C(1,,200) = -1,,-1
]).
orcbb_test() ->
Prog =
[ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 8#707070)} % 1,,100/ MOVEI 1,707070
, {1, 8#101, ?INSN(?OP_ORCBB, 1, 0, 0, 8#200)} % 1,,101/ ORCBB 1,200
, {1, 8#102, ?INSN_INVALID} % 1,,102/ <invalid>
, {1, 8#200, ?COMMA2(0, 8#070707)} % 1,,200/ 0,,070707
],
expect(Prog, [], {1, 8#102}, ?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) ->