Class: Amaterasu::GameBoy::Cpu::Instructions::Rst
- Defined in:
- lib/amaterasu/game_boy/cpu/instructions/rst.rb,
sig/akane/game_boy/cpu/instructions/rst.rbs
Overview
Holds the logic of all the RST instructions.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(cpu:, vector:) ⇒ Rst
constructor
Creates a Call instruction object with a mnemonic and logic to be executed.
-
#rst(vector) ⇒ void
This is essentially a CALL, but jumps to a fixed address vector.
Methods inherited from Base
Constructor Details
#initialize(cpu:, vector:) ⇒ Rst
Creates a Call instruction object with a mnemonic and logic to be executed.
10 11 12 13 14 15 |
# File 'lib/amaterasu/game_boy/cpu/instructions/rst.rb', line 10 def initialize(cpu:, vector:) super(cpu:) @mnemonic = "RST $#{format('%02X', vector)}" @logic = -> { rst(vector) } end |
Instance Method Details
#rst(vector) ⇒ void
This method returns an undefined value.
This is essentially a CALL, but jumps to a fixed address vector.
M-cycle 1: Fetches opcode. M-cycle 2: Stores the msb of the PC into the Stack. M-cycle 3: Stores the lsb of the PC into the Stack. M-cycle 4: Jumps to a fixed address vector.
25 26 27 28 |
# File 'lib/amaterasu/game_boy/cpu/instructions/rst.rb', line 25 def rst(vector) @cpu.stack_push(value: @registers.pc) @cpu.jump_to(address: vector) end |