src/cpu/cpu.cc
/*
 * Fetches the next instruction to be executing, storing brk instead
 * if an interrupt should be started. Adjusts the PC as necessary, since
 * interrupts do not increment it.
 */
Fetches the next instruction to be executing, storing brk instead
if an interrupt should be started. Adjusts the PC as necessary, since
interrupts do not increment it.
Fetches the next instruction to be executing storing brk instead if an interrupt should be started . Adjusts the PC as necessary since interrupts do not increment it .
void Cpu::Fetch(CpuOperation &op) {
  if (!nmi_edge_ && !irq_ready_) {
    regs_->inst = memory_->Read(READ_ADDR_REG(REG_PCL, 0));
    current_sequence_ = &code_table_[regs_->inst * kInstSequenceSize_];
    if (current_sequence_[0] == 0) {
      fprintf(stderr, "Error: Fetch obtained unimplemented instruction %02x",
              regs_->inst);
      abort();
    }
  } else {
    regs_->inst = INST_BRK;
    op &= (~PC_INC);
    if (nmi_edge_) {
      nmi_edge_ = false;
      irq_ready_ = false;
      current_sequence_ = &code_table_[EINST_NMI * kInstSequenceSize_];
    } else {
      irq_ready_ = false;
      current_sequence_ = &code_table_[EINST_IRQ * kInstSequenceSize_];
    }
  }
  inst_pointer_ = 0;
  return;
}
void Cpu :: Fetch ( CpuOperation & op ) { if ( ! nmi_edge_ && ! irq_ready_ ) { regs_ -> inst = memory_ -> Read ( READ_ADDR_REG ( REG_PCL , 0 ) ) ; current_sequence_ = & code_table_ [ regs_ -> inst * kInstSequenceSize_ ] ; if ( current_sequence_ [ 0 ] == 0 ) { fprintf ( stderr , " " , regs_ -> inst ) ; abort ( ) ; } } else { regs_ -> inst = INST_BRK ; op &= ( ~ PC_INC ) ; if ( nmi_edge_ ) { nmi_edge_ = false ; irq_ready_ = false ; current_sequence_ = & code_table_ [ EINST_NMI * kInstSequenceSize_ ] ; } else { irq_ready_ = false ; current_sequence_ = & code_table_ [ EINST_IRQ * kInstSequenceSize_ ] ; } } inst_pointer_ = 0 ; return ; }
Fetches the next instruction to be executing, storing brk instead
 if an interrupt should be started.
Fetches the next instruction to be executing storing brk instead if an interrupt should be started .
// Fetch the next instruction to the instruction register. // Read the inst from the PC, then decode it using the code table. // Ensure that the instruction loaded was not illegal. // In the code table, no valid instruction begins with a NOP. // All interrupts fill the instruction register with 0x00 (BRK). // Interrupts should not increment the PC. // Decode the interrupt from the code table. // Reset the index in the microcode sequence.