mirror of
https://github.com/mikpe/pdp10-tools.git
synced 2026-01-22 18:42:34 +00:00
sim: sim_boolean: handle XORM, add unit test
This commit is contained in:
parent
84a0e9b226
commit
579a7aee5b
@ -44,6 +44,7 @@
|
||||
, handle_SETZM/4
|
||||
, handle_XOR/4
|
||||
, handle_XORI/4
|
||||
, handle_XORM/4
|
||||
]).
|
||||
|
||||
-include("sim_core.hrl").
|
||||
@ -315,6 +316,20 @@ handle_XORI(Core, Mem, IR, EA) ->
|
||||
Word = CA bxor EA#ea.offset,
|
||||
sim_core:next_pc(sim_core:set_ac(Core, AC, Word), Mem).
|
||||
|
||||
-spec handle_XORM(#core{}, sim_mem:mem(), IR :: word(), #ea{})
|
||||
-> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}.
|
||||
handle_XORM(Core, Mem, IR, EA) ->
|
||||
case sim_core:c(Core, Mem, EA) of
|
||||
{ok, CE} ->
|
||||
AC = IR band 8#17,
|
||||
CA = sim_core:get_ac(Core, AC),
|
||||
Word = CE bxor CA,
|
||||
handle_ANDM_1(Core, Mem, EA, Word);
|
||||
{error, Reason} ->
|
||||
sim_core:page_fault(Core, Mem, ea_address(EA), read, Reason,
|
||||
fun(Core1, Mem1) -> handle_XORM(Core1, Mem1, IR, EA) end)
|
||||
end.
|
||||
|
||||
%% Miscellaneous ===============================================================
|
||||
|
||||
ea_address(#ea{section = Section, offset = Offset}) ->
|
||||
|
||||
@ -279,6 +279,7 @@ dispatch(Core, Mem, IR, EA) ->
|
||||
8#427 -> sim_moves:handle_MOVEM(Core, Mem, IR, EA); % SETAB = MOVEM
|
||||
8#430 -> sim_boolean:handle_XOR(Core, Mem, IR, EA);
|
||||
8#431 -> sim_boolean:handle_XORI(Core, Mem, IR, EA);
|
||||
8#432 -> sim_boolean:handle_XORM(Core, Mem, IR, EA);
|
||||
_ ->
|
||||
PC = (Core#core.pc_section bsl 18) bor Core#core.pc_offset,
|
||||
{Core, Mem, {error, {?MODULE, {dispatch, PC, IR, EA}}}}
|
||||
|
||||
@ -70,6 +70,7 @@
|
||||
-define(OP_SETAB, 8#426).
|
||||
-define(OP_XOR, 8#430).
|
||||
-define(OP_XORI, 8#431).
|
||||
-define(OP_XORM, 8#432).
|
||||
|
||||
%% 2.4 Boolean Functions =======================================================
|
||||
|
||||
@ -399,6 +400,17 @@ xori_test() ->
|
||||
[ {#ea{section = 1, offset = 1, islocal = false}, 8#434343} % AC1 = 0,,434343
|
||||
]).
|
||||
|
||||
xorm_test() ->
|
||||
Prog =
|
||||
[ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 8#707070)} % 1,,100/ MOVEI 1,707070
|
||||
, {1, 8#101, ?INSN(?OP_XORM, 1, 0, 0, 8#200)} % 1,,101/ XORM 1,200
|
||||
, {1, 8#102, ?INSN_INVALID} % 1,,102/ <invalid>
|
||||
, {1, 8#200, ?COMMA2(0, 8#333333)} % 1,,200/ 0,,333333
|
||||
],
|
||||
expect(Prog, [], {1, 8#102}, ?DEFAULT_FLAGS,
|
||||
[ {#ea{section = 1, offset = 8#200, islocal = false}, 8#434343} % C(1,,200) = 0,,434343
|
||||
]).
|
||||
|
||||
%% Common code to run short sequences ==========================================
|
||||
|
||||
expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user