Skip to content

Commit

Permalink
Implement ROR (zero page, X).
Browse files Browse the repository at this point in the history
  • Loading branch information
hainesr committed Oct 24, 2020
1 parent 532e6bf commit 57fbc40
Show file tree
Hide file tree
Showing 2 changed files with 18 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 @@ -232,6 +232,12 @@ def instructions
@pc = branch(offset) if @status.overflow?
},

# ROR (zero page, X)
0x76 => lambda {
address = zero_page(@x)
@memory.set(address, ror(@memory.get(address)))
},

# SEI
0x78 => lambda {
@status.interupt_disable = true
Expand Down
12 changes: 12 additions & 0 deletions test/cpu_instructions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,18 @@ def test_0x70
assert_equal(0xff, @cpu.y)
end

def test_0x76
@cpu.load!([0xa9, 0x7f, 0xa2, 0xbc, 0x95, 0x70, 0x76, 0x70])
@cpu.step
@cpu.step
@cpu.step
@cpu.step
assert(@cpu.carry?)
refute(@cpu.negative?)
refute(@cpu.zero?)
assert_equal([0x3f], @cpu.dump_memory(0x2c, 1))
end

def test_0x81
@cpu.load!(
[
Expand Down

0 comments on commit 57fbc40

Please sign in to comment.