Skip to content

Commit

Permalink
Implement INC (absolute, X).
Browse files Browse the repository at this point in the history
  • Loading branch information
hainesr committed Oct 24, 2020
1 parent b296f10 commit a4c9724
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/mos6502/cpu_instructions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,12 @@ def instructions
# SED
0xf8 => lambda {
@status.decimal_mode = true
},

# INC (absolute, X)
0xfe => lambda {
address = absolute(@x)
@memory.set(address, inc(@memory.get(address)))
}
}
end
Expand Down
20 changes: 20 additions & 0 deletions test/cpu_instructions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1551,4 +1551,24 @@ def test_0xf6
assert(@cpu.zero?)
end

def test_0xfe
@cpu.load!(
[
0xa9, 0xfe, 0xa2, 0x08, 0x9d, 0x92, 0x32,
0xfe, 0x92, 0x32, 0xfe, 0x92, 0x32
]
)
@cpu.step
@cpu.step
@cpu.step
assert_equal([0xfe], @cpu.dump_memory(0x329a, 1))
@cpu.step
assert_equal([0xff], @cpu.dump_memory(0x329a, 1))
assert(@cpu.negative?)
refute(@cpu.zero?)
@cpu.step
assert_equal([0x00], @cpu.dump_memory(0x329a, 1))
refute(@cpu.negative?)
assert(@cpu.zero?)
end
end

0 comments on commit a4c9724

Please sign in to comment.