Class: GBRb::InstructionSet::Push

Inherits:
Instruction show all
Defined in:
lib/gbrb/instruction_set/stack.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 = 4, t = 16) ⇒ Push

Returns a new instance of Push.



22
23
24
25
# File 'lib/gbrb/instruction_set/stack.rb', line 22

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

Instance Method Details

#call(r, mem) ⇒ Object



27
28
29
30
31
32
# File 'lib/gbrb/instruction_set/stack.rb', line 27

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