mirror of
https://github.com/mikpe/pdp10-tools.git
synced 2026-01-23 19:08:00 +00:00
sim: sim_boolean: handle XORB, add unit test
This commit is contained in:
parent
579a7aee5b
commit
6b43d21578
@ -43,6 +43,7 @@
|
||||
, handle_SETZB/4
|
||||
, handle_SETZM/4
|
||||
, handle_XOR/4
|
||||
, handle_XORB/4
|
||||
, handle_XORI/4
|
||||
, handle_XORM/4
|
||||
]).
|
||||
@ -330,6 +331,20 @@ handle_XORM(Core, Mem, IR, EA) ->
|
||||
fun(Core1, Mem1) -> handle_XORM(Core1, Mem1, IR, EA) end)
|
||||
end.
|
||||
|
||||
-spec handle_XORB(#core{}, sim_mem:mem(), IR :: word(), #ea{})
|
||||
-> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}.
|
||||
handle_XORB(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_ANDB(Core, Mem, AC, EA, Word);
|
||||
{error, Reason} ->
|
||||
sim_core:page_fault(Core, Mem, ea_address(EA), read, Reason,
|
||||
fun(Core1, Mem1) -> handle_XORB(Core1, Mem1, IR, EA) end)
|
||||
end.
|
||||
|
||||
%% Miscellaneous ===============================================================
|
||||
|
||||
ea_address(#ea{section = Section, offset = Offset}) ->
|
||||
|
||||
@ -280,6 +280,7 @@ dispatch(Core, Mem, IR, EA) ->
|
||||
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);
|
||||
8#433 -> sim_boolean:handle_XORB(Core, Mem, IR, EA);
|
||||
_ ->
|
||||
PC = (Core#core.pc_section bsl 18) bor Core#core.pc_offset,
|
||||
{Core, Mem, {error, {?MODULE, {dispatch, PC, IR, EA}}}}
|
||||
|
||||
@ -71,6 +71,7 @@
|
||||
-define(OP_XOR, 8#430).
|
||||
-define(OP_XORI, 8#431).
|
||||
-define(OP_XORM, 8#432).
|
||||
-define(OP_XORB, 8#433).
|
||||
|
||||
%% 2.4 Boolean Functions =======================================================
|
||||
|
||||
@ -411,6 +412,18 @@ xorm_test() ->
|
||||
[ {#ea{section = 1, offset = 8#200, islocal = false}, 8#434343} % C(1,,200) = 0,,434343
|
||||
]).
|
||||
|
||||
xorb_test() ->
|
||||
Prog =
|
||||
[ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 8#707070)} % 1,,100/ MOVEI 1,707070
|
||||
, {1, 8#101, ?INSN(?OP_XORB, 1, 0, 0, 8#200)} % 1,,101/ XORB 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
|
||||
, {#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