Skip to content

Commit

Permalink
Implement LSR (absolute).
Browse files Browse the repository at this point in the history
  • Loading branch information
hainesr committed Oct 24, 2020
1 parent 458cbfb commit a7afb5d
Show file tree
Hide file tree
Showing 2 changed files with 17 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 @@ -147,6 +147,12 @@ def instructions
@pc = absolute
},

# LSR (absolute)
0x4e => lambda {
address = absolute
@memory.set(address, lsr(@memory.get(address)))
},

# BVC
0x50 => lambda {
offset = next_byte
Expand Down
11 changes: 11 additions & 0 deletions test/cpu_instructions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,17 @@ def test_0x4c
assert_equal(0x047f, @cpu.pc)
end

def test_0x4e
@cpu.load!([0xa9, 0x7f, 0x8d, 0x0f, 0x70, 0x4e, 0x0f, 0x70])
@cpu.step
@cpu.step
@cpu.step
assert(@cpu.carry?)
refute(@cpu.negative?)
refute(@cpu.zero?)
assert_equal([0x3f], @cpu.dump_memory(0x700f, 1))
end

def test_0x50
@cpu.load!(
[0xa9, 0x40, 0x48, 0x28, 0x50, 0x03, 0xb8, 0x50, 0xfb, 0xa0, 0xff]
Expand Down

0 comments on commit a7afb5d

Please sign in to comment.