sim: sim_boolean: handle ANDCBM, add unit test

This commit is contained in:
Mikael Pettersson
2020-07-24 23:11:37 +02:00
parent df0474f9c1
commit ad9cc52502
3 changed files with 28 additions and 0 deletions

View File

@@ -32,6 +32,7 @@
, handle_ANDCAM/4
, handle_ANDCB/4
, handle_ANDCBI/4
, handle_ANDCBM/4
, handle_ANDCM/4
, handle_ANDCMB/4
, handle_ANDCMI/4
@@ -427,6 +428,20 @@ handle_ANDCBI(Core, Mem, IR, EA) ->
Word = ((bnot CA) band (bnot EA#ea.offset)) band ((1 bsl 36) - 1),
sim_core:next_pc(sim_core:set_ac(Core, AC, Word), Mem).
-spec handle_ANDCBM(#core{}, sim_mem:mem(), IR :: word(), #ea{})
-> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}.
handle_ANDCBM(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 CE) band (bnot CA)) band ((1 bsl 36) - 1),
handle_ANDM_1(Core, Mem, EA, Word);
{error, Reason} ->
sim_core:page_fault(Core, Mem, ea_address(EA), read, Reason,
fun(Core1, Mem1) -> handle_ANDCBM(Core1, Mem1, IR, EA) end)
end.
%% Miscellaneous ===============================================================
ea_address(#ea{section = Section, offset = Offset}) ->

View File

@@ -287,6 +287,7 @@ dispatch(Core, Mem, IR, EA) ->
8#437 -> sim_boolean:handle_IORB(Core, Mem, IR, EA);
8#440 -> sim_boolean:handle_ANDCB(Core, Mem, IR, EA);
8#441 -> sim_boolean:handle_ANDCBI(Core, Mem, IR, EA);
8#442 -> sim_boolean:handle_ANDCBM(Core, Mem, IR, EA);
_ ->
PC = (Core#core.pc_section bsl 18) bor Core#core.pc_offset,
{Core, Mem, {error, {?MODULE, {dispatch, PC, IR, EA}}}}