mirror of
https://github.com/mikpe/pdp10-tools.git
synced 2026-01-23 19:08:00 +00:00
sim: sim_boolean: handle XORI, add unit test
This commit is contained in:
parent
b3038df02b
commit
84a0e9b226
@ -43,6 +43,7 @@
|
||||
, handle_SETZB/4
|
||||
, handle_SETZM/4
|
||||
, handle_XOR/4
|
||||
, handle_XORI/4
|
||||
]).
|
||||
|
||||
-include("sim_core.hrl").
|
||||
@ -306,6 +307,14 @@ handle_XOR(Core, Mem, IR, EA) ->
|
||||
fun(Core1, Mem1) -> handle_XOR(Core1, Mem1, IR, EA) end)
|
||||
end.
|
||||
|
||||
-spec handle_XORI(#core{}, sim_mem:mem(), IR :: word(), #ea{})
|
||||
-> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}.
|
||||
handle_XORI(Core, Mem, IR, EA) ->
|
||||
AC = IR band 8#17,
|
||||
CA = sim_core:get_ac(Core, AC),
|
||||
Word = CA bxor EA#ea.offset,
|
||||
sim_core:next_pc(sim_core:set_ac(Core, AC, Word), Mem).
|
||||
|
||||
%% Miscellaneous ===============================================================
|
||||
|
||||
ea_address(#ea{section = Section, offset = Offset}) ->
|
||||
|
||||
@ -278,6 +278,7 @@ dispatch(Core, Mem, IR, EA) ->
|
||||
8#426 -> sim_moves:handle_MOVEM(Core, Mem, IR, EA); % SETAM = MOVEM
|
||||
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);
|
||||
_ ->
|
||||
PC = (Core#core.pc_section bsl 18) bor Core#core.pc_offset,
|
||||
{Core, Mem, {error, {?MODULE, {dispatch, PC, IR, EA}}}}
|
||||
|
||||
@ -69,6 +69,7 @@
|
||||
-define(OP_SETAM, 8#426).
|
||||
-define(OP_SETAB, 8#426).
|
||||
-define(OP_XOR, 8#430).
|
||||
-define(OP_XORI, 8#431).
|
||||
|
||||
%% 2.4 Boolean Functions =======================================================
|
||||
|
||||
@ -388,6 +389,16 @@ xor_test() ->
|
||||
[ {#ea{section = 1, offset = 1, islocal = false}, 8#434343} % AC1 = 0,,434343
|
||||
]).
|
||||
|
||||
xori_test() ->
|
||||
Prog =
|
||||
[ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 8#707070)} % 1,,100/ MOVEI 1,707070
|
||||
, {1, 8#101, ?INSN(?OP_XORI, 1, 0, 0, 8#333333)} % 1,,101/ XORI 1,333333
|
||||
, {1, 8#102, ?INSN_INVALID} % 1,,102/ <invalid>
|
||||
],
|
||||
expect(Prog, [], {1, 8#102}, ?DEFAULT_FLAGS,
|
||||
[ {#ea{section = 1, offset = 1, islocal = false}, 8#434343} % AC1 = 0,,434343
|
||||
]).
|
||||
|
||||
%% Common code to run short sequences ==========================================
|
||||
|
||||
expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user