mirror of
https://github.com/mikpe/pdp10-tools.git
synced 2026-01-22 18:42:34 +00:00
sim: sim_boolean: handle XOR, add unit test
This commit is contained in:
parent
a30384b185
commit
b3038df02b
@ -42,6 +42,7 @@
|
||||
, handle_SETZ/4
|
||||
, handle_SETZB/4
|
||||
, handle_SETZM/4
|
||||
, handle_XOR/4
|
||||
]).
|
||||
|
||||
-include("sim_core.hrl").
|
||||
@ -289,6 +290,22 @@ handle_ANDCMB(Core, Mem, IR, EA) ->
|
||||
fun(Core1, Mem1) -> handle_ANDCMB(Core1, Mem1, IR, EA) end)
|
||||
end.
|
||||
|
||||
%% XOR - Exclusive Or with AC
|
||||
|
||||
-spec handle_XOR(#core{}, sim_mem:mem(), IR :: word(), #ea{})
|
||||
-> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}.
|
||||
handle_XOR(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,
|
||||
sim_core:next_pc(sim_core:set_ac(Core, AC, Word), Mem);
|
||||
{error, Reason} ->
|
||||
sim_core:page_fault(Core, Mem, ea_address(EA), read, Reason,
|
||||
fun(Core1, Mem1) -> handle_XOR(Core1, Mem1, IR, EA) end)
|
||||
end.
|
||||
|
||||
%% Miscellaneous ===============================================================
|
||||
|
||||
ea_address(#ea{section = Section, offset = Offset}) ->
|
||||
|
||||
@ -277,6 +277,7 @@ dispatch(Core, Mem, IR, EA) ->
|
||||
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
|
||||
8#430 -> sim_boolean:handle_XOR(Core, Mem, IR, EA);
|
||||
_ ->
|
||||
PC = (Core#core.pc_section bsl 18) bor Core#core.pc_offset,
|
||||
{Core, Mem, {error, {?MODULE, {dispatch, PC, IR, EA}}}}
|
||||
|
||||
@ -68,6 +68,7 @@
|
||||
-define(OP_SETAI, 8#425).
|
||||
-define(OP_SETAM, 8#426).
|
||||
-define(OP_SETAB, 8#426).
|
||||
-define(OP_XOR, 8#430).
|
||||
|
||||
%% 2.4 Boolean Functions =======================================================
|
||||
|
||||
@ -374,6 +375,19 @@ setab_test() ->
|
||||
[ {#ea{section = 1, offset = 8#150, islocal = false}, 8#42} % C(1,,150) = 42
|
||||
]).
|
||||
|
||||
%% XOR - Exclusive Or with AC
|
||||
|
||||
xor_test() ->
|
||||
Prog =
|
||||
[ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 8#707070)} % 1,,100/ MOVEI 1,707070
|
||||
, {1, 8#101, ?INSN(?OP_XOR, 1, 0, 0, 8#200)} % 1,,101/ XOR 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 = 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