sim: sim_boolean: handle ORCAM, add unit test

This commit is contained in:
Mikael Pettersson
2020-07-25 15:54:54 +02:00
parent 1a3633d336
commit c2e4ac4805
3 changed files with 28 additions and 0 deletions

View File

@@ -50,6 +50,7 @@
, handle_IORM/4
, handle_ORCA/4
, handle_ORCAI/4
, handle_ORCAM/4
, handle_SETCA/4
, handle_SETCAB/4
, handle_SETCAM/4
@@ -568,6 +569,20 @@ handle_ORCAI(Core, Mem, IR, EA) ->
Word = (EA#ea.offset bor bnot CA) band ((1 bsl 36) - 1),
sim_core:next_pc(sim_core:set_ac(Core, AC, Word), Mem).
-spec handle_ORCAM(#core{}, sim_mem:mem(), IR :: word(), #ea{})
-> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}.
handle_ORCAM(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 = (CE bor 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_ORCAM(Core1, Mem1, IR, EA) end)
end.
%% Miscellaneous ===============================================================
ea_address(#ea{section = Section, offset = Offset}) ->

View File

@@ -299,6 +299,7 @@ dispatch(Core, Mem, IR, EA) ->
8#453 -> sim_boolean:handle_SETCAB(Core, Mem, IR, EA);
8#454 -> sim_boolean:handle_ORCA(Core, Mem, IR, EA);
8#455 -> sim_boolean:handle_ORCAI(Core, Mem, IR, EA);
8#456 -> sim_boolean:handle_ORCAM(Core, Mem, IR, EA);
_ ->
PC = (Core#core.pc_section bsl 18) bor Core#core.pc_offset,
{Core, Mem, {error, {?MODULE, {dispatch, PC, IR, EA}}}}