mirror of
https://github.com/mikpe/pdp10-tools.git
synced 2026-01-23 02:49:07 +00:00
sim: sim_core: move handle_MOVEI/4 to sim_moves, add unit test
This commit is contained in:
parent
fc825e5556
commit
9ccb331bca
@ -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())
|
||||
|
||||
@ -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}) ->
|
||||
|
||||
@ -85,6 +85,17 @@ move_test() ->
|
||||
[ {#ea{section = 1, offset = 1, islocal = false}, 8#42} % AC1 = 42
|
||||
]).
|
||||
|
||||
movei_test() ->
|
||||
Prog =
|
||||
[ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 8#200)} % 1,,100/ MOVEI 1,200
|
||||
, {1, 8#101, ?INSN_INVALID} % 1,,101/ <invalid>
|
||||
],
|
||||
%% Note that the EA in 1,,100 evaluates to 1,,200 local, but only the
|
||||
%% in-section offset is loaded into AC1.
|
||||
expect(Prog, [], {1, 8#101}, ?DEFAULT_FLAGS,
|
||||
[ {#ea{section = 1, offset = 1, islocal = false}, 8#200} % AC1 = 200
|
||||
]).
|
||||
|
||||
%% Common code to run short sequences ==========================================
|
||||
|
||||
expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user