sim: sim_moves: handle MOVSS, add unit tests

This commit is contained in:
Mikael Pettersson 2020-07-14 14:57:45 +02:00
parent bdc853f239
commit a3a0648567
3 changed files with 39 additions and 0 deletions

View File

@ -231,6 +231,7 @@ dispatch(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#207 -> sim_moves:handle_MOVSS(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

@ -32,6 +32,7 @@
, handle_MOVS/4
, handle_MOVSI/4
, handle_MOVSM/4
, handle_MOVSS/4
]).
-include("sim_core.hrl").
@ -146,6 +147,18 @@ handle_MOVSM(Core, Mem, IR, EA) ->
CA = sim_core:get_ac(Core, AC),
handle_MOVEM_1(Core, Mem, swap_halves(CA), EA).
-spec handle_MOVSS(#core{}, sim_mem:mem(), IR :: word(), #ea{})
-> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}.
handle_MOVSS(Core, Mem, IR, EA) ->
case sim_core:c(Core, Mem, EA) of
{ok, CE} ->
AC = IR band 8#17,
handle_MOVES(Core, Mem, AC, EA, swap_halves(CE));
{error, Reason} ->
sim_core:page_fault(Core, Mem, ea_address(EA), read, Reason,
fun(Core1, Mem1) -> handle_MOVSS(Core1, Mem1, IR, EA) end)
end.
%% Miscellaneous ===============================================================
ea_address(#ea{section = Section, offset = Offset}) ->

View File

@ -50,6 +50,7 @@
-define(OP_MOVS, 8#204).
-define(OP_MOVSI, 8#205).
-define(OP_MOVSM, 8#206).
-define(OP_MOVSS, 8#207).
-define(OP_EXCH, 8#250).
%% 2.1.1 Exchange Instruction ==================================================
@ -166,6 +167,30 @@ movsm_test() ->
[ {#ea{section = 1, offset = 8#150, islocal = false}, ?COMMA2(8#42, 0)} % C(1,,150) = 42,,0
]).
movss_ac_test() ->
Prog =
[ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 0)} % 1,,100/ MOVEI 1,0
, {1, 8#101, ?INSN(?OP_MOVSS, 1, 0, 0, 8#150)} % 1,,101/ MOVSS 1,150
, {1, 8#102, ?INSN_INVALID} % 1,,102/ <invalid>
, {1, 8#150, ?COMMA2(8#27, 8#42)} % 1,,150/ 27,,42
],
expect(Prog, [], {1, 8#102}, ?DEFAULT_FLAGS,
[ {#ea{section = 1, offset = 8#150, islocal = false}, ?COMMA2(8#42, 8#27)} % C(1,,150) = 42,,27
, {#ea{section = 1, offset = 1, islocal = false}, ?COMMA2(8#42, 8#27)} % AC1 = 42,,27
]).
movss_noac_test() ->
Prog =
[ {1, 8#100, ?INSN(?OP_MOVEI, 0, 0, 0, 0)} % 1,,100/ MOVEI 0,0
, {1, 8#101, ?INSN(?OP_MOVSS, 0, 0, 0, 8#150)} % 1,,101/ MOVSS 0,150
, {1, 8#102, ?INSN_INVALID} % 1,,102/ <invalid>
, {1, 8#150, ?COMMA2(8#27, 8#42)} % 1,,150/ 27,,42
],
expect(Prog, [], {1, 8#102}, ?DEFAULT_FLAGS,
[ {#ea{section = 1, offset = 8#150, islocal = false}, ?COMMA2(8#42, 8#27)} % C(1,,150) = 42,,27
, {#ea{section = 1, offset = 0, islocal = false}, 0} % AC0 = 0
]).
%% Common code to run short sequences ==========================================
expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->