ComSquare::CPU::CPU Class Reference

The main CPU. More...

`#include <CPU.hpp>`

Inheritance diagram for ComSquare::CPU::CPU:
Collaboration diagram for ComSquare::CPU::CPU:

## Public Member Functions

| CPU (std::shared_ptr< Memory::MemoryBus > bus)
int | update ()
| This function continue to execute the Cartridge code. More...
uint8_t | read (uint24_t addr) override
| Read from the internal CPU register. More...
void | write (uint24_t addr, uint8_t data) override
| Write data to the internal CPU register. More...
Public Member Functions inherited from ComSquare::Memory::IMemory
void | setMemoryRegion (uint24_t start, uint24_t end)
| Change starting and ending points of this mapped memory. More...
virtual bool | hasMemoryAt (uint24_t addr)
| Return true if this component has mapped the address. More...
virtual uint24_t | getStart ()
| Get the first address mapped to this component. More...

## Private Member Functions

int | executeInstruction ()
| Execute a single instruction. More...

## Private Attributes

Registers | _registers {}
| All the registers of the CPU. More...
bool | _isEmulationMode = true
| Is the CPU running in emulation mode (in 8bits) More...
InternalRegisters | _internalRegisters {}
| Internal registers of the CPU (accessible from the bus via addr $4200 to $421F). More...
std::shared_ptr< Memory::MemoryBus > | _bus
| The memory bus to use for read/write. More...

## Detailed Description

The main CPU.

## Constructor & Destructor Documentation

## CPU()

ComSquare::CPU::CPU::CPU | ( | std::shared_ptr< Memory::MemoryBus > | bus | ) |

explicit

## Member Function Documentation

## executeInstruction()

int ComSquare::CPU::CPU::executeInstruction | ( |  | ) |

private

Execute a single instruction.

Returns
  The number of CPU cycles that the instruction took.

## read()

uint8_t ComSquare::CPU::CPU::read | ( | uint24_t | addr | ) |

overridevirtual

Read from the internal CPU register.

@bref The CPU's internal registers starts at $4200 and finish at $421F.

Parameters

  addr | The address to read from. The address 0x0 should refer to the first byte of the register.

Exceptions

  InvalidAddress | will be thrown if the address is more than $1F (the number of register).

Returns
  Return the value of the register.

Implements ComSquare::Memory::IMemory.

## update()

int ComSquare::CPU::CPU::update | ( |  | ) |

This function continue to execute the Cartridge code.

Returns
  The number of CPU cycles that elapsed

## write()

void ComSquare::CPU::CPU::write | ( | uint24_t | addr,
|  | uint8_t | data
| ) |  |

overridevirtual

Write data to the internal CPU register.

Parameters

  addr | The address to write to. The address 0x0 should refer to the first byte of register.
  data | The new value of the register.

Exceptions

  InvalidAddress | will be thrown if the address is more than $1F (the number of register).

Implements ComSquare::Memory::IMemory.

## Member Data Documentation

## _bus

std::shared_ptr<Memory::MemoryBus> ComSquare::CPU::CPU::_bus

private

The memory bus to use for read/write.

## _internalRegisters

InternalRegisters ComSquare::CPU::CPU::_internalRegisters {}

private

Internal registers of the CPU (accessible from the bus via addr $4200 to $421F).

## _isEmulationMode

bool ComSquare::CPU::CPU::_isEmulationMode = true

private

Is the CPU running in emulation mode (in 8bits)

## _registers

Registers ComSquare::CPU::CPU::_registers {}

private

All the registers of the CPU.

The documentation for this class was generated from the following files:

- sources/CPU/CPU.hpp
- sources/CPU/CPU.cpp