Class: GBRb::CPU::Pop

Inherits:
Instruction show all
Defined in:
lib/gbrb/cpu/instruction.rb

Instance Attribute Summary

Attributes inherited from Instruction

#i, #m, #t

Instance Method Summary collapse

Methods inherited from Instruction

#carry?, #immediate_count

Constructor Details

#initialize(target, m = 1, t = 12) ⇒ Pop

Returns a new instance of Pop.



495
496
497
498
# File 'lib/gbrb/cpu/instruction.rb', line 495

def initialize target, m=1, t=12
  super m, t
  @targets = target.to_s.chars.map{|a| a.to_sym}.reverse
end

Instance Method Details

#call(r, mem) ⇒ Object



500
501
502
503
504
505
# File 'lib/gbrb/cpu/instruction.rb', line 500

def call r, mem
  @targets.each do |target|
    r.public_send(target).store mem.read_byte(r.sp.read)
    r.sp.store r.sp.read + 1
  end
end