/*
Copyright (C) 2006 - 2009 Evan Teran
                   eteran@alum.rit.edu

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#ifndef REX_20071217_H_
#define REX_20071217_H_

#include "edisassm_types.h"

class REX {
public:
	REX(uint8_t value) : m_Value(value) {}
	REX(const REX &other) : m_Value(other.m_Value) {}
	REX &operator=(const REX &rhs) { m_Value = rhs.m_Value; return *this;}
public:
	union {
		struct {
		uint8_t B		: 1,
				X		: 1,
				R		: 1,
				W 		: 1,
				Rex		: 4;
		} m_Bits;

		uint8_t m_Value;
	};
public:
	bool isREX() const	{ return m_Bits.Rex == 0x04; }
	uint8_t w() const	{ return m_Bits.W; }	// 64 bit mode
	uint8_t r() const	{ return m_Bits.R; }	// modRM extention
	uint8_t x() const	{ return m_Bits.X; }	// SIB extention
	uint8_t b() const	{ return m_Bits.B; }	// ModRM OR SIB base or Opcode Reg extention
};

#endif

