contur2
Loading...
Searching...
No Matches
contur::RegisterFile Class Reference

The CPU's register bank — holds REGISTER_COUNT (16) registers. More...

#include <register_file.h>

Public Member Functions

 RegisterFile ()
 ~RegisterFile ()
 RegisterFile (const RegisterFile &)=delete
RegisterFileoperator= (const RegisterFile &)=delete
 RegisterFile (RegisterFile &&) noexcept
RegisterFileoperator= (RegisterFile &&) noexcept
RegisterValue get (Register reg) const noexcept
 Gets the value of the specified register.
RegisterValue get (std::uint8_t index) const noexcept
 Gets the value of a register by raw index.
void set (Register reg, RegisterValue value) noexcept
 Sets the value of the specified register.
void set (std::uint8_t index, RegisterValue value) noexcept
 Sets the value of a register by raw index.
RegisterValue pc () const noexcept
 Convenience accessor for the Program Counter.
void setPc (RegisterValue value) noexcept
 Sets the Program Counter.
RegisterValue sp () const noexcept
 Convenience accessor for the Stack Pointer.
void setSp (RegisterValue value) noexcept
 Sets the Stack Pointer.
void reset () noexcept
 Resets all registers to zero.
std::array< RegisterValue, REGISTER_COUNTsnapshot () const noexcept
 Returns a snapshot of all register values as an array. Used for context switching (save/restore).
void restore (const std::array< RegisterValue, REGISTER_COUNT > &values) noexcept
 Restores register values from a previously taken snapshot.
std::string dump () const
 Returns a formatted string showing all register values.

Private Attributes

std::unique_ptr< Impl > impl_

Friends

std::ostream & operator<< (std::ostream &os, const RegisterFile &rf)
 Stream output operator for debug printing.

Detailed Description

The CPU's register bank — holds REGISTER_COUNT (16) registers.

Provides safe access by Register enum or raw index, bulk save/restore (for context switching), and formatted debug output.

Definition at line 49 of file register_file.h.

Constructor & Destructor Documentation

◆ RegisterFile() [1/3]

contur::RegisterFile::RegisterFile ( )

◆ ~RegisterFile()

contur::RegisterFile::~RegisterFile ( )

◆ RegisterFile() [2/3]

contur::RegisterFile::RegisterFile ( const RegisterFile & )
delete

◆ RegisterFile() [3/3]

contur::RegisterFile::RegisterFile ( RegisterFile && )
noexcept

Member Function Documentation

◆ dump()

std::string contur::RegisterFile::dump ( ) const
nodiscard

Returns a formatted string showing all register values.

◆ get() [1/2]

RegisterValue contur::RegisterFile::get ( Register reg) const
nodiscardnoexcept

Gets the value of the specified register.

◆ get() [2/2]

RegisterValue contur::RegisterFile::get ( std::uint8_t index) const
nodiscardnoexcept

Gets the value of a register by raw index.

Precondition
index < REGISTER_COUNT

◆ operator=() [1/2]

RegisterFile & contur::RegisterFile::operator= ( const RegisterFile & )
delete

◆ operator=() [2/2]

RegisterFile & contur::RegisterFile::operator= ( RegisterFile && )
noexcept

◆ pc()

RegisterValue contur::RegisterFile::pc ( ) const
nodiscardnoexcept

Convenience accessor for the Program Counter.

◆ reset()

void contur::RegisterFile::reset ( )
noexcept

Resets all registers to zero.

◆ restore()

void contur::RegisterFile::restore ( const std::array< RegisterValue, REGISTER_COUNT > & values)
noexcept

Restores register values from a previously taken snapshot.

◆ set() [1/2]

void contur::RegisterFile::set ( Register reg,
RegisterValue value )
noexcept

Sets the value of the specified register.

◆ set() [2/2]

void contur::RegisterFile::set ( std::uint8_t index,
RegisterValue value )
noexcept

Sets the value of a register by raw index.

Precondition
index < REGISTER_COUNT

◆ setPc()

void contur::RegisterFile::setPc ( RegisterValue value)
noexcept

Sets the Program Counter.

◆ setSp()

void contur::RegisterFile::setSp ( RegisterValue value)
noexcept

Sets the Stack Pointer.

◆ snapshot()

std::array< RegisterValue, REGISTER_COUNT > contur::RegisterFile::snapshot ( ) const
nodiscardnoexcept

Returns a snapshot of all register values as an array. Used for context switching (save/restore).

◆ sp()

RegisterValue contur::RegisterFile::sp ( ) const
nodiscardnoexcept

Convenience accessor for the Stack Pointer.

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const RegisterFile & rf )
friend

Stream output operator for debug printing.

Member Data Documentation

◆ impl_

std::unique_ptr<Impl> contur::RegisterFile::impl_
private

Definition at line 107 of file register_file.h.


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