mirror of
https://github.com/mikpe/pdp10-tools.git
synced 2026-01-24 11:22:52 +00:00
sim: sim_moves: handle MOVS, add unit test
This commit is contained in:
parent
01bd93b3c3
commit
3b96e2333c
@ -228,6 +228,7 @@ dispatch(Core, Mem, IR, EA) ->
|
||||
8#201 -> sim_moves:handle_MOVEI(Core, Mem, IR, EA);
|
||||
8#202 -> sim_moves:handle_MOVEM(Core, Mem, IR, EA);
|
||||
8#203 -> sim_moves:handle_MOVES(Core, Mem, IR, EA);
|
||||
8#204 -> sim_moves:handle_MOVS(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,
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
, handle_MOVEI/4
|
||||
, handle_MOVEM/4
|
||||
, handle_MOVES/4
|
||||
, handle_MOVS/4
|
||||
]).
|
||||
|
||||
-include("sim_core.hrl").
|
||||
@ -115,6 +116,21 @@ handle_MOVES(Core, Mem, AC, EA, Word) ->
|
||||
fun(Core1, Mem1) -> handle_MOVES(Core1, Mem1, AC, EA, Word) end)
|
||||
end.
|
||||
|
||||
%% MOVS - Move Swapped
|
||||
|
||||
-spec handle_MOVS(#core{}, sim_mem:mem(), IR :: word(), #ea{})
|
||||
-> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}.
|
||||
handle_MOVS(Core, Mem, IR, EA) ->
|
||||
case sim_core:c(Core, Mem, EA) of
|
||||
{ok, CE} ->
|
||||
Swapped = swap_halves(CE),
|
||||
AC = IR band 8#17,
|
||||
sim_core:next_pc(sim_core:set_ac(Core, AC, Swapped), Mem);
|
||||
{error, Reason} ->
|
||||
sim_core:page_fault(Core, Mem, ea_address(EA), read, Reason,
|
||||
fun(Core1, Mem1) -> handle_MOVS(Core1, Mem1, IR, EA) end)
|
||||
end.
|
||||
|
||||
%% Miscellaneous ===============================================================
|
||||
|
||||
ea_address(#ea{section = Section, offset = Offset}) ->
|
||||
@ -122,3 +138,7 @@ ea_address(#ea{section = Section, offset = Offset}) ->
|
||||
|
||||
set_non_zero_ac(Core, _AC = 0, _Word) -> Core;
|
||||
set_non_zero_ac(Core, AC, Word) -> sim_core:set_ac(Core, AC, Word).
|
||||
|
||||
swap_halves(Word) ->
|
||||
Low18Mask = ((1 bsl 18) - 1),
|
||||
((Word band Low18Mask) bsl 18) bor ((Word bsr 18) band Low18Mask).
|
||||
|
||||
@ -47,6 +47,7 @@
|
||||
-define(OP_MOVEI, 8#201).
|
||||
-define(OP_MOVEM, 8#202).
|
||||
-define(OP_MOVES, 8#203).
|
||||
-define(OP_MOVS, 8#204).
|
||||
-define(OP_EXCH, 8#250).
|
||||
|
||||
%% 2.1.1 Exchange Instruction ==================================================
|
||||
@ -133,6 +134,16 @@ moves_noac_test() ->
|
||||
, {#ea{section = 1, offset = 0, islocal = false}, 8#27} % AC0 = 27
|
||||
]).
|
||||
|
||||
movs_test() ->
|
||||
Prog =
|
||||
[ {1, 8#100, ?INSN(?OP_MOVS, 1, 0, 0, 8#150)} % 1,,100/ MOVS 1,150
|
||||
, {1, 8#101, ?INSN_INVALID} % 1,,101/ <invalid>
|
||||
, {1, 8#150, ?COMMA2(8#27, 8#42)} % 1,,150/ 27,,42
|
||||
],
|
||||
expect(Prog, [], {1, 8#101}, ?DEFAULT_FLAGS,
|
||||
[ {#ea{section = 1, offset = 1, islocal = false}, ?COMMA2(8#42, 8#27)} % AC1 = 42,,27
|
||||
]).
|
||||
|
||||
%% Common code to run short sequences ==========================================
|
||||
|
||||
expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user