mirror of
https://github.com/mikpe/pdp10-tools.git
synced 2026-04-26 12:08:27 +00:00
sim: sim_boolean: handle ANDCA, add unit test
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
|
||||
-export([ handle_AND/4
|
||||
, handle_ANDB/4
|
||||
, handle_ANDCA/4
|
||||
, handle_ANDI/4
|
||||
, handle_ANDM/4
|
||||
, handle_SETZ/4
|
||||
@@ -135,6 +136,22 @@ handle_ANDB(Core, Mem, AC, EA, Word) ->
|
||||
fun(Core1, Mem1) -> handle_ANDB(Core1, Mem1, AC, EA, Word) end)
|
||||
end.
|
||||
|
||||
%% ANDCA - And with Complement of AC
|
||||
|
||||
-spec handle_ANDCA(#core{}, sim_mem:mem(), IR :: word(), #ea{})
|
||||
-> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}.
|
||||
handle_ANDCA(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 band bnot 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_ANDCA(Core1, Mem1, IR, EA) end)
|
||||
end.
|
||||
|
||||
%% Miscellaneous ===============================================================
|
||||
|
||||
ea_address(#ea{section = Section, offset = Offset}) ->
|
||||
|
||||
@@ -261,6 +261,7 @@ dispatch(Core, Mem, IR, EA) ->
|
||||
8#405 -> sim_boolean:handle_ANDI(Core, Mem, IR, EA);
|
||||
8#406 -> sim_boolean:handle_ANDM(Core, Mem, IR, EA);
|
||||
8#407 -> sim_boolean:handle_ANDB(Core, Mem, IR, EA);
|
||||
8#410 -> sim_boolean:handle_ANDCA(Core, Mem, IR, EA);
|
||||
_ ->
|
||||
PC = (Core#core.pc_section bsl 18) bor Core#core.pc_offset,
|
||||
{Core, Mem, {error, {?MODULE, {dispatch, PC, IR, EA}}}}
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
-define(OP_ANDI, 8#405).
|
||||
-define(OP_ANDM, 8#406).
|
||||
-define(OP_ANDB, 8#407).
|
||||
-define(OP_ANDCA, 8#410).
|
||||
|
||||
%% 2.4 Boolean Functions =======================================================
|
||||
|
||||
@@ -144,6 +145,19 @@ andb_test() ->
|
||||
, {#ea{section = 1, offset = 1, islocal = false}, 8#303030} % AC1 = 0,,303030
|
||||
]).
|
||||
|
||||
%% ANDCA - And with Complement of AC
|
||||
|
||||
andca_test() ->
|
||||
Prog =
|
||||
[ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 8#707070)} % 1,,100/ MOVEI 1,707070
|
||||
, {1, 8#101, ?INSN(?OP_ANDCA, 1, 0, 0, 8#200)} % 1,,101/ ANDCA 1,200
|
||||
, {1, 8#102, ?INSN_INVALID} % 1,,102/ <invalid>
|
||||
, {1, 8#200, ?COMMA2(-1, 8#333333)} % 1,,200/ -1,,333333
|
||||
],
|
||||
expect(Prog, [], {1, 8#102}, ?DEFAULT_FLAGS,
|
||||
[ {#ea{section = 1, offset = 1, islocal = false}, ?COMMA2(-1, 8#030303)} % AC1 = -1,,030303
|
||||
]).
|
||||
|
||||
%% Common code to run short sequences ==========================================
|
||||
|
||||
expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->
|
||||
|
||||
Reference in New Issue
Block a user