Module: Badline::InstructionSet::IncDec
- Included in:
- Badline::InstructionSet
- Defined in:
- lib/badline/instruction_set/inc_dec.rb
Instance Method Summary collapse
-
#dec(addr, value) ⇒ Object
Decrements memory location by one.
-
#dex(_addr, _value) ⇒ Object
Decrements X register by one.
-
#dey(_addr, _value) ⇒ Object
Decrements Y register by one.
-
#inc(addr, value) ⇒ Object
Increments memory location by one.
-
#inx(_addr, _value) ⇒ Object
Increments X register by one.
-
#iny(_addr, _value) ⇒ Object
Increments Y register by one.
Instance Method Details
#dec(addr, value) ⇒ Object
Decrements memory location by one.
Opcodes:
$C6 - zeropage - 5 cycles
$CE - absolute - 6 cycles
$D6 - zeropage_x - 6 cycles
$DE - absolute_x - 7 cycles
13 14 15 16 17 18 |
# File 'lib/badline/instruction_set/inc_dec.rb', line 13 def dec(addr, value) v = resolve(value) result = (v - 1) & 0xff write_modified(addr, v, result) update_number_flags(result) end |
#dex(_addr, _value) ⇒ Object
Decrements X register by one.
Opcodes:
$CA - implied - 2 cycles
24 25 26 27 |
# File 'lib/badline/instruction_set/inc_dec.rb', line 24 def dex(_addr, _value) cycle { @x = (@x - 1) & 0xff } update_number_flags(@x) end |
#dey(_addr, _value) ⇒ Object
Decrements Y register by one.
Opcodes:
$88 - implied - 2 cycles
33 34 35 36 |
# File 'lib/badline/instruction_set/inc_dec.rb', line 33 def dey(_addr, _value) cycle { @y = (@y - 1) & 0xff } update_number_flags(@y) end |
#inc(addr, value) ⇒ Object
Increments memory location by one.
Opcodes:
$E6 - zeropage - 5 cycles
$EE - absolute - 6 cycles
$F6 - zeropage_x - 6 cycles
$FE - absolute_x - 7 cycles
45 46 47 48 49 50 |
# File 'lib/badline/instruction_set/inc_dec.rb', line 45 def inc(addr, value) v = resolve(value) result = (v + 1) & 0xff write_modified(addr, v, result) update_number_flags(result) end |
#inx(_addr, _value) ⇒ Object
Increments X register by one.
Opcodes:
$E8 - implied - 2 cycles
56 57 58 59 |
# File 'lib/badline/instruction_set/inc_dec.rb', line 56 def inx(_addr, _value) cycle { @x = (@x + 1) & 0xff } update_number_flags(@x) end |
#iny(_addr, _value) ⇒ Object
Increments Y register by one.
Opcodes:
$C8 - implied - 2 cycles
65 66 67 68 |
# File 'lib/badline/instruction_set/inc_dec.rb', line 65 def iny(_addr, _value) cycle { @y = (@y + 1) & 0xff } update_number_flags(@y) end |