Class: GBRb::InstructionSet::Rst

Inherits:
Instruction show all
Defined in:
lib/gbrb/instruction_set/rst.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(offset) ⇒ Rst

Returns a new instance of Rst.



5
6
7
8
# File 'lib/gbrb/instruction_set/rst.rb', line 5

def initialize offset
  @offset = offset
  super 1, 16
end

Instance Method Details

#call(r, mem) ⇒ Object



10
11
12
13
14
# File 'lib/gbrb/instruction_set/rst.rb', line 10

def call r, mem
  r.sp.store r.sp.read - 2
  mem.write_word r.sp.read, r.pc.read
  r.pc.store 0x0000 + @offset
end