Skip to content

Commit

Permalink
Move the definitions of data_register and address register into class…
Browse files Browse the repository at this point in the history
… execution_context
  • Loading branch information
kazssym committed Dec 28, 2020
1 parent 713757f commit 9ce1726
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 89 deletions.
179 changes: 90 additions & 89 deletions libvm68k/bits/vm68k/execution_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,106 +28,107 @@

namespace vm68k
{
/**
* Data registers.
*/
class _VM68K_PUBLIC data_register
{
private:
long_word::uint_type _value;

public:
data_register &operator =(const long_word value)
{
_value = value.to_uint();
return *this;
}

data_register &operator =(const word value)
{
auto unchanged = _value & 0xffff0000U;
_value = unchanged | value.to_uint();
return *this;
}

data_register &operator =(const byte value)
{
auto unchanged = _value & 0xffffff00U;
_value = unchanged | value.to_uint();
return *this;
}

public:
/**
* Converts the register value to a long word.
*/
operator long_word() const noexcept
{
return long_word(_value);
}

/**
* Converts the register value to a word.
*/
operator word() const noexcept
{
return word(_value);
}

/**
* Converts the register value to a byte.
*/
operator byte() const noexcept
{
return byte(_value);
}
};

/**
* Address registers.
/*
* Execution contexts.
*/
class _VM68K_PUBLIC address_register
class _VM68K_PUBLIC execution_context
{
private:
long_word::uint_type _value;

public:
address_register &operator =(const long_word value)
{
_value = value.to_int();
return *this;
}

address_register &operator =(const word value)
{
// Word assignments shall be sign-extended.
_value = value.to_int();
return *this;
}

public:
/**
* Converts the register value to a long word.
* Data registers.
*/
operator long_word() const noexcept
class data_register
{
return long_word(_value);
}
private:
long_word::uint_type _value;

public:
data_register &operator =(const long_word value)
{
_value = value.to_uint();
return *this;
}

data_register &operator =(const word value)
{
auto unchanged = _value & 0xffff0000U;
_value = unchanged | value.to_uint();
return *this;
}

data_register &operator =(const byte value)
{
auto unchanged = _value & 0xffffff00U;
_value = unchanged | value.to_uint();
return *this;
}

public:
/**
* Converts the register value to a long word.
*/
operator long_word() const noexcept
{
return long_word(_value);
}

/**
* Converts the register value to a word.
*/
operator word() const noexcept
{
return word(_value);
}

/**
* Converts the register value to a byte.
*/
operator byte() const noexcept
{
return byte(_value);
}
};

/**
* Converts the register value to a word.
* Address registers.
*/
operator word() const noexcept
class address_register
{
return word(_value);
}
};
private:
long_word::uint_type _value;

public:
address_register &operator =(const long_word value)
{
_value = value.to_int();
return *this;
}

address_register &operator =(const word value)
{
// Word assignments shall be sign-extended.
_value = value.to_int();
return *this;
}

public:
/**
* Converts the register value to a long word.
*/
operator long_word() const noexcept
{
return long_word(_value);
}

/**
* Converts the register value to a word.
*/
operator word() const noexcept
{
return word(_value);
}
};

/*
* Execution contexts.
*/
class _VM68K_PUBLIC execution_context
{
public:
/**
* Number of the data registers.
Expand Down
3 changes: 3 additions & 0 deletions libvm68k/execution_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ using std::shared_ptr;
using std::swap;
using namespace vm68k;

using data_register = execution_context::data_register;
using address_register = execution_context::address_register;


// Implementation of class execution_context.

Expand Down

0 comments on commit 9ce1726

Please sign in to comment.