sim: sim_moves: handle MOVSM, add unit test

This commit is contained in:
Mikael Pettersson 2020-07-14 14:19:57 +02:00
parent 6561814cd8
commit bdc853f239
3 changed files with 21 additions and 0 deletions

View File

@ -230,6 +230,7 @@ dispatch(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#205 -> sim_moves:handle_MOVSI(Core, Mem, IR, EA);
8#206 -> sim_moves:handle_MOVSM(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,

View File

@ -31,6 +31,7 @@
, handle_MOVES/4
, handle_MOVS/4
, handle_MOVSI/4
, handle_MOVSM/4
]).
-include("sim_core.hrl").
@ -138,6 +139,13 @@ handle_MOVSI(Core, Mem, IR, #ea{offset = E}) ->
AC = IR band 8#17,
sim_core:next_pc(sim_core:set_ac(Core, AC, E bsl 18), Mem).
-spec handle_MOVSM(#core{}, sim_mem:mem(), IR :: word(), #ea{})
-> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}.
handle_MOVSM(Core, Mem, IR, EA) ->
AC = IR band 8#17,
CA = sim_core:get_ac(Core, AC),
handle_MOVEM_1(Core, Mem, swap_halves(CA), EA).
%% Miscellaneous ===============================================================
ea_address(#ea{section = Section, offset = Offset}) ->

View File

@ -49,6 +49,7 @@
-define(OP_MOVES, 8#203).
-define(OP_MOVS, 8#204).
-define(OP_MOVSI, 8#205).
-define(OP_MOVSM, 8#206).
-define(OP_EXCH, 8#250).
%% 2.1.1 Exchange Instruction ==================================================
@ -154,6 +155,17 @@ movsi_test() ->
[ {#ea{section = 1, offset = 1, islocal = false}, ?COMMA2(-1, 0)} % AC1 = -1,,0
]).
movsm_test() ->
Prog =
[ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 8#42)} % 1,,100/ MOVEI 1,42
, {1, 8#101, ?INSN(?OP_MOVSM, 1, 0, 0, 8#150)} % 1,,101/ MOVSM 1,150
, {1, 8#102, ?INSN_INVALID} % 1,,102/ <invalid>
, {1, 8#150, 8#27} % 1,,150/ 0,,27
],
expect(Prog, [], {1, 8#102}, ?DEFAULT_FLAGS,
[ {#ea{section = 1, offset = 8#150, islocal = false}, ?COMMA2(8#42, 0)} % C(1,,150) = 42,,0
]).
%% Common code to run short sequences ==========================================
expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->