sim: sim_core: move handle_MOVEI/4 to sim_moves, add unit test

This commit is contained in:
Mikael Pettersson
2020-07-13 20:56:44 +02:00
parent fc825e5556
commit 9ccb331bca
3 changed files with 19 additions and 5 deletions

View File

@@ -225,17 +225,13 @@ dispatch(Core, Mem, IR, EA) ->
case IR bsr 4 of
8#104 -> sim_kernel:handle_JSYS(Core, Mem, IR, EA);
8#200 -> sim_moves:handle_MOVE(Core, Mem, IR, EA);
8#201 -> handle_MOVEI(Core, Mem, IR, EA);
8#201 -> sim_moves:handle_MOVEI(Core, Mem, IR, EA);
8#250 -> sim_moves:handle_EXCH(Core, Mem, IR, EA);
_ ->
PC = (Core#core.pc_section bsl 18) bor Core#core.pc_offset,
{Core, Mem, {error, {?MODULE, {dispatch, PC, IR, EA}}}}
end.
handle_MOVEI(Core, Mem, IR, #ea{offset = E}) ->
AC = IR band 8#17,
next_pc(set_ac(Core, AC, E), Mem).
%% Page Fault Handling =========================================================
-spec page_fault(#core{}, sim_mem:mem(), word(), atom(), term(), fun())

View File

@@ -26,6 +26,7 @@
-export([ handle_EXCH/4
, handle_MOVE/4
, handle_MOVEI/4
]).
-include("sim_core.hrl").
@@ -71,6 +72,12 @@ handle_MOVE(Core, Mem, IR, EA) ->
fun(Core1, Mem1) -> handle_MOVE(Core1, Mem1, IR, EA) end)
end.
-spec handle_MOVEI(#core{}, sim_mem:mem(), IR :: word(), #ea{})
-> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}.
handle_MOVEI(Core, Mem, IR, #ea{offset = E}) ->
AC = IR band 8#17,
sim_core:next_pc(sim_core:set_ac(Core, AC, E), Mem).
%% Miscellaneous ===============================================================
ea_address(#ea{section = Section, offset = Offset}) ->