mirror of
https://github.com/mikpe/pdp10-tools.git
synced 2026-01-23 10:59:42 +00:00
sim: sim_moves: handle MOVNS, add unit tests
This commit is contained in:
parent
d06ab5c614
commit
eb95bfd514
@ -242,6 +242,7 @@ dispatch(Core, Mem, IR, EA) ->
|
||||
8#210 -> sim_moves:handle_MOVN(Core, Mem, IR, EA);
|
||||
8#211 -> sim_moves:handle_MOVNI(Core, Mem, IR, EA);
|
||||
8#212 -> sim_moves:handle_MOVNM(Core, Mem, IR, EA);
|
||||
8#213 -> sim_moves:handle_MOVNS(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,
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
, handle_MOVN/4
|
||||
, handle_MOVNI/4
|
||||
, handle_MOVNM/4
|
||||
, handle_MOVNS/4
|
||||
, handle_MOVS/4
|
||||
, handle_MOVSI/4
|
||||
, handle_MOVSM/4
|
||||
@ -205,6 +206,31 @@ handle_MOVNM(Core, Mem, Word, Flags, EA) ->
|
||||
fun(Core1, Mem1) -> handle_MOVNM(Core1, Mem1, Word, Flags, EA) end)
|
||||
end.
|
||||
|
||||
-spec handle_MOVNS(#core{}, sim_mem:mem(), IR :: word(), #ea{})
|
||||
-> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}.
|
||||
handle_MOVNS(Core, Mem, IR, EA) ->
|
||||
case sim_core:c(Core, Mem, EA) of
|
||||
{ok, CE} ->
|
||||
AC = IR band 8#17,
|
||||
{Negated, Flags} = negate(CE),
|
||||
handle_MOVNS(Core, Mem, AC, EA, Negated, Flags);
|
||||
{error, Reason} ->
|
||||
sim_core:page_fault(Core, Mem, ea_address(EA), read, Reason,
|
||||
fun(Core1, Mem1) -> handle_MOVNS(Core1, Mem1, IR, EA) end)
|
||||
end.
|
||||
|
||||
handle_MOVNS(Core, Mem, AC, EA, Word, Flags) ->
|
||||
%% See handle_MOVNM/5 for ordering requirements.
|
||||
case sim_core:cset(Core, Mem, EA, Word) of
|
||||
{ok, Core1} ->
|
||||
Core2 = set_non_zero_ac(Core1, AC, Word),
|
||||
Core3 = sim_core:set_flags(Core2, Flags),
|
||||
sim_core:next_pc(Core3, Mem);
|
||||
{error, Reason} ->
|
||||
sim_core:page_fault(Core, Mem, ea_address(EA), write, Reason,
|
||||
fun(Core1, Mem1) -> handle_MOVNS(Core1, Mem1, AC, EA, Word, Flags) end)
|
||||
end.
|
||||
|
||||
%% Miscellaneous ===============================================================
|
||||
|
||||
ea_address(#ea{section = Section, offset = Offset}) ->
|
||||
|
||||
@ -54,6 +54,7 @@
|
||||
-define(OP_MOVN, 8#210).
|
||||
-define(OP_MOVNI, 8#211).
|
||||
-define(OP_MOVNM, 8#212).
|
||||
-define(OP_MOVNS, 8#213).
|
||||
-define(OP_EXCH, 8#250).
|
||||
|
||||
%% 2.1.1 Exchange Instruction ==================================================
|
||||
@ -246,6 +247,30 @@ movnm_test() ->
|
||||
[ {#ea{section = 1, offset = 8#150, islocal = false}, (-8#42) band ((1 bsl 36) - 1)} % C(1,,150) = -42
|
||||
]).
|
||||
|
||||
movns_ac_test() ->
|
||||
Prog =
|
||||
[ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 0)} % 1,,100/ MOVEI 1,0
|
||||
, {1, 8#101, ?INSN(?OP_MOVNS, 1, 0, 0, 8#150)} % 1,,101/ MOVNS 1,150
|
||||
, {1, 8#102, ?INSN_INVALID} % 1,,102/ <invalid>
|
||||
, {1, 8#150, 8#42} % 1,,150/ 0,,42
|
||||
],
|
||||
expect(Prog, [], {1, 8#102}, ?DEFAULT_FLAGS,
|
||||
[ {#ea{section = 1, offset = 8#150, islocal = false}, (-8#42) band ((1 bsl 36) - 1)} % C(1,,150) = -42
|
||||
, {#ea{section = 1, offset = 1, islocal = false}, (-8#42) band ((1 bsl 36) - 1)} % AC1 = -42
|
||||
]).
|
||||
|
||||
movns_noac_test() ->
|
||||
Prog =
|
||||
[ {1, 8#100, ?INSN(?OP_MOVEI, 0, 0, 0, 0)} % 1,,100/ MOVEI 0,0
|
||||
, {1, 8#101, ?INSN(?OP_MOVNS, 0, 0, 0, 8#150)} % 1,,101/ MOVNS 0,150
|
||||
, {1, 8#102, ?INSN_INVALID} % 1,,102/ <invalid>
|
||||
, {1, 8#150, 8#42} % 1,,150/ 0,,42
|
||||
],
|
||||
expect(Prog, [], {1, 8#102}, ?DEFAULT_FLAGS,
|
||||
[ {#ea{section = 1, offset = 8#150, islocal = false}, (-8#42) band ((1 bsl 36) - 1)} % C(1,,150) = -42
|
||||
, {#ea{section = 1, offset = 0, islocal = false}, 0} % AC0 = 0
|
||||
]).
|
||||
|
||||
%% Common code to run short sequences ==========================================
|
||||
|
||||
expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user