sim: sim_core: handle SETAM and SETAB as MOVEM, add unit tests

This commit is contained in:
Mikael Pettersson 2020-07-24 17:48:44 +02:00
parent 8f7e4d7210
commit a30384b185
2 changed files with 26 additions and 0 deletions

View File

@ -275,6 +275,8 @@ dispatch(Core, Mem, IR, EA) ->
8#423 -> sim_boolean:handle_ANDCMB(Core, Mem, IR, EA);
8#424 -> next_pc(Core, Mem); % SETA = no-op
8#425 -> next_pc(Core, Mem); % SETAI = no-op
8#426 -> sim_moves:handle_MOVEM(Core, Mem, IR, EA); % SETAM = MOVEM
8#427 -> sim_moves:handle_MOVEM(Core, Mem, IR, EA); % SETAB = MOVEM
_ ->
PC = (Core#core.pc_section bsl 18) bor Core#core.pc_offset,
{Core, Mem, {error, {?MODULE, {dispatch, PC, IR, EA}}}}

View File

@ -66,6 +66,8 @@
-define(OP_ANDCMB, 8#423).
-define(OP_SETA, 8#424).
-define(OP_SETAI, 8#425).
-define(OP_SETAM, 8#426).
-define(OP_SETAB, 8#426).
%% 2.4 Boolean Functions =======================================================
@ -350,6 +352,28 @@ setai_test() ->
],
expect(Prog, [], {1, 8#101}, ?DEFAULT_FLAGS, []).
setam_test() ->
Prog =
[ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 8#42)} % 1,,100/ MOVEI 1,42
, {1, 8#101, ?INSN(?OP_SETAM, 1, 0, 0, 8#150)} % 1,,101/ SETAM 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}, 8#42} % C(1,,150) = 42
]).
setab_test() ->
Prog =
[ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 8#42)} % 1,,100/ MOVEI 1,42
, {1, 8#101, ?INSN(?OP_SETAB, 1, 0, 0, 8#150)} % 1,,101/ SETAB 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}, 8#42} % C(1,,150) = 42
]).
%% Common code to run short sequences ==========================================
expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->