Class: GBRb::InstructionSet::Push
- Inherits:
-
Instruction
- Object
- Instruction
- GBRb::InstructionSet::Push
- Defined in:
- lib/gbrb/instruction_set/stack.rb
Instance Attribute Summary
Attributes inherited from Instruction
Instance Method Summary collapse
- #call(r, mem) ⇒ Object
-
#initialize(target, m = 4, t = 16) ⇒ Push
constructor
A new instance of Push.
Methods inherited from Instruction
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 |