Skip to content

Commit

Permalink
Implement NOP (absolute, X).
Browse files Browse the repository at this point in the history
  • Loading branch information
hainesr committed Oct 28, 2020
1 parent 3c5e537 commit 03e252b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
32 changes: 31 additions & 1 deletion lib/mos6502/cpu_illegal_instructions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ def illegal_instructions
# NOP (implied)
0x1a => lambda {},

# NOP (absolute, X)
0x1c => lambda {
absolute(@x)
},

# NOP (zero page, X)
0x34 => lambda {
zero_page(@x)
Expand All @@ -38,6 +43,11 @@ def illegal_instructions
# NOP (implied)
0x3a => lambda {},

# NOP (absolute, X)
0x3c => lambda {
absolute(@x)
},

# NOP (zero page)
0x44 => lambda {
zero_page
Expand All @@ -51,6 +61,11 @@ def illegal_instructions
# NOP (implied)
0x5a => lambda {},

# NOP (absolute, X)
0x5c => lambda {
absolute(@x)
},

# NOP (zero page)
0x64 => lambda {
zero_page
Expand All @@ -64,6 +79,11 @@ def illegal_instructions
# NOP (implied)
0x7a => lambda {},

# NOP (absolute, X)
0x7c => lambda {
absolute(@x)
},

# NOP (immediate)
0x80 => lambda {
next_byte
Expand All @@ -77,13 +97,23 @@ def illegal_instructions
# NOP (implied)
0xda => lambda {},

# NOP (absolute, X)
0xdc => lambda {
absolute(@x)
},

# NOP (zero page, X)
0xf4 => lambda {
zero_page(@x)
},

# NOP (implied)
0xfa => lambda {}
0xfa => lambda {},

# NOP (absolute, X)
0xfc => lambda {
absolute(@x)
}
}
end
end
Expand Down
20 changes: 20 additions & 0 deletions test/cpu_illegal_instructions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,26 @@ def test_0x1a_0x3a_0x5a_0x7a_0xda_0xfa
assert_equal(0x606, @cpu.pc)
end

# NOP (absolute, X)
def test_0x1c_0x3c_0x5c_0x7c_0xdc_0xfc
@cpu.load!(
[
0x1c, 0xa9, 0xa9, 0x3c, 0xa9, 0xa9, 0x5c, 0xa9, 0xa9,
0x7c, 0xa9, 0xa9, 0xdc, 0xa9, 0xa9, 0xfc, 0xa9, 0xa9
]
)
@cpu.step
@cpu.step
@cpu.step
@cpu.step
@cpu.step
@cpu.step
assert_equal(0x00, @cpu.a)
assert_equal(0x00, @cpu.x)
assert_equal(0x00, @cpu.y)
assert_equal(0x612, @cpu.pc)
end

# NOP (immediate)
def test_0x80
@cpu.load!([0x80, 0xff])
Expand Down

0 comments on commit 03e252b

Please sign in to comment.