contur2
Loading...
Searching...
No Matches

A single memory cell in the simulated architecture. More...

#include <block.h>

Public Member Functions

constexpr Block () noexcept=default
 Default-constructs a Nop block.
constexpr Block (Instruction code, std::uint8_t reg, std::int32_t operand, std::int32_t state=0) noexcept
 Constructs a block with all fields specified.
constexpr bool operator== (const Block &other) const noexcept
 Equality comparison.
constexpr bool operator!= (const Block &other) const noexcept
 Inequality comparison.

Public Attributes

Instruction code = Instruction::Nop
 Instruction opcode.
std::uint8_t reg = 0
 Target/source register index.
std::int32_t operand = 0
 Immediate value or address.
std::int32_t state = 0
 Auxiliary state / flags.

Detailed Description

A single memory cell in the simulated architecture.

Blocks serve dual purpose:

  • In the code segment: they represent instructions (opcode + operands)
  • In the data segment: the operand field stores data values

This is a lightweight value type (Flyweight pattern) — designed to be stored in large arrays efficiently.

Definition at line 25 of file block.h.

Constructor & Destructor Documentation

◆ Block() [1/2]

contur::Block::Block ( )
constexprdefaultnoexcept

Default-constructs a Nop block.

◆ Block() [2/2]

contur::Block::Block ( Instruction code,
std::uint8_t reg,
std::int32_t operand,
std::int32_t state = 0 )
inlineconstexprnoexcept

Constructs a block with all fields specified.

Definition at line 36 of file block.h.

Member Function Documentation

◆ operator!=()

bool contur::Block::operator!= ( const Block & other) const
inlinenodiscardconstexprnoexcept

Inequality comparison.

Definition at line 50 of file block.h.

◆ operator==()

bool contur::Block::operator== ( const Block & other) const
inlinenodiscardconstexprnoexcept

Equality comparison.

Definition at line 44 of file block.h.

Member Data Documentation

◆ code

Instruction contur::Block::code = Instruction::Nop

Instruction opcode.

Definition at line 27 of file block.h.

◆ operand

std::int32_t contur::Block::operand = 0

Immediate value or address.

Definition at line 29 of file block.h.

◆ reg

std::uint8_t contur::Block::reg = 0

Target/source register index.

Definition at line 28 of file block.h.

◆ state

std::int32_t contur::Block::state = 0

Auxiliary state / flags.

Definition at line 30 of file block.h.


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