Skip to content

Commit

Permalink
Green again :)
Browse files Browse the repository at this point in the history
  • Loading branch information
dparnell committed Apr 23, 2012
1 parent 521420e commit d96697d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
11 changes: 4 additions & 7 deletions src/dcpu16_core.erl
Expand Up @@ -237,10 +237,10 @@ cycle(Cpu, Ram, Cycles, [], CyclesLeft) ->
9 -> [decode_read(A), set_target, decode_read(B), logical_and, decode_write(A)];
10 -> [decode_read(A), set_target, decode_read(B), logical_or, decode_write(A)];
11 -> [decode_read(A), set_target, decode_read(B), logical_xor, decode_write(A)];
12 -> [decode_read(A), set_target, decode_read(B), ife];
13 -> [decode_read(A), set_target, decode_read(B), ifn];
14 -> [decode_read(A), set_target, decode_read(B), ifg];
15 -> [decode_read(A), set_target, decode_read(B), ifb];
12 -> [decode_read(A), set_target, decode_read(B), nop, ife];
13 -> [decode_read(A), set_target, decode_read(B), nop, ifn];
14 -> [decode_read(A), set_target, decode_read(B), nop, ifg];
15 -> [decode_read(A), set_target, decode_read(B), nop, ifb];
_ -> error
end,

Expand Down Expand Up @@ -280,9 +280,6 @@ cycle(Cpu, Ram, Cycles, [Micro_op|Micro_ops], CyclesLeft) ->

{ lit, Value } -> { Cpu#cpu{w = lists:append([Value], Cpu#cpu.w)}, Ram, 0 };

read_next_literal -> Literal = array:get(Cpu#cpu.pc, Ram),
{ Cpu#cpu{ pc = Cpu#cpu.pc + 1, w = lists:append([Literal], Cpu#cpu.w)}, Ram, 1 };

{ read_reg, Reg } -> { Cpu#cpu{w = lists:append([reg(Cpu, Reg)], Cpu#cpu.w)}, Ram, 0};

{ write_reg, Reg } -> [Value|T] = Cpu#cpu.w,
Expand Down
8 changes: 4 additions & 4 deletions src/dcpu16_core_test.erl
Expand Up @@ -96,7 +96,7 @@ test_subroutines() ->
16#61c1 %% SET PC, POP
]),

ResultCPU = dcpu16_core:cycle(ReadyCPU, 100),
ResultCPU = dcpu16_core:cycle(ReadyCPU, 11),

{
dcpu16_core:get_reg(ResultCPU, a),
Expand Down Expand Up @@ -229,7 +229,7 @@ basic_test_() ->
?_assertEqual(16#1234, attempt(fun() -> indirect_register_write() end)),
?_assertEqual(16#0010, attempt(fun() -> complicated_subtraction() end)),
?_assertMatch({16#0001, 16#0005}, attempt(fun() -> test_subroutines() end)),
?_assertEqual(16#0021, attempt(fun() -> test_stack_operations() end))
% ?_assertEqual(16#0013, attempt(fun() -> subtractions_and_overflow() end)),
% ?_assertEqual(16#0015, attempt(fun() -> compare_instructions() end))
?_assertEqual(16#0021, attempt(fun() -> test_stack_operations() end)),
?_assertEqual(16#0013, attempt(fun() -> subtractions_and_overflow() end)),
?_assertEqual(16#0015, attempt(fun() -> compare_instructions() end))
].

0 comments on commit d96697d

Please sign in to comment.