mirror of
https://github.com/mikpe/pdp10-tools.git
synced 2026-01-25 11:47:25 +00:00
sim: sim_boolean: handle SETCMB, add unit test
This commit is contained in:
@@ -56,6 +56,7 @@
|
||||
, handle_SETCAB/4
|
||||
, handle_SETCAM/4
|
||||
, handle_SETCM/4
|
||||
, handle_SETCMB/4
|
||||
, handle_SETCMI/4
|
||||
, handle_SETCMM/4
|
||||
, handle_SETMB/4
|
||||
@@ -635,6 +636,19 @@ handle_SETCMM(Core, Mem, IR, EA) ->
|
||||
fun(Core1, Mem1) -> handle_SETCMM(Core1, Mem1, IR, EA) end)
|
||||
end.
|
||||
|
||||
-spec handle_SETCMB(#core{}, sim_mem:mem(), IR :: word(), #ea{})
|
||||
-> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}.
|
||||
handle_SETCMB(Core, Mem, IR, EA) ->
|
||||
case sim_core:c(Core, Mem, EA) of
|
||||
{ok, CE} ->
|
||||
AC = IR band 8#17,
|
||||
Word = (bnot CE) band ((1 bsl 36) - 1),
|
||||
handle_ANDB(Core, Mem, AC, EA, Word);
|
||||
{error, Reason} ->
|
||||
sim_core:page_fault(Core, Mem, ea_address(EA), read, Reason,
|
||||
fun(Core1, Mem1) -> handle_SETCMB(Core1, Mem1, IR, EA) end)
|
||||
end.
|
||||
|
||||
%% Miscellaneous ===============================================================
|
||||
|
||||
ea_address(#ea{section = Section, offset = Offset}) ->
|
||||
|
||||
@@ -304,6 +304,7 @@ dispatch(Core, Mem, IR, EA) ->
|
||||
8#460 -> sim_boolean:handle_SETCM(Core, Mem, IR, EA);
|
||||
8#461 -> sim_boolean:handle_SETCMI(Core, Mem, IR, EA);
|
||||
8#462 -> sim_boolean:handle_SETCMM(Core, Mem, IR, EA);
|
||||
8#463 -> sim_boolean:handle_SETCMB(Core, Mem, IR, EA);
|
||||
_ ->
|
||||
PC = (Core#core.pc_section bsl 18) bor Core#core.pc_offset,
|
||||
{Core, Mem, {error, {?MODULE, {dispatch, PC, IR, EA}}}}
|
||||
|
||||
@@ -95,6 +95,7 @@
|
||||
-define(OP_SETCM, 8#460).
|
||||
-define(OP_SETCMI, 8#461).
|
||||
-define(OP_SETCMM, 8#462).
|
||||
-define(OP_SETCMB, 8#463).
|
||||
|
||||
%% 2.4 Boolean Functions =======================================================
|
||||
|
||||
@@ -707,6 +708,17 @@ setcmm_test() ->
|
||||
[ {#ea{section = 1, offset = 8#200, islocal = false}, ?COMMA2(-1, 8#070707)} % C(1,,200) = -1,,070707
|
||||
]).
|
||||
|
||||
setcmb_test() ->
|
||||
Prog =
|
||||
[ {1, 8#100, ?INSN(?OP_SETCMB, 1, 0, 0, 8#200)} % 1,,100/ SETCMB 1,200
|
||||
, {1, 8#101, ?INSN_INVALID} % 1,,101/ <invalid>
|
||||
, {1, 8#200, ?COMMA2(0, 8#707070)} % 1,,200/ 0,,707070
|
||||
],
|
||||
expect(Prog, [], {1, 8#101}, ?DEFAULT_FLAGS,
|
||||
[ {#ea{section = 1, offset = 8#200, islocal = false}, ?COMMA2(-1, 8#070707)} % C(1,,200) = -1,,070707
|
||||
, {#ea{section = 1, offset = 1, islocal = false}, ?COMMA2(-1, 8#070707)} % AC1 = -1,,070707
|
||||
]).
|
||||
|
||||
%% Common code to run short sequences ==========================================
|
||||
|
||||
expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->
|
||||
|
||||
Reference in New Issue
Block a user