Class: GBRb::InstructionSet::Dec
- Inherits:
-
Instruction
- Object
- Instruction
- GBRb::InstructionSet::Dec
- Defined in:
- lib/gbrb/instruction_set/arithmetic.rb
Instance Attribute Summary
Attributes inherited from Instruction
Instance Method Summary collapse
- #call(r, mem) ⇒ Object
-
#initialize(register, m = 1, t = 4, flags = true, indirect = false) ⇒ Dec
constructor
A new instance of Dec.
Methods inherited from Instruction
Constructor Details
#initialize(register, m = 1, t = 4, flags = true, indirect = false) ⇒ Dec
Returns a new instance of Dec.
202 203 204 205 206 207 208 209 |
# File 'lib/gbrb/instruction_set/arithmetic.rb', line 202 def initialize register, m=1, t=4, flags=true, indirect=false super m, t @register = register @flags = flags @op = :- @indirect = indirect end |
Instance Method Details
#call(r, mem) ⇒ Object
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/gbrb/instruction_set/arithmetic.rb', line 211 def call r, mem reg = r.public_send(@register.to_sym) tmp = reg.read if @indirect v = mem.read_byte(tmp) mem.write_byte(tmp, v - 1) tmp = v half_mask = r.a.half_mask else reg.store tmp - 0x01 half_mask = reg.half_mask end if @flags r.set_add_sub_flag if (tmp - 0x01) == 0x00 r.set_zero_flag else r.clear_zero_flag end if carry? tmp, 0x01, half_mask r.set_half_carry_flag else r.clear_half_carry_flag end end end |