Skip to content

Commit

Permalink
more cycle testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mpd committed Apr 16, 2010
1 parent 15baa68 commit a7e8c39
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 5 deletions.
9 changes: 7 additions & 2 deletions cpu/cpu_6502.rb
Expand Up @@ -605,12 +605,16 @@ def runop(opcode, oper1 = nil, oper2 = nil)
set_sz(@register[:A])

when 0x5D # EOR absolutex
address = ((oper1 << 8) | oper2) + @register[:X]
sixteen = to_16_bit(oper1, oper2)
add_cycle_if_crossing_boundary(sixteen, @register[:X])
address = (sixteen + @register[:X])
@register[:A] = (@register[:A] ^ @ram[address]) & 0xFF
set_sz(@register[:A])

when 0x59 # EOR absolutey
address = ((oper1 << 8) | oper2) + @register[:Y]
sixteen = to_16_bit(oper1, oper2)
add_cycle_if_crossing_boundary(sixteen, @register[:Y])
address = (sixteen + @register[:Y])
@register[:A] = (@register[:A] ^ @ram[address]) & 0xFF
set_sz(@register[:A])

Expand All @@ -620,6 +624,7 @@ def runop(opcode, oper1 = nil, oper2 = nil)
set_sz(@register[:A])

when 0x51 # EOR indirecty
add_cycle_if_crossing_boundary(oper1, @register[:Y])
address = indirect_y_address(oper1)
@register[:A] = (@register[:A] ^ @ram[address]) & 0xFF
set_sz(@register[:A])
Expand Down
3 changes: 3 additions & 0 deletions test/cpu/6502/ops/cpx_test.rb
Expand Up @@ -13,6 +13,7 @@ class Cpu6502CpxTest < Test::Unit::TestCase
end

should_increase_pc_by 2
should_increase_cycles_by 2

should "set the carry flag if the value in the X register is the same or greater than the passed value" do
@cpu.runop(@op, 0x30)
Expand Down Expand Up @@ -56,6 +57,7 @@ class Cpu6502CpxTest < Test::Unit::TestCase
end

should_increase_pc_by 2
should_increase_cycles_by 3

should "set the carry flag if the X register value is the same or greater than the passed value" do
@cpu.ram[0x1A] = 0x20
Expand Down Expand Up @@ -103,6 +105,7 @@ class Cpu6502CpxTest < Test::Unit::TestCase
end

should_increase_pc_by 3
should_increase_cycles_by 4

should "set the carry flag if the X register value is the same or greater than the passed value" do
@cpu.ram[0x1A34] = 0x20
Expand Down
3 changes: 3 additions & 0 deletions test/cpu/6502/ops/cpy_test.rb
Expand Up @@ -13,6 +13,7 @@ class Cpu6502CpyTest < Test::Unit::TestCase
end

should_increase_pc_by 2
should_increase_cycles_by 2

should "set the carry flag if the value in the Y register is the same or greater than the passed value" do
@cpu.runop(@op, 0x30)
Expand Down Expand Up @@ -56,6 +57,7 @@ class Cpu6502CpyTest < Test::Unit::TestCase
end

should_increase_pc_by 2
should_increase_cycles_by 3

should "set the carry flag if the Y register value is the same or greater than the passed value" do
@cpu.ram[0x1A] = 0x20
Expand Down Expand Up @@ -103,6 +105,7 @@ class Cpu6502CpyTest < Test::Unit::TestCase
end

should_increase_pc_by 3
should_increase_cycles_by 4

should "set the carry flag if the Y register value is the same or greater than the passed value" do
@cpu.ram[0x1A34] = 0x20
Expand Down
6 changes: 5 additions & 1 deletion test/cpu/6502/ops/dec_test.rb
Expand Up @@ -13,7 +13,8 @@ class Cpu6502DecTest < Test::Unit::TestCase
end

should_increase_pc_by 2

should_increase_cycles_by 5

should "decrement the value at the correct address by 1" do
@cpu.runop(@op, 0x12)
assert_equal 0x68, @cpu.ram[0x12]
Expand Down Expand Up @@ -50,6 +51,7 @@ class Cpu6502DecTest < Test::Unit::TestCase
end

should_increase_pc_by 2
should_increase_cycles_by 6

should "decrement the value at the correct address by 1" do
@cpu.runop(@op, 0x12)
Expand Down Expand Up @@ -92,6 +94,7 @@ class Cpu6502DecTest < Test::Unit::TestCase
end

should_increase_pc_by 3
should_increase_cycles_by 6

should "decrement the value at the correct address by 1" do
@cpu.runop(@op, 0x16, 0x5B)
Expand Down Expand Up @@ -129,6 +132,7 @@ class Cpu6502DecTest < Test::Unit::TestCase
end

should_increase_pc_by 3
should_increase_cycles_by 7

should "decrement the value at the correct address by 1" do
@cpu.runop(@op, 0x16, 0x5B)
Expand Down
1 change: 1 addition & 0 deletions test/cpu/6502/ops/dex_test.rb
Expand Up @@ -13,6 +13,7 @@ class Cpu6502DexTest < Test::Unit::TestCase
end

should_increase_pc_by 1
should_increase_cycles_by 2

should "decrement the value in the X register" do
@cpu.runop(@op)
Expand Down
1 change: 1 addition & 0 deletions test/cpu/6502/ops/dey_test.rb
Expand Up @@ -13,6 +13,7 @@ class Cpu6502DeyTest < Test::Unit::TestCase
end

should_increase_pc_by 1
should_increase_cycles_by 2

should "decrement the value in the Y register" do
@cpu.runop(@op)
Expand Down
10 changes: 9 additions & 1 deletion test/cpu/6502/ops/eor_test.rb
Expand Up @@ -13,6 +13,7 @@ class Cpu6502EorTest < Test::Unit::TestCase
end

should_increase_pc_by 2
should_increase_cycles_by 2

should "exclusive OR the contents of the accumulator with the correct value based on addressing mode, storing the results in the accumulator" do
@cpu.runop(@op, 0x83)
Expand Down Expand Up @@ -47,6 +48,7 @@ class Cpu6502EorTest < Test::Unit::TestCase
end

should_increase_pc_by 2
should_increase_cycles_by 3

should "exclusive OR the contents of the accumulator with the correct value based on addressing mode, storing the results in the accumulator" do
@cpu.ram[0x50] = 0x83
Expand Down Expand Up @@ -87,6 +89,7 @@ class Cpu6502EorTest < Test::Unit::TestCase
end

should_increase_pc_by 2
should_increase_cycles_by 4

should "exclusive OR the contents of the accumulator with the correct value based on addressing mode, storing the results in the accumulator" do
@cpu.ram[0x50] = 0x83
Expand Down Expand Up @@ -133,6 +136,7 @@ class Cpu6502EorTest < Test::Unit::TestCase
end

should_increase_pc_by 3
should_increase_cycles_by 4

should "exclusive OR the contents of the accumulator with the correct value based on addressing mode, storing the results in the accumulator" do
@cpu.ram[0x5150] = 0x83
Expand Down Expand Up @@ -173,6 +177,7 @@ class Cpu6502EorTest < Test::Unit::TestCase
end

should_increase_pc_by 3
should_increase_cycles_with_boundary_check_by 4

should "exclusive OR the contents of the accumulator with the correct value based on addressing mode, storing the results in the accumulator" do
@cpu.ram[0x5150] = 0x83
Expand Down Expand Up @@ -213,6 +218,7 @@ class Cpu6502EorTest < Test::Unit::TestCase
end

should_increase_pc_by 3
should_increase_cycles_with_boundary_check_by 4

should "exclusive OR the contents of the accumulator with the correct value based on addressing mode, storing the results in the accumulator" do
@cpu.ram[0x5150] = 0x83
Expand Down Expand Up @@ -255,7 +261,8 @@ class Cpu6502EorTest < Test::Unit::TestCase
end

should_increase_pc_by 2

should_increase_cycles_by 6

should "exclusive OR the contents of the accumulator with the correct value based on addressing mode, storing the results in the accumulator" do
@cpu.ram[0x5150] = 0x83
@cpu.runop(@op, 0x1C)
Expand Down Expand Up @@ -305,6 +312,7 @@ class Cpu6502EorTest < Test::Unit::TestCase
end

should_increase_pc_by 2
should_increase_cycles_with_boundary_check_by 5

should "exclusive OR the contents of the accumulator with the correct value based on addressing mode, storing the results in the accumulator" do
@cpu.ram[0x5150] = 0x83
Expand Down
4 changes: 4 additions & 0 deletions test/cpu/6502/ops/inc_test.rb
Expand Up @@ -13,6 +13,7 @@ class Cpu6502IncTest < Test::Unit::TestCase
end

should_increase_pc_by 2
should_increase_cycles_by 5

should "increment the value at the correct address by 1" do
@cpu.runop(@op, 0x12)
Expand Down Expand Up @@ -50,6 +51,7 @@ class Cpu6502IncTest < Test::Unit::TestCase
end

should_increase_pc_by 2
should_increase_cycles_by 6

should "increment the value at the correct address by 1" do
@cpu.runop(@op, 0x12)
Expand Down Expand Up @@ -92,6 +94,7 @@ class Cpu6502IncTest < Test::Unit::TestCase
end

should_increase_pc_by 3
should_increase_cycles_by 6

should "increment the value at the correct address by 1" do
@cpu.runop(@op, 0x16, 0x5B)
Expand Down Expand Up @@ -129,6 +132,7 @@ class Cpu6502IncTest < Test::Unit::TestCase
end

should_increase_pc_by 3
should_increase_cycles_by 7

should "increment the value at the correct address by 1" do
@cpu.runop(@op, 0x16, 0x5B)
Expand Down
3 changes: 2 additions & 1 deletion test/cpu/6502/ops/inx_test.rb
Expand Up @@ -12,7 +12,8 @@ class Cpu6502InxTest < Test::Unit::TestCase
end

should_increase_pc_by 1

should_increase_cycles_by 2

should "increment the X register" do
@cpu.register = {:X => 8}
@cpu.runop(@op)
Expand Down
1 change: 1 addition & 0 deletions test/cpu/6502/ops/iny_test.rb
Expand Up @@ -12,6 +12,7 @@ class Cpu6502InyTest < Test::Unit::TestCase
end

should_increase_pc_by 1
should_increase_cycles_by 2

should "increment the Y register" do
@cpu.register[:Y] = 0x08
Expand Down

0 comments on commit a7e8c39

Please sign in to comment.