Skip to content

Commit

Permalink
Implement AND (indirect indexed).
Browse files Browse the repository at this point in the history
  • Loading branch information
hainesr committed Oct 25, 2020
1 parent 9a65225 commit 59b0306
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 @@ -145,6 +145,12 @@ def instructions
@pc = branch(offset) if @status.negative?
},

# AND (indirect indexed)
0x31 => lambda {
@a &= @memory.get(indirect_indexed)
set_nz_flags(@a)
},

# AND (zero page, X)
0x35 => lambda {
@a &= @memory.get(zero_page(@x))
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 @@ -280,6 +280,18 @@ def test_0x30
assert_equal(0xff, @cpu.y)
end

def test_0x31
@cpu.load!([0xa2, 0x06, 0x86, 0x76, 0xa0, 0x04, 0xa9, 0x3f, 0x31, 0x75])
@cpu.step
@cpu.step
@cpu.step
@cpu.step
@cpu.step
assert_equal(0x20, @cpu.a)
refute(@cpu.negative?)
refute(@cpu.zero?)
end

def test_0x35
@cpu.load!([0xa9, 0xb3, 0xa2, 0x12, 0xa0, 0xb3, 0x94, 0x41, 0x35, 0x41])
@cpu.step
Expand Down

0 comments on commit 59b0306

Please sign in to comment.