Skip to content

AddressingMode

INCLUDE FILE
#include "AddressingMode.h"

class AddressingMode

Represents an addressing mode, which defines how an instruction's operands are specified and encoded.

DEFINITION
class AddressingMode;

class Argument

Represents an argument for the instruction, which can have a specific type and an optional default value.

DEFINITION
class Argument;

constructor Argument

Default constructor for Argument.

DEFINITION
Argument ( );

constructor Argument

Initialize an argument with a specific type and an optional default value.

DEFINITION
Argument ( const ArgumentType * type,
std::optional< Value >  default_value = {} );
PARAMETERDESCRIPTION
type

The type of the argument.

default_value

The optional default value of the argument.

member default_value

The optional default value of the argument.

DEFINITION
std::optional< Value >  default_value;

member type

The type of the argument.

DEFINITION
const ArgumentType * type;

class Notation

Represents a notation for an instruction, which defines the syntax of the instruction.

It includes a sequence of punctuation, reserved words, and arguments.

DEFINITION
class Notation;

class Element

Represents an element in the notation, which can be punctuation, reserved word, or argument.

DEFINITION
class Element;
constructor Element

Initialize an element in the notation with a specific type and symbol.

DEFINITION
Element ( Type  type,
Symbol  symbol );
PARAMETERDESCRIPTION
type

The type of the element.

symbol

The symbol corresponding to the element, or the name of the argument.

method is_argumentconst

Check if the element is an argument.

DEFINITION
bool  is_argument ( ) const;
RETURNSDESCRIPTION
bool

true if the element is an argument, false otherwise.

member symbol

The symbol corresponding to the element, or the name of the argument.

DEFINITION
Symbol  symbol;
member type

The type of the element.

DEFINITION
Type  type;

enum Type

The type of an element in the notation.

DEFINITION
enum Type;
VALUEDESCRIPTION
ARGUMENT

The element is an argument, corresponding to an operand of the instruction.

PUNCTUATION

The element is punctuation.

RESERVED_WORD

The element is a reserved word.

method compute_argument_names

Compute the names of the arguments in the notation.

This method populates the argument_names vector based on the elements in the notation.

DEFINITION
void  compute_argument_names ( );

member argument_names

The names of the arguments in the notation, in order.

DEFINITION
std::vector< Symbol >  argument_names;

member elements

The elements that make up the notation.

DEFINITION
std::vector< Element >  elements;

method add_notation

Add a notation to the addressing mode.

DEFINITION
void  add_notation ( Notation  notation );
PARAMETERDESCRIPTION
notation

The notation to add.

method argumentconst

Get the argument with the specified name.

DEFINITION
const Argument * argument ( Symbol  name ) const;
PARAMETERDESCRIPTION
name

The name of the argument.

RETURNSDESCRIPTION
const Argument *

A pointer to the argument if it exists, nullptr otherwise.

method has_argumentconst

Check if the instruction has an argument with the specified name.

DEFINITION
bool  has_argument ( Symbol  name ) const;
PARAMETERDESCRIPTION
name

The name of the argument.

RETURNSDESCRIPTION
bool

true if it has an argument with the specified name, false otherwise.

method operator<const

Compare two addressing modes based on their priority.

DEFINITION
bool  operator< ( const AddressingMode & other ) const;
PARAMETERDESCRIPTION
other

The other addressing mode to compare with.

RETURNSDESCRIPTION
bool

true if this addressing mode has a lower priority than the other, false otherwise.

member arguments

The arguments of the addressing mode.

DEFINITION
std::unordered_map< Symbol, std::unique_ptr< Argument > >  arguments;

member encoding

The encoding of the addressing mode.

DEFINITION
Body  encoding;

member notations

The notations that define the syntax of instructions with this addressing mode.

DEFINITION
std::vector< Notation >  notations;

member priority

The priority of the addressing mode, which determines the order in which addressing modes are considered.

DEFINITION
size_t  priority;

member uses_pc

Indicates whether the addressing mode uses the program counter (PC) in its encoding.

DEFINITION
bool  uses_pc;

class Argument

Represents an argument for the instruction, which can have a specific type and an optional default value.

DEFINITION
class Argument;

constructor Argument

Default constructor for Argument.

DEFINITION
Argument ( );

constructor Argument

Initialize an argument with a specific type and an optional default value.

DEFINITION
Argument ( const ArgumentType * type,
std::optional< Value >  default_value = {} );
PARAMETERDESCRIPTION
type

The type of the argument.

default_value

The optional default value of the argument.

member default_value

The optional default value of the argument.

DEFINITION
std::optional< Value >  default_value;

member type

The type of the argument.

DEFINITION
const ArgumentType * type;

class Notation

Represents a notation for an instruction, which defines the syntax of the instruction.

It includes a sequence of punctuation, reserved words, and arguments.

DEFINITION
class Notation;

class Element

Represents an element in the notation, which can be punctuation, reserved word, or argument.

DEFINITION
class Element;

constructor Element

Initialize an element in the notation with a specific type and symbol.

DEFINITION
Element ( Type  type,
Symbol  symbol );
PARAMETERDESCRIPTION
type

The type of the element.

symbol

The symbol corresponding to the element, or the name of the argument.

method is_argumentconst

Check if the element is an argument.

DEFINITION
bool  is_argument ( ) const;
RETURNSDESCRIPTION
bool

true if the element is an argument, false otherwise.

member symbol

The symbol corresponding to the element, or the name of the argument.

DEFINITION
Symbol  symbol;

member type

The type of the element.

DEFINITION
Type  type;

enum Type

The type of an element in the notation.

DEFINITION
enum Type;
VALUEDESCRIPTION
ARGUMENT

The element is an argument, corresponding to an operand of the instruction.

PUNCTUATION

The element is punctuation.

RESERVED_WORD

The element is a reserved word.

method compute_argument_names

Compute the names of the arguments in the notation.

This method populates the argument_names vector based on the elements in the notation.

DEFINITION
void  compute_argument_names ( );

member argument_names

The names of the arguments in the notation, in order.

DEFINITION
std::vector< Symbol >  argument_names;

member elements

The elements that make up the notation.

DEFINITION
std::vector< Element >  elements;

class Element

Represents an element in the notation, which can be punctuation, reserved word, or argument.

DEFINITION
class Element;

constructor Element

Initialize an element in the notation with a specific type and symbol.

DEFINITION
Element ( Type  type,
Symbol  symbol );
PARAMETERDESCRIPTION
type

The type of the element.

symbol

The symbol corresponding to the element, or the name of the argument.

method is_argumentconst

Check if the element is an argument.

DEFINITION
bool  is_argument ( ) const;
RETURNSDESCRIPTION
bool

true if the element is an argument, false otherwise.

member symbol

The symbol corresponding to the element, or the name of the argument.

DEFINITION
Symbol  symbol;

member type

The type of the element.

DEFINITION
Type  type;