mirror of
https://github.com/mikpe/pdp10-tools.git
synced 2026-01-23 02:49:07 +00:00
sim: sim_boolean: handle SETMM, add unit test
This commit is contained in:
parent
40c36a5f6e
commit
45c852e4fe
@ -33,6 +33,7 @@
|
||||
, handle_ANDI/4
|
||||
, handle_ANDM/4
|
||||
, handle_SETMI/4
|
||||
, handle_SETMM/4
|
||||
, handle_SETZ/4
|
||||
, handle_SETZB/4
|
||||
, handle_SETZM/4
|
||||
@ -206,6 +207,18 @@ handle_SETMI(Core, Mem, IR, #ea{section = Section0, offset = Offset, islocal = I
|
||||
Word = (Section1 bsl 18) bor Offset,
|
||||
sim_core:next_pc(sim_core:set_ac(Core, AC, Word), Mem).
|
||||
|
||||
-spec handle_SETMM(#core{}, sim_mem:mem(), IR :: word(), #ea{})
|
||||
-> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}.
|
||||
handle_SETMM(Core, Mem, IR, EA) ->
|
||||
%% SETMM only checks that E is readable and writable.
|
||||
case sim_core:c(Core, Mem, EA) of
|
||||
{ok, CE} ->
|
||||
handle_ANDM_1(Core, Mem, EA, CE);
|
||||
{error, Reason} ->
|
||||
sim_core:page_fault(Core, Mem, ea_address(EA), read, Reason,
|
||||
fun(Core1, Mem1) -> handle_SETMM(Core1, Mem1, IR, EA) end)
|
||||
end.
|
||||
|
||||
%% Miscellaneous ===============================================================
|
||||
|
||||
ea_address(#ea{section = Section, offset = Offset}) ->
|
||||
|
||||
@ -267,6 +267,7 @@ dispatch(Core, Mem, IR, EA) ->
|
||||
8#413 -> sim_boolean:handle_ANDCAB(Core, Mem, IR, EA);
|
||||
8#414 -> sim_moves:handle_MOVE(Core, Mem, IR, EA); % SETM = MOVE
|
||||
8#415 -> sim_boolean:handle_SETMI(Core, Mem, IR, EA); % SETMI = MOVEI in section 0, XMOVEI elsewhere
|
||||
8#416 -> sim_boolean:handle_SETMM(Core, Mem, IR, EA);
|
||||
_ ->
|
||||
PC = (Core#core.pc_section bsl 18) bor Core#core.pc_offset,
|
||||
{Core, Mem, {error, {?MODULE, {dispatch, PC, IR, EA}}}}
|
||||
|
||||
@ -58,6 +58,7 @@
|
||||
-define(OP_SETM, 8#414).
|
||||
-define(OP_SETMI, 8#415).
|
||||
-define(OP_XMOVEI, ?OP_SETMI).
|
||||
-define(OP_SETMM, 8#416).
|
||||
|
||||
%% 2.4 Boolean Functions =======================================================
|
||||
|
||||
@ -258,6 +259,18 @@ xmovei_non_ac_test() ->
|
||||
[ {#ea{section = 1, offset = 1, islocal = false}, ?COMMA2(2, 8#42)} % AC1 = 2,,42
|
||||
]).
|
||||
|
||||
setmm_test() ->
|
||||
Prog =
|
||||
[ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 3)} % 1,,100/ MOVEI 1,3
|
||||
, {1, 8#101, ?INSN(?OP_SETMM, 1, 0, 0, 8#200)} % 1,,101/ SETMM 1,200
|
||||
, {1, 8#102, ?INSN_INVALID} % 1,,102/ <invalid>
|
||||
, {1, 8#200, ?COMMA2(1, 2)} % 1,,200/ 1,,2
|
||||
],
|
||||
expect(Prog, [], {1, 8#102}, ?DEFAULT_FLAGS,
|
||||
[ {#ea{section = 1, offset = 8#200, islocal = false}, ?COMMA2(1, 2)} % C(1,,200) = 1,,2
|
||||
, {#ea{section = 1, offset = 1, islocal = false}, 3}
|
||||
]).
|
||||
|
||||
%% Common code to run short sequences ==========================================
|
||||
|
||||
expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user