diff --git a/erlang/apps/sim/src/sim_core.erl b/erlang/apps/sim/src/sim_core.erl index 258835e..8f433e1 100644 --- a/erlang/apps/sim/src/sim_core.erl +++ b/erlang/apps/sim/src/sim_core.erl @@ -230,6 +230,7 @@ dispatch(Core, Mem, IR, EA) -> 8#203 -> sim_moves:handle_MOVES(Core, Mem, IR, EA); 8#204 -> sim_moves:handle_MOVS(Core, Mem, IR, EA); 8#205 -> sim_moves:handle_MOVSI(Core, Mem, IR, EA); + 8#206 -> sim_moves:handle_MOVSM(Core, Mem, IR, EA); 8#250 -> sim_moves:handle_EXCH(Core, Mem, IR, EA); _ -> PC = (Core#core.pc_section bsl 18) bor Core#core.pc_offset, diff --git a/erlang/apps/sim/src/sim_moves.erl b/erlang/apps/sim/src/sim_moves.erl index 2fe5d50..190da28 100644 --- a/erlang/apps/sim/src/sim_moves.erl +++ b/erlang/apps/sim/src/sim_moves.erl @@ -31,6 +31,7 @@ , handle_MOVES/4 , handle_MOVS/4 , handle_MOVSI/4 + , handle_MOVSM/4 ]). -include("sim_core.hrl"). @@ -138,6 +139,13 @@ handle_MOVSI(Core, Mem, IR, #ea{offset = E}) -> AC = IR band 8#17, sim_core:next_pc(sim_core:set_ac(Core, AC, E bsl 18), Mem). +-spec handle_MOVSM(#core{}, sim_mem:mem(), IR :: word(), #ea{}) + -> {#core{}, sim_mem:mem(), {ok, integer()} | {error, {module(), term()}}}. +handle_MOVSM(Core, Mem, IR, EA) -> + AC = IR band 8#17, + CA = sim_core:get_ac(Core, AC), + handle_MOVEM_1(Core, Mem, swap_halves(CA), EA). + %% Miscellaneous =============================================================== ea_address(#ea{section = Section, offset = Offset}) -> diff --git a/erlang/apps/sim/test/sim_moves_tests.erl b/erlang/apps/sim/test/sim_moves_tests.erl index 7c4d68f..27c3f1a 100644 --- a/erlang/apps/sim/test/sim_moves_tests.erl +++ b/erlang/apps/sim/test/sim_moves_tests.erl @@ -49,6 +49,7 @@ -define(OP_MOVES, 8#203). -define(OP_MOVS, 8#204). -define(OP_MOVSI, 8#205). +-define(OP_MOVSM, 8#206). -define(OP_EXCH, 8#250). %% 2.1.1 Exchange Instruction ================================================== @@ -154,6 +155,17 @@ movsi_test() -> [ {#ea{section = 1, offset = 1, islocal = false}, ?COMMA2(-1, 0)} % AC1 = -1,,0 ]). +movsm_test() -> + Prog = + [ {1, 8#100, ?INSN(?OP_MOVEI, 1, 0, 0, 8#42)} % 1,,100/ MOVEI 1,42 + , {1, 8#101, ?INSN(?OP_MOVSM, 1, 0, 0, 8#150)} % 1,,101/ MOVSM 1,150 + , {1, 8#102, ?INSN_INVALID} % 1,,102/ + , {1, 8#150, 8#27} % 1,,150/ 0,,27 + ], + expect(Prog, [], {1, 8#102}, ?DEFAULT_FLAGS, + [ {#ea{section = 1, offset = 8#150, islocal = false}, ?COMMA2(8#42, 0)} % C(1,,150) = 42,,0 + ]). + %% Common code to run short sequences ========================================== expect(Prog, ACs, ExpectedPC, ExpectedFlags, ExpectedEs) ->