fcml  1.1.1
fcml_common.hpp
Go to the documentation of this file.
1 /*
2  * FCML - Free Code Manipulation Library.
3  * Copyright (C) 2010-2015 Slawomir Wojtasiak
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
27 #ifndef FCML_COMMON_HPP_
28 #define FCML_COMMON_HPP_
29 
30 #include <stdlib.h>
31 #include <string.h>
32 #include <new>
33 #include <iostream>
34 #include <sstream>
35 #include <stdexcept>
36 #include <memory>
37 #include <vector>
38 
39 #include "fcml_types.h"
40 #include "fcml_common.h"
41 #include "fcml_common_utils.h"
42 #include "fcml_errors.h"
43 
44 namespace fcml {
45 
46 #define FCML_TO_CPP_BOOL( x ) ( (x) ? true : false )
47 
53 typedef std::basic_string<fcml_char> fcml_cstring;
54 
59 typedef std::basic_ostringstream<fcml_char> fcml_costream;
60 
68 class Env {
69 public:
74  static fcml_string strDup( const fcml_string str ) {
75  if ( !str ) {
76  return NULL;
77  }
78 #if defined(FCML_MSCC)
79  fcml_string newStr = _strdup( str );
80 #else
81  fcml_string newStr = strdup( str );
82 #endif
83  if ( !newStr ) {
84  throw std::bad_alloc();
85  }
86  return newStr;
87  }
88  static void strFree( fcml_string str ) {
89  free( str );
90  }
91 };
92 
97 template <typename T>
98 class Iterator {
99 public:
100 
101  Iterator() {}
102 
103  virtual ~Iterator() {}
104 
108  virtual bool hasNext() = 0;
109 
113  virtual T next() = 0;
114 };
115 
119 template<typename T>
120 class Nullable {
121 public:
122 
123  Nullable( const T& value, bool is_not_null = false ) :
124  _value( value ), _is_not_null( is_not_null ) {
125  }
126 
127  Nullable() :
128  _is_not_null( false ) {
129  }
130 
131  bool isNotNull() const {
132  return _is_not_null;
133  }
134 
135  void setNotNull(bool isNull) {
136  _is_not_null = isNull;
137  }
138 
139  T getValue() const {
140  return _value;
141  }
142 
143  T& getValue() {
144  return _value;
145  }
146 
147  void setValue(const T& value) {
148  this->_value = value;
149  }
150 
151 private:
153  T _value;
155  bool _is_not_null;
156 };
157 
163 public:
165  this->_error = error;
166  }
167  BaseException( const fcml_cstring &msg, fcml_ceh_error error = FCML_CEH_GEC_NO_ERROR ) {
168  this->_msg = msg;
169  this->_error = error;
170  }
171  BaseException( const BaseException &cpy ) {
172  this->_msg = cpy._msg;
173  this->_error = cpy._error;
174  }
175  virtual ~BaseException() {
176  }
177  BaseException& operator=( const BaseException &exc ) {
178  if ( &exc != this ) {
179  this->_msg = exc._msg;
180  this->_error = exc._error;
181  }
182  return *this;
183  }
184 public:
185  const fcml_cstring getMsg() const {
186  return _msg;
187  }
188  const fcml_ceh_error& getError() const {
189  return _error;
190  }
191 private:
192  void* operator new( size_t size ) {
193  return ::operator new( size );
194  }
195 private:
197  fcml_cstring _msg;
199  fcml_ceh_error _error;
200 };
201 
207 public:
208  InitException( const fcml_cstring &msg, fcml_ceh_error error = FCML_CEH_GEC_NO_ERROR ) :
209  BaseException( msg, error ) {
210  }
211 };
212 
218 public:
219  BadArgumentException( const fcml_cstring &msg, fcml_ceh_error error = FCML_CEH_GEC_NO_ERROR ) :
220  BaseException( msg, error ) {
221  }
222 };
223 
229 public:
230  IllegalStateException( const fcml_cstring &msg, fcml_ceh_error error = FCML_CEH_GEC_NO_ERROR ) :
231  BaseException( msg, error ) {
232  }
233 };
234 
240 public:
241  IllegalArgumentException( const fcml_cstring &msg, fcml_ceh_error error = FCML_CEH_GEC_NO_ERROR ) :
242  BaseException( msg, error ) {
243  }
244 };
245 
251 public:
252  OperationNotSupportedException( const fcml_cstring &msg ) :
253  BaseException( msg ) {
254  }
256  }
257 };
258 
263 class NonCopyable {
264 protected:
265  NonCopyable() {
266  }
267 private:
271  NonCopyable( const NonCopyable &cpy ) {
273  }
277  NonCopyable& operator=( const NonCopyable &exc ) {
279  }
280 };
281 
288 private:
294  static InstructionPrefix create( fcml_prefixes prefix ) {
295  InstructionPrefix instructionPrefix;
296  instructionPrefix._prefix = prefix;
297  return instructionPrefix;
298  }
299 public:
304  static const InstructionPrefix LOCK() {
305  return create(FCML_PREFIX_LOCK);
306  }
311  static const InstructionPrefix REPNE() {
312  return create(FCML_PREFIX_REPNE);
313  }
318  static const InstructionPrefix REPNZ() {
319  return create(FCML_PREFIX_REPNZ);
320  }
325  static const InstructionPrefix REP() {
326  return create(FCML_PREFIX_REP);
327  }
332  static const InstructionPrefix REPE() {
333  return create(FCML_PREFIX_REPE);
334  }
339  static const InstructionPrefix REPZ() {
340  return create(FCML_PREFIX_REPZ);
341  }
346  static const InstructionPrefix XACQUIRE() {
347  return create(FCML_PREFIX_XACQUIRE);
348  }
353  static const InstructionPrefix XRELEASE() {
354  return create(FCML_PREFIX_XRELEASE);
355  }
361  return create(FCML_PREFIX_BRANCH_HINT);
362  }
368  return create(FCML_PREFIX_NOBRANCH_HINT);
369  }
370 public:
371  fcml_prefixes _prefix;
372 };
373 
378 private:
384  _hint(hints) {
385  }
386 public:
391  static const InstructionHint NO_HINTS() {
393  }
398  static const InstructionHint NEAR_POINTER() {
400  }
405  static const InstructionHint FAR_POINTER() {
407  }
414  }
421  }
428  }
429 public:
431 };
432 
436 struct OperandHint {
437 private:
439  _hint(hint) {
440  }
441 public:
446  static const OperandHint UNDEFIEND() {
448  }
453  static const OperandHint MULTIMEDIA() {
455  }
462  }
467  static const OperandHint PSEUDO_OPCODE() {
469  }
476  }
483  }
488  static const OperandHint SIB_ENCODING() {
490  }
491 public:
492  fcml_en_operand_hints _hint;
493 };
494 
499 class EntryPoint {
500 public:
501 
507  OM_16_BIT = FCML_OM_16_BIT,
508  OM_32_BIT = FCML_OM_32_BIT,
509  OM_64_BIT = FCML_OM_64_BIT
510  };
511 
517  _opMode(OM_32_BIT),
518  _addressSizeAttribute(FCML_DS_32),
519  _operandSizeAttribute(FCML_DS_32),
520  _ip(0) {
521  }
522 
531  EntryPoint(OperatingMode opMode, fcml_ip ip = 0, fcml_usize addressSizeAttribute = FCML_DS_UNDEF, fcml_usize operandSizeAttribute = FCML_DS_UNDEF ) :
532  _opMode(opMode),
533  _addressSizeAttribute(addressSizeAttribute),
534  _operandSizeAttribute(operandSizeAttribute),
535  _ip(ip) {
536  }
537 
538  virtual ~EntryPoint() {
539  }
540 
541 public:
542 
550  bool operator==( const EntryPoint &ep ) const {
551  return _opMode == ep._opMode &&
552  _ip == ep._ip &&
553  _operandSizeAttribute == ep._operandSizeAttribute &&
554  _addressSizeAttribute == ep._addressSizeAttribute;
555  }
556 
564  bool operator!=( const EntryPoint &ep ) const {
565  return !(ep == *this);
566  }
567 
568 public:
569 
576  fcml_usize getAddressSizeAttribute() const {
577  return _addressSizeAttribute;
578  }
579 
586  void setAddressSizeAttribute( fcml_usize addressSizeAttribute ) {
587  _addressSizeAttribute = addressSizeAttribute;
588  }
589 
596  fcml_usize getOperandSizeAttribute() const {
597  return _operandSizeAttribute;
598  }
599 
606  void setOperandSizeAttribute( fcml_usize operandSizeAttribute ) {
607  _operandSizeAttribute = operandSizeAttribute;
608  }
609 
616  fcml_ip getIP() const {
617  return _ip;
618  }
619 
626  void setIP( fcml_ip ip ) {
627  _ip = ip;
628  }
629 
637  return _opMode;
638  }
639 
646  void setOpMode( OperatingMode opMode ) {
647  _opMode = opMode;
648  }
649 
656  void incrementIP( fcml_ip ip ) {
657  _ip += ip;
658  }
659 
660 private:
662  OperatingMode _opMode;
664  fcml_usize _addressSizeAttribute;
666  fcml_usize _operandSizeAttribute;
668  fcml_ip _ip;
669 };
670 
675 class Integer {
676 public:
677 
680  _size( FCML_DS_64 ), _isSigned( FCML_FALSE ), _vint8( 0 ), _vint16( 0 ), _vint32( 0 ), _vint64( 0 ) {
681  }
682 
684  Integer( fcml_int8_t value ) :
685  _size( FCML_DS_8 ), _isSigned( FCML_TRUE ), _vint8( value ), _vint16( 0 ), _vint32( 0 ), _vint64( 0 ) {
686  }
687 
689  Integer( fcml_int16_t value ) :
690  _size( FCML_DS_16 ), _isSigned( FCML_TRUE ), _vint8( 0 ), _vint16( value ), _vint32( 0 ), _vint64( 0 ) {
691  }
692 
694  Integer( fcml_int32_t value ) :
695  _size( FCML_DS_32 ), _isSigned( FCML_TRUE ), _vint8( 0 ), _vint16( 0 ), _vint32( value ), _vint64( 0 ) {
696  }
697 
699  Integer( fcml_int64_t value ) :
700  _size( FCML_DS_64 ), _isSigned( FCML_TRUE ), _vint8( 0 ), _vint16( 0 ), _vint32( 0 ), _vint64( value ) {
701  }
702 
704  Integer( fcml_uint8_t value ) :
705  _size( FCML_DS_8 ), _isSigned( FCML_FALSE ), _vint8( static_cast<fcml_uint8_t>( value ) ), _vint16( 0 ), _vint32( 0 ), _vint64( 0 ) {
706  }
707 
709  Integer( fcml_uint16_t value ) :
710  _size( FCML_DS_16 ), _isSigned( FCML_FALSE ), _vint8( 0 ), _vint16( static_cast<fcml_uint16_t>( value ) ), _vint32( 0 ), _vint64( 0 ) {
711  }
712 
714  Integer( fcml_uint32_t value ) :
715  _size( FCML_DS_32 ), _isSigned( FCML_FALSE ), _vint8( 0 ), _vint16( 0 ), _vint32( static_cast<fcml_uint32_t>( value ) ), _vint64( 0 ) {
716  }
717 
719  Integer( fcml_uint64_t value ) :
720  _size( FCML_DS_64 ), _isSigned( FCML_FALSE ), _vint8( 0 ), _vint16( 0 ), _vint32( 0 ), _vint64( static_cast<fcml_uint64_t>( value ) ) {
721  }
722 
724  virtual ~Integer() {
725  }
726 
727 public:
728 
730  fcml_int16_t getInt16() const {
731  return _vint16;
732  }
733 
735  Integer& setInt16( fcml_int16_t int16 ) {
736  _vint16 = int16;
737  return *this;
738  }
739 
741  fcml_int32_t getInt32() const {
742  return _vint32;
743  }
744 
746  Integer& setInt32( fcml_int32_t int32 ) {
747  _vint32 = int32;
748  return *this;
749  }
750 
752  fcml_int64_t getInt64() const {
753  return _vint64;
754  }
755 
757  Integer& setInt64( fcml_int64_t int64 ) {
758  _vint64 = int64;
759  return *this;
760  }
761 
763  fcml_int8_t getInt8() const {
764  return _vint8;
765  }
766 
768  Integer& setInt8( fcml_int8_t int8 ) {
769  _vint8 = int8;
770  return *this;
771  }
772 
774  fcml_bool isSigned() const {
775  return _isSigned;
776  }
777 
779  Integer& setSigned( fcml_bool isSigned ) {
780  _isSigned = isSigned;
781  return *this;
782  }
783 
785  fcml_usize getSize() const {
786  return _size;
787  }
788 
790  Integer& setSize( fcml_usize size ) {
791  _size = size;
792  return *this;
793  }
794 
802  bool operator==( const fcml_uint8_t value ) const {
803  return _isSigned ? static_cast<fcml_int64_t>( *this ) == static_cast<fcml_int64_t>( value ) : static_cast<fcml_uint64_t>( *this ) == static_cast<fcml_uint64_t>( value );
804  }
805 
813  bool operator==( const fcml_int8_t value ) const {
814  return _isSigned ? static_cast<fcml_int64_t>( *this ) == static_cast<fcml_int64_t>( value ) : static_cast<fcml_uint64_t>( *this ) == static_cast<fcml_uint64_t>( value );
815  }
816 
824  bool operator==( const fcml_uint16_t value ) const {
825  return _isSigned ? static_cast<fcml_int64_t>( *this ) == static_cast<fcml_int64_t>( value ) : static_cast<fcml_uint64_t>( *this ) == static_cast<fcml_uint64_t>( value );
826  }
827 
835  bool operator==( const fcml_int16_t value ) const {
836  return _isSigned ? static_cast<fcml_int64_t>( *this ) == static_cast<fcml_int64_t>( value ) : static_cast<fcml_uint64_t>( *this ) == static_cast<fcml_uint64_t>( value );
837  }
838 
846  bool operator==( const fcml_uint32_t value ) const {
847  return _isSigned ? static_cast<fcml_int64_t>( *this ) == static_cast<fcml_int64_t>( value ) : static_cast<fcml_uint64_t>( *this ) == static_cast<fcml_uint64_t>( value );
848  }
849 
857  bool operator==( const fcml_int32_t value ) const {
858  return _isSigned ? static_cast<fcml_int64_t>( *this ) == static_cast<fcml_int64_t>( value ) : static_cast<fcml_uint64_t>( *this ) == static_cast<fcml_uint64_t>( value );
859  }
860 
868  bool operator==( const fcml_uint64_t value ) const {
869  return _isSigned ? static_cast<fcml_int64_t>( *this ) == static_cast<fcml_int64_t>( value ) : static_cast<fcml_uint64_t>( *this ) == static_cast<fcml_uint64_t>( value );
870  }
871 
879  bool operator==( const fcml_int64_t value ) const {
880  return _isSigned ? static_cast<fcml_int64_t>( *this ) == static_cast<fcml_int64_t>( value ) : static_cast<fcml_uint64_t>( *this ) == static_cast<fcml_uint64_t>( value );
881  }
882 
890  bool operator==( const Integer &value ) const {
891  return _isSigned ? static_cast<fcml_int64_t>( *this ) == static_cast<fcml_int64_t>( value ) : static_cast<fcml_uint64_t>( *this ) == static_cast<fcml_uint64_t>( value );
892  }
893 
901  bool operator!=( const fcml_uint8_t value ) const {
902  return _isSigned ? static_cast<fcml_int64_t>( *this ) != static_cast<fcml_int64_t>( value ) : static_cast<fcml_uint64_t>( *this ) != static_cast<fcml_uint64_t>( value );
903  }
904 
912  bool operator!=( const fcml_int8_t value ) const {
913  return _isSigned ? static_cast<fcml_int64_t>( *this ) != static_cast<fcml_int64_t>( value ) : static_cast<fcml_uint64_t>( *this ) != static_cast<fcml_uint64_t>( value );
914  }
915 
923  bool operator!=( const fcml_uint16_t value ) const {
924  return _isSigned ? static_cast<fcml_int64_t>( *this ) != static_cast<fcml_int64_t>( value ) : static_cast<fcml_uint64_t>( *this ) != static_cast<fcml_uint64_t>( value );
925  }
926 
934  bool operator!=( const fcml_int16_t value ) const {
935  return _isSigned ? static_cast<fcml_int64_t>( *this ) != static_cast<fcml_int64_t>( value ) : static_cast<fcml_uint64_t>( *this ) != static_cast<fcml_uint64_t>( value );
936  }
937 
945  bool operator!=( const fcml_uint32_t value ) const {
946  return _isSigned ? static_cast<fcml_int64_t>( *this ) != static_cast<fcml_int64_t>( value ) : static_cast<fcml_uint64_t>( *this ) != static_cast<fcml_uint64_t>( value );
947  }
948 
956  bool operator!=( const fcml_int32_t value ) const {
957  return _isSigned ? static_cast<fcml_int64_t>( *this ) != static_cast<fcml_int64_t>( value ) : static_cast<fcml_uint64_t>( *this ) != static_cast<fcml_uint64_t>( value );
958  }
959 
967  bool operator!=( const fcml_uint64_t value ) const {
968  return _isSigned ? static_cast<fcml_int64_t>( *this ) != static_cast<fcml_int64_t>( value ) : static_cast<fcml_uint64_t>( *this ) != static_cast<fcml_uint64_t>( value );
969  }
970 
978  bool operator!=( const fcml_int64_t value ) const {
979  return _isSigned ? static_cast<fcml_int64_t>( *this ) != static_cast<fcml_int64_t>( value ) : static_cast<fcml_uint64_t>( *this ) != static_cast<fcml_uint64_t>( value );
980  }
981 
989  bool operator!=( const Integer &value ) const {
990  return _isSigned ? static_cast<fcml_int64_t>( *this ) != static_cast<fcml_int64_t>( value ) : static_cast<fcml_uint64_t>( *this ) != static_cast<fcml_uint64_t>( value );
991  }
992 
998  operator fcml_int8_t() const {
999  fcml_int8_t result;
1000  switch ( _size ) {
1001  case FCML_DS_8:
1002  result = static_cast<fcml_int8_t>( _isSigned ? _vint8 : (fcml_uint8_t)_vint8 );
1003  break;
1004  case FCML_DS_16:
1005  result = static_cast<fcml_int8_t>( _isSigned ? _vint16 : (fcml_uint16_t)_vint16 );
1006  break;
1007  case FCML_DS_32:
1008  result = static_cast<fcml_int8_t>( _isSigned ? _vint32 : (fcml_uint32_t)_vint32 );
1009  break;
1010  case FCML_DS_64:
1011  result = static_cast<fcml_int8_t>( _isSigned ? _vint64 : (fcml_uint64_t)_vint64 );
1012  break;
1013  default:
1014  throw BadArgumentException( FCML_TEXT( "Wrong size." ) );
1015  }
1016  return result;
1017  }
1023  operator fcml_uint8_t() const {
1024  fcml_uint8_t result;
1025  switch ( _size ) {
1026  case FCML_DS_8:
1027  result = static_cast<fcml_uint8_t>( _isSigned ? _vint8 : (fcml_uint8_t)_vint8 );
1028  break;
1029  case FCML_DS_16:
1030  result = static_cast<fcml_uint8_t>( _isSigned ? _vint16 : (fcml_uint16_t)_vint16 );
1031  break;
1032  case FCML_DS_32:
1033  result = static_cast<fcml_uint8_t>( _isSigned ? _vint32 : (fcml_uint32_t)_vint32 );
1034  break;
1035  case FCML_DS_64:
1036  result = static_cast<fcml_uint8_t>( _isSigned ? _vint64 : (fcml_uint64_t)_vint64 );
1037  break;
1038  default:
1039  throw BadArgumentException( FCML_TEXT( "Wrong size." ) );
1040  }
1041  return result;
1042  }
1043 
1049  operator fcml_int16_t() const {
1050  fcml_int16_t result;
1051  switch ( _size ) {
1052  case FCML_DS_8:
1053  result = static_cast<fcml_int16_t>( _isSigned ? _vint8 : (fcml_uint8_t)_vint8 );
1054  break;
1055  case FCML_DS_16:
1056  result = static_cast<fcml_int16_t>( _isSigned ? _vint16 : (fcml_uint16_t)_vint16 );
1057  break;
1058  case FCML_DS_32:
1059  result = static_cast<fcml_int16_t>( _isSigned ? _vint32 : (fcml_uint32_t)_vint32 );
1060  break;
1061  case FCML_DS_64:
1062  result = static_cast<fcml_int16_t>( _isSigned ? _vint64 : (fcml_uint64_t)_vint64 );
1063  break;
1064  default:
1065  throw BadArgumentException( FCML_TEXT( "Wrong size." ) );
1066  }
1067  return result;
1068  }
1069 
1075  operator fcml_uint16_t() const {
1076  fcml_uint16_t result;
1077  switch ( _size ) {
1078  case FCML_DS_8:
1079  result = static_cast<fcml_uint16_t>( _isSigned ? _vint8 : (fcml_uint8_t)_vint8 );
1080  break;
1081  case FCML_DS_16:
1082  result = static_cast<fcml_uint16_t>( _isSigned ? _vint16 : (fcml_uint16_t)_vint16 );
1083  break;
1084  case FCML_DS_32:
1085  result = static_cast<fcml_uint16_t>( _isSigned ? _vint32 : (fcml_uint32_t)_vint32 );
1086  break;
1087  case FCML_DS_64:
1088  result = static_cast<fcml_uint16_t>( _isSigned ? _vint64 : (fcml_uint64_t)_vint64 );
1089  break;
1090  default:
1091  throw BadArgumentException( FCML_TEXT( "Wrong size." ) );
1092  }
1093  return result;
1094  }
1095 
1101  operator fcml_int32_t() const {
1102  fcml_int32_t result;
1103  switch ( _size ) {
1104  case FCML_DS_8:
1105  result = static_cast<fcml_int32_t>( _isSigned ? _vint8 : (fcml_uint8_t)_vint8 );
1106  break;
1107  case FCML_DS_16:
1108  result = static_cast<fcml_int32_t>( _isSigned ? _vint16 : (fcml_uint16_t)_vint16 );
1109  break;
1110  case FCML_DS_32:
1111  result = static_cast<fcml_int32_t>( _isSigned ? _vint32 : (fcml_uint32_t)_vint32 );
1112  break;
1113  case FCML_DS_64:
1114  result = static_cast<fcml_int32_t>( _isSigned ? _vint64 : (fcml_uint64_t)_vint64 );
1115  break;
1116  default:
1117  throw BadArgumentException( FCML_TEXT( "Wrong size." ) );
1118  }
1119  return result;
1120  }
1121 
1127  operator fcml_uint32_t() const {
1128  fcml_uint32_t result;
1129  switch ( _size ) {
1130  case FCML_DS_8:
1131  result = static_cast<fcml_uint32_t>( _isSigned ? _vint8 : (fcml_uint8_t)_vint8 );
1132  break;
1133  case FCML_DS_16:
1134  result = static_cast<fcml_uint32_t>( _isSigned ? _vint16 : (fcml_uint16_t)_vint16 );
1135  break;
1136  case FCML_DS_32:
1137  result = static_cast<fcml_uint32_t>( _isSigned ? _vint32 : (fcml_uint32_t)_vint32 );
1138  break;
1139  case FCML_DS_64:
1140  result = static_cast<fcml_uint32_t>( _isSigned ? _vint64 : (fcml_uint64_t)_vint64 );
1141  break;
1142  default:
1143  throw BadArgumentException( FCML_TEXT( "Wrong size." ) );
1144  }
1145  return result;
1146  }
1147 
1153  operator fcml_int64_t() const {
1154  fcml_int64_t result;
1155  switch ( _size ) {
1156  case FCML_DS_8:
1157  result = static_cast<fcml_int64_t>( _isSigned ? _vint8 : (fcml_uint8_t)_vint8 );
1158  break;
1159  case FCML_DS_16:
1160  result = static_cast<fcml_int64_t>( _isSigned ? _vint16 : (fcml_uint16_t)_vint16 );
1161  break;
1162  case FCML_DS_32:
1163  result = static_cast<fcml_int64_t>( _isSigned ? _vint32 : (fcml_uint32_t)_vint32 );
1164  break;
1165  case FCML_DS_64:
1166  result = static_cast<fcml_int64_t>( _isSigned ? _vint64 : (fcml_uint64_t)_vint64 );
1167  break;
1168  default:
1169  throw BadArgumentException( FCML_TEXT( "Wrong size." ) );
1170  }
1171  return result;
1172  }
1173 
1179  operator fcml_uint64_t() const {
1180  fcml_uint64_t result;
1181  switch ( _size ) {
1182  case FCML_DS_8:
1183  result = static_cast<fcml_uint64_t>( _isSigned ? _vint8 : (fcml_uint8_t)_vint8 );
1184  break;
1185  case FCML_DS_16:
1186  result = static_cast<fcml_uint64_t>( _isSigned ? _vint16 : (fcml_uint16_t)_vint16 );
1187  break;
1188  case FCML_DS_32:
1189  result = static_cast<fcml_uint64_t>( _isSigned ? _vint32 : (fcml_uint32_t)_vint32 );
1190  break;
1191  case FCML_DS_64:
1192  result = static_cast<fcml_uint64_t>( _isSigned ? _vint64 : (fcml_uint64_t)_vint64 );
1193  break;
1194  default:
1195  throw BadArgumentException( FCML_TEXT( "Wrong size." ) );
1196  }
1197  return result;
1198  }
1199 
1204  Integer& operator +=( const Integer &arg ) {
1205  plus( *this, arg );
1206  return ( *this );
1207  }
1208 
1213  Integer& operator *=( const Integer &arg ) {
1214  mul( *this, arg );
1215  return ( *this );
1216  }
1217 
1222  Integer& operator /=( const Integer &arg ) {
1223  div( *this, arg );
1224  return ( *this );
1225  }
1226 
1231  Integer& operator -=( const Integer &arg ) {
1232  minus( *this, arg );
1233  return ( *this );
1234  }
1235 
1240  Integer operator+( const Integer &src ) const {
1241  const Integer &thisRef = *this;
1242  Integer result( thisRef );
1243  plus( result, src );
1244  return result;
1245  }
1246 
1251  Integer operator-( const Integer &src ) const {
1252  const Integer &thisRef = *this;
1253  Integer result( thisRef );
1254  minus( result, src );
1255  return result;
1256  }
1257 
1262  Integer operator*( const Integer &src ) const {
1263  const Integer &thisRef = *this;
1264  Integer result( thisRef );
1265  mul( result, src );
1266  return result;
1267  }
1268 
1273  Integer operator/( const Integer &src ) const {
1274  const Integer &thisRef = *this;
1275  Integer result( thisRef );
1276  div( result, src );
1277  return result;
1278  }
1279 
1280 public:
1281 
1288  static Integer int8( fcml_int8_t value ) {
1289  return Integer( value );
1290  }
1291 
1298  static Integer uint8( fcml_uint8_t value ) {
1299  return Integer( value );
1300  }
1301 
1308  static Integer int16( fcml_int16_t value ) {
1309  return Integer( value );
1310  }
1311 
1318  static Integer uint16( fcml_uint16_t value ) {
1319  return Integer( value );
1320  }
1321 
1328  static Integer int32( fcml_int32_t value ) {
1329  return Integer( value );
1330  }
1331 
1338  static Integer uint32( fcml_uint32_t value ) {
1339  return Integer( value );
1340  }
1341 
1348  static Integer int64( fcml_int64_t value ) {
1349  return Integer( value );
1350  }
1351 
1358  static Integer uint64( fcml_uint64_t value ) {
1359  return Integer( value );
1360  }
1361 
1362 private:
1363 
1368  void minus( Integer &result, const Integer &src ) const {
1369  callMathExpression( &doMinus, &doUMinus, result, src );
1370  }
1371 
1376  void mul( Integer &result, const Integer &src ) const {
1377  callMathExpression( &doMul, &doUMul, result, src );
1378  }
1379 
1384  void div( Integer &result, const Integer &src ) const {
1385  callMathExpression( &doDiv, &doUDiv, result, src );
1386  }
1387 
1392  void plus( Integer &result, const Integer &src ) const {
1393  callMathExpression( &doPlus, &doUPlus, result, src );
1394  }
1395 
1396 private:
1397 
1402  static fcml_int64_t doPlus( fcml_int64_t thisValue, fcml_int64_t thatValue ) {
1403  return thisValue + thatValue;
1404  }
1405 
1410  static fcml_int64_t doMinus( fcml_int64_t thisValue, fcml_int64_t thatValue ) {
1411  return thisValue - thatValue;
1412  }
1413 
1418  static fcml_int64_t doMul( fcml_int64_t thisValue, fcml_int64_t thatValue ) {
1419  return thisValue * thatValue;
1420  }
1421 
1426  static fcml_int64_t doDiv( fcml_int64_t thisValue, fcml_int64_t thatValue ) {
1427  return thisValue / thatValue;
1428  }
1429 
1434  static fcml_uint64_t doUPlus( fcml_uint64_t thisValue, fcml_uint64_t thatValue ) {
1435  return thisValue + thatValue;
1436  }
1437 
1442  static fcml_uint64_t doUMinus( fcml_uint64_t thisValue, fcml_uint64_t thatValue ) {
1443  return thisValue - thatValue;
1444  }
1445 
1450  static fcml_uint64_t doUMul( fcml_uint64_t thisValue, fcml_uint64_t thatValue ) {
1451  return thisValue * thatValue;
1452  }
1453 
1458  static fcml_uint64_t doUDiv( fcml_uint64_t thisValue, fcml_uint64_t thatValue ) {
1459  return thisValue / thatValue;
1460  }
1461 
1466  void callMathExpression( fcml_int64_t (*signedExpressionFn)( fcml_int64_t thisValue, fcml_int64_t thatValue ), fcml_uint64_t (*unsignedExpressionFn)( fcml_uint64_t thisValue, fcml_uint64_t thatValue ), Integer &result, const Integer &src ) const {
1467 
1468  if( _isSigned ) {
1469 
1470  fcml_int64_t thisValue;
1471  fcml_int64_t thatValue;
1472 
1473  // Prepare "that". It has to be converted to the same sign.
1474  switch( src._size ) {
1475  case FCML_DS_8:
1476  thatValue = src._isSigned ? src._vint8 : static_cast<fcml_uint8_t>( src._vint8 );
1477  break;
1478  case FCML_DS_16:
1479  thatValue = src._isSigned ? src._vint16 : static_cast<fcml_uint16_t>( src._vint16 );
1480  break;
1481  case FCML_DS_32:
1482  thatValue = src._isSigned ? src._vint32 : static_cast<fcml_uint32_t>( src._vint32 );
1483  break;
1484  case FCML_DS_64:
1485  thatValue = src._isSigned ? src._vint64 : static_cast<fcml_uint64_t>( src._vint64 );
1486  break;
1487  }
1488 
1489  // Now "this".
1490  switch( result._size ) {
1491  case FCML_DS_8:
1492  thisValue = result._isSigned ? result._vint8 : static_cast<fcml_uint8_t>(result._vint8 );
1493  thisValue = (*signedExpressionFn)( thisValue, thatValue );
1494  result._vint8 = static_cast<fcml_int8_t>( thisValue );
1495  break;
1496  case FCML_DS_16:
1497  thisValue = result._isSigned ? result._vint16 : static_cast<fcml_uint16_t>( result._vint16 );
1498  thisValue = (*signedExpressionFn)( thisValue, thatValue );
1499  result._vint16 = static_cast<fcml_int16_t>( thisValue );
1500  break;
1501  case FCML_DS_32:
1502  thisValue = result._isSigned ? result._vint32 : static_cast<fcml_uint32_t>( result._vint32 );
1503  thisValue = (*signedExpressionFn)( thisValue, thatValue );
1504  result._vint32 = static_cast<fcml_int32_t>( thisValue );
1505  break;
1506  case FCML_DS_64:
1507  thisValue = result._isSigned ? result._vint64 : static_cast<fcml_uint64_t>( result._vint64 );
1508  thisValue = (*signedExpressionFn)( thisValue, thatValue );
1509  result._vint64 = thisValue;
1510  break;
1511  }
1512 
1513  } else {
1514 
1515  fcml_uint64_t thisValue;
1516  fcml_uint64_t thatValue;
1517 
1518  // Prepare "that". It has to be converted to the same sign.
1519  switch( src._size ) {
1520  case FCML_DS_8:
1521  thatValue = src._isSigned ? src._vint8 : static_cast<fcml_uint8_t>( src._vint8 );
1522  break;
1523  case FCML_DS_16:
1524  thatValue = src._isSigned ? src._vint16 : static_cast<fcml_uint16_t>( src._vint16 );
1525  break;
1526  case FCML_DS_32:
1527  thatValue = src._isSigned ? src._vint32 : static_cast<fcml_uint32_t>( src._vint32 );
1528  break;
1529  case FCML_DS_64:
1530  thatValue = src._isSigned ? src._vint64 : static_cast<fcml_uint64_t>( src._vint64 );
1531  break;
1532  }
1533 
1534  // Now "this".
1535  switch( result._size ) {
1536  case FCML_DS_8:
1537  thisValue = result._isSigned ? result._vint8 : static_cast<fcml_uint8_t>( result._vint8 );
1538  thisValue = (*unsignedExpressionFn)( thisValue, thatValue );
1539  result._vint8 = static_cast<fcml_int8_t>( thisValue );
1540  break;
1541  case FCML_DS_16:
1542  thisValue = result._isSigned ? result._vint16 : static_cast<fcml_uint16_t>( result._vint16 );
1543  thisValue = (*unsignedExpressionFn)( thisValue, thatValue );
1544  result._vint16 = static_cast<fcml_int16_t>( thisValue );
1545  break;
1546  case FCML_DS_32:
1547  thisValue = result._isSigned ? result._vint32 : static_cast<fcml_uint32_t>( result._vint32 );
1548  thisValue = (*unsignedExpressionFn)( thisValue, thatValue );
1549  result._vint32 = static_cast<fcml_int32_t>( thisValue );
1550  break;
1551  case FCML_DS_64:
1552  thisValue = result._isSigned ? result._vint64 : static_cast<fcml_uint64_t>( result._vint64 );
1553  thisValue = (*unsignedExpressionFn)( thisValue, thatValue );
1554  result._vint64 = thisValue;
1555  break;
1556  }
1557  }
1558 
1559  }
1560 
1561 private:
1562  fcml_usize _size;
1563  fcml_bool _isSigned;
1564  fcml_int8_t _vint8;
1565  fcml_int16_t _vint16;
1566  fcml_int32_t _vint32;
1567  fcml_int64_t _vint64;
1568 };
1569 
1574 class Register {
1575 public:
1576 
1597  };
1598 
1604  _type(REG_UNDEFINED),
1605  _size(0),
1606  _reg(0),
1607  _x64_exp(FCML_FALSE) {
1608  }
1609 
1615  Register( const fcml_st_register &reg ) :
1616  _type(static_cast<RegisterType>( reg.type )),
1617  _size(reg.size),
1618  _reg(reg.reg),
1619  _x64_exp(reg.x64_exp? true : false) {
1620  }
1621 
1630  Register( fcml_uint8_t reg, fcml_usize size, RegisterType type = REG_GPR, fcml_bool x64_exp = FCML_FALSE ) :
1631  _type(type),
1632  _size(size),
1633  _reg(reg),
1634  _x64_exp(x64_exp?true:false) {
1635  }
1636 
1640  virtual ~Register() {
1641  }
1642 
1643 public:
1644 
1650  fcml_uint8_t getReg() const {
1651  return _reg;
1652  }
1653 
1659  void setReg( fcml_uint8_t reg ) {
1660  _reg = reg;
1661  }
1662 
1668  fcml_usize getSize() const {
1669  return _size;
1670  }
1671 
1677  void setSize( fcml_usize size ) {
1678  _size = size;
1679  }
1680 
1687  return _type;
1688  }
1689 
1695  void setType( RegisterType type ) {
1696  _type = type;
1697  }
1698 
1704  bool getX64Exp() const {
1705  return _x64_exp;
1706  }
1707 
1713  void setX64Exp( bool x64Exp ) {
1714  _x64_exp = x64Exp;
1715  }
1716 
1717 public:
1718 
1725  bool operator==( const Register &reg ) const {
1726  return _reg == reg._reg && _type == reg._type && _size == reg._size && _x64_exp == reg._x64_exp;
1727  }
1728 
1735  bool operator!=( const Register &reg ) const {
1736  return !( reg == *this );
1737  }
1738 
1739 public:
1740 
1746  static const Register UNDEF() {
1747  Register reg( 0, 0, Register::REG_UNDEFINED, FCML_FALSE );
1748  return reg;
1749  }
1750 
1756  static const Register AL() {
1757  Register reg( ::fcml_reg_AL );
1758  return reg;
1759  }
1760 
1766  static const Register AX() {
1767  Register reg( ::fcml_reg_AX );
1768  return reg;
1769  }
1770 
1776  static const Register EAX() {
1777  Register reg( ::fcml_reg_EAX );
1778  return reg;
1779  }
1780 
1786  static const Register RAX() {
1787  Register reg( ::fcml_reg_RAX );
1788  return reg;
1789  }
1790 
1796  static const Register MM0() {
1797  Register reg( ::fcml_reg_MM0 );
1798  return reg;
1799  }
1800 
1806  static const Register XMM0() {
1807  Register reg( ::fcml_reg_XMM0 );
1808  return reg;
1809  }
1810 
1816  static const Register YMM0() {
1817  Register reg( ::fcml_reg_YMM0 );
1818  return reg;
1819  }
1820 
1826  static const Register CL() {
1827  Register reg( ::fcml_reg_CL );
1828  return reg;
1829  }
1830 
1836  static const Register CX() {
1837  Register reg( ::fcml_reg_CX );
1838  return reg;
1839  }
1840 
1846  static const Register ECX() {
1847  Register reg( ::fcml_reg_ECX );
1848  return reg;
1849  }
1850 
1856  static const Register RCX() {
1857  Register reg( ::fcml_reg_RCX );
1858  return reg;
1859  }
1860 
1866  static const Register MM1() {
1867  Register reg( ::fcml_reg_MM1 );
1868  return reg;
1869  }
1870 
1876  static const Register XMM1() {
1877  Register reg( ::fcml_reg_XMM1 );
1878  return reg;
1879  }
1880 
1886  static const Register YMM1() {
1887  Register reg( ::fcml_reg_YMM1 );
1888  return reg;
1889  }
1890 
1896  static const Register DL() {
1897  Register reg( ::fcml_reg_DL );
1898  return reg;
1899  }
1900 
1906  static const Register DX() {
1907  Register reg( ::fcml_reg_DX );
1908  return reg;
1909  }
1910 
1916  static const Register EDX() {
1917  Register reg( ::fcml_reg_EDX );
1918  return reg;
1919  }
1920 
1926  static const Register RDX() {
1927  Register reg( ::fcml_reg_RDX );
1928  return reg;
1929  }
1930 
1936  static const Register MM2() {
1937  Register reg( ::fcml_reg_MM2 );
1938  return reg;
1939  }
1940 
1946  static const Register XMM2() {
1947  Register reg( ::fcml_reg_XMM2 );
1948  return reg;
1949  }
1950 
1956  static const Register YMM2() {
1957  Register reg( ::fcml_reg_YMM2 );
1958  return reg;
1959  }
1960 
1966  static const Register BL() {
1967  Register reg( ::fcml_reg_BL );
1968  return reg;
1969  }
1970 
1976  static const Register BX() {
1977  Register reg( ::fcml_reg_BX );
1978  return reg;
1979  }
1980 
1986  static const Register EBX() {
1987  Register reg( ::fcml_reg_EBX );
1988  return reg;
1989  }
1990 
1996  static const Register RBX() {
1997  Register reg( ::fcml_reg_RBX );
1998  return reg;
1999  }
2000 
2006  static const Register MM3() {
2007  Register reg( ::fcml_reg_MM3 );
2008  return reg;
2009  }
2010 
2016  static const Register XMM3() {
2017  Register reg( ::fcml_reg_XMM3 );
2018  return reg;
2019  }
2020 
2026  static const Register YMM3() {
2027  Register reg( ::fcml_reg_YMM3 );
2028  return reg;
2029  }
2030 
2036  static const Register AH() {
2037  Register reg( ::fcml_reg_AH );
2038  return reg;
2039  }
2040 
2046  static const Register SPL() {
2047  Register reg( ::fcml_reg_SPL );
2048  return reg;
2049  }
2050 
2056  static const Register SP() {
2057  Register reg( ::fcml_reg_SP );
2058  return reg;
2059  }
2060 
2066  static const Register ESP() {
2067  Register reg( ::fcml_reg_ESP );
2068  return reg;
2069  }
2070 
2076  static const Register RSP() {
2077  Register reg( ::fcml_reg_RSP );
2078  return reg;
2079  }
2080 
2086  static const Register MM4() {
2087  Register reg( ::fcml_reg_MM4 );
2088  return reg;
2089  }
2090 
2096  static const Register XMM4() {
2097  Register reg( ::fcml_reg_XMM4 );
2098  return reg;
2099  }
2100 
2106  static const Register YMM4() {
2107  Register reg( ::fcml_reg_YMM4 );
2108  return reg;
2109  }
2110 
2116  static const Register CH() {
2117  Register reg( ::fcml_reg_CH );
2118  return reg;
2119  }
2120 
2126  static const Register BPL() {
2127  Register reg( ::fcml_reg_BPL );
2128  return reg;
2129  }
2130 
2136  static const Register BP() {
2137  Register reg( ::fcml_reg_BP );
2138  return reg;
2139  }
2140 
2146  static const Register EBP() {
2147  Register reg( ::fcml_reg_EBP );
2148  return reg;
2149  }
2150 
2156  static const Register RBP() {
2157  Register reg( ::fcml_reg_RBP );
2158  return reg;
2159  }
2160 
2166  static const Register MM5() {
2167  Register reg( ::fcml_reg_MM5 );
2168  return reg;
2169  }
2170 
2176  static const Register XMM5() {
2177  Register reg( ::fcml_reg_XMM5 );
2178  return reg;
2179  }
2180 
2186  static const Register YMM5() {
2187  Register reg( ::fcml_reg_YMM5 );
2188  return reg;
2189  }
2190 
2196  static const Register DH() {
2197  Register reg( ::fcml_reg_DH );
2198  return reg;
2199  }
2200 
2206  static const Register SIL() {
2207  Register reg( ::fcml_reg_SIL );
2208  return reg;
2209  }
2210 
2216  static const Register SI() {
2217  Register reg( ::fcml_reg_SI );
2218  return reg;
2219  }
2220 
2226  static const Register ESI() {
2227  Register reg( ::fcml_reg_ESI );
2228  return reg;
2229  }
2230 
2236  static const Register RSI() {
2237  Register reg( ::fcml_reg_RSI );
2238  return reg;
2239  }
2240 
2246  static const Register MM6() {
2247  Register reg( ::fcml_reg_MM6 );
2248  return reg;
2249  }
2250 
2256  static const Register XMM6() {
2257  Register reg( ::fcml_reg_XMM6 );
2258  return reg;
2259  }
2260 
2266  static const Register YMM6() {
2267  Register reg( ::fcml_reg_YMM6 );
2268  return reg;
2269  }
2270 
2276  static const Register BH() {
2277  Register reg( ::fcml_reg_BH );
2278  return reg;
2279  }
2280 
2286  static const Register DIL() {
2287  Register reg( ::fcml_reg_DIL );
2288  return reg;
2289  }
2290 
2296  static const Register DI() {
2297  Register reg( ::fcml_reg_DI );
2298  return reg;
2299  }
2300 
2306  static const Register EDI() {
2307  Register reg( ::fcml_reg_EDI );
2308  return reg;
2309  }
2310 
2316  static const Register RDI() {
2317  Register reg( ::fcml_reg_RDI );
2318  return reg;
2319  }
2320 
2326  static const Register MM7() {
2327  Register reg( ::fcml_reg_MM7 );
2328  return reg;
2329  }
2330 
2336  static const Register XMM7() {
2337  Register reg( ::fcml_reg_XMM7 );
2338  return reg;
2339  }
2340 
2346  static const Register YMM7() {
2347  Register reg( ::fcml_reg_YMM7 );
2348  return reg;
2349  }
2350 
2356  static const Register R8L() {
2357  Register reg( ::fcml_reg_R8L );
2358  return reg;
2359  }
2360 
2366  static const Register R8W() {
2367  Register reg( ::fcml_reg_R8W );
2368  return reg;
2369  }
2370 
2376  static const Register R8D() {
2377  Register reg( ::fcml_reg_R8D );
2378  return reg;
2379  }
2380 
2386  static const Register R8() {
2387  Register reg( ::fcml_reg_R8 );
2388  return reg;
2389  }
2390 
2396  static const Register XMM8() {
2397  Register reg( ::fcml_reg_XMM8 );
2398  return reg;
2399  }
2400 
2406  static const Register YMM8() {
2407  Register reg( ::fcml_reg_YMM8 );
2408  return reg;
2409  }
2410 
2416  static const Register R9L() {
2417  Register reg( ::fcml_reg_R9L );
2418  return reg;
2419  }
2420 
2426  static const Register R9W() {
2427  Register reg( ::fcml_reg_R9W );
2428  return reg;
2429  }
2430 
2436  static const Register R9D() {
2437  Register reg( ::fcml_reg_R9D );
2438  return reg;
2439  }
2440 
2446  static const Register R9() {
2447  Register reg( ::fcml_reg_R9 );
2448  return reg;
2449  }
2450 
2456  static const Register XMM9() {
2457  Register reg( ::fcml_reg_XMM9 );
2458  return reg;
2459  }
2460 
2466  static const Register YMM9() {
2467  Register reg( ::fcml_reg_YMM9 );
2468  return reg;
2469  }
2470 
2476  static const Register R10L() {
2477  Register reg( ::fcml_reg_R10L );
2478  return reg;
2479  }
2480 
2486  static const Register R10W() {
2487  Register reg( ::fcml_reg_R10W );
2488  return reg;
2489  }
2490 
2496  static const Register R10D() {
2497  Register reg( ::fcml_reg_R10D );
2498  return reg;
2499  }
2500 
2506  static const Register R10() {
2507  Register reg( ::fcml_reg_R10 );
2508  return reg;
2509  }
2510 
2516  static const Register XMM10() {
2517  Register reg( ::fcml_reg_XMM10 );
2518  return reg;
2519  }
2520 
2526  static const Register YMM10() {
2527  Register reg( ::fcml_reg_YMM10 );
2528  return reg;
2529  }
2530 
2536  static const Register R11L() {
2537  Register reg( ::fcml_reg_R11L );
2538  return reg;
2539  }
2540 
2546  static const Register R11W() {
2547  Register reg( ::fcml_reg_R11W );
2548  return reg;
2549  }
2550 
2556  static const Register R11D() {
2557  Register reg( ::fcml_reg_R11D );
2558  return reg;
2559  }
2560 
2566  static const Register R11() {
2567  Register reg( ::fcml_reg_R11 );
2568  return reg;
2569  }
2570 
2576  static const Register XMM11() {
2577  Register reg( ::fcml_reg_XMM11 );
2578  return reg;
2579  }
2580 
2586  static const Register YMM11() {
2587  Register reg( ::fcml_reg_YMM11 );
2588  return reg;
2589  }
2590 
2596  static const Register R12L() {
2597  Register reg( ::fcml_reg_R12L );
2598  return reg;
2599  }
2600 
2606  static const Register R12W() {
2607  Register reg( ::fcml_reg_R12W );
2608  return reg;
2609  }
2610 
2616  static const Register R12D() {
2617  Register reg( ::fcml_reg_R12D );
2618  return reg;
2619  }
2620 
2626  static const Register R12() {
2627  Register reg( ::fcml_reg_R12 );
2628  return reg;
2629  }
2630 
2636  static const Register XMM12() {
2637  Register reg( ::fcml_reg_XMM12 );
2638  return reg;
2639  }
2640 
2646  static const Register YMM12() {
2647  Register reg( ::fcml_reg_YMM12 );
2648  return reg;
2649  }
2650 
2656  static const Register R13L() {
2657  Register reg( ::fcml_reg_R13L );
2658  return reg;
2659  }
2660 
2666  static const Register R13W() {
2667  Register reg( ::fcml_reg_R13W );
2668  return reg;
2669  }
2670 
2676  static const Register R13D() {
2677  Register reg( ::fcml_reg_R13D );
2678  return reg;
2679  }
2680 
2686  static const Register R13() {
2687  Register reg( ::fcml_reg_R13 );
2688  return reg;
2689  }
2690 
2696  static const Register XMM13() {
2697  Register reg( ::fcml_reg_XMM13 );
2698  return reg;
2699  }
2700 
2706  static const Register YMM13() {
2707  Register reg( ::fcml_reg_YMM13 );
2708  return reg;
2709  }
2710 
2716  static const Register R14L() {
2717  Register reg( ::fcml_reg_R14L );
2718  return reg;
2719  }
2720 
2726  static const Register R14W() {
2727  Register reg( ::fcml_reg_R14W );
2728  return reg;
2729  }
2730 
2736  static const Register R14D() {
2737  Register reg( ::fcml_reg_R14D );
2738  return reg;
2739  }
2740 
2746  static const Register R14() {
2747  Register reg( ::fcml_reg_R14 );
2748  return reg;
2749  }
2750 
2756  static const Register XMM14() {
2757  Register reg( ::fcml_reg_XMM14 );
2758  return reg;
2759  }
2760 
2766  static const Register YMM14() {
2767  Register reg( ::fcml_reg_YMM14 );
2768  return reg;
2769  }
2770 
2776  static const Register R15L() {
2777  Register reg( ::fcml_reg_R15L );
2778  return reg;
2779  }
2780 
2786  static const Register R15W() {
2787  Register reg( ::fcml_reg_R15W );
2788  return reg;
2789  }
2790 
2796  static const Register R15D() {
2797  Register reg( ::fcml_reg_R15D );
2798  return reg;
2799  }
2800 
2806  static const Register R15() {
2807  Register reg( ::fcml_reg_R15 );
2808  return reg;
2809  }
2810 
2816  static const Register XMM15() {
2817  Register reg( ::fcml_reg_XMM15 );
2818  return reg;
2819  }
2820 
2826  static const Register YMM15() {
2827  Register reg( ::fcml_reg_YMM15 );
2828  return reg;
2829  }
2830 
2836  static const Register ES() {
2837  Register reg( ::fcml_reg_ES );
2838  return reg;
2839  }
2840 
2846  static const Register CS() {
2847  Register reg( ::fcml_reg_CS );
2848  return reg;
2849  }
2850 
2856  static const Register SS() {
2857  Register reg( ::fcml_reg_SS );
2858  return reg;
2859  }
2860 
2866  static const Register DS() {
2867  Register reg( ::fcml_reg_DS );
2868  return reg;
2869  }
2870 
2876  static const Register FS() {
2877  Register reg( ::fcml_reg_FS );
2878  return reg;
2879  }
2880 
2886  static const Register GS() {
2887  Register reg( ::fcml_reg_GS );
2888  return reg;
2889  }
2890 
2896  static const Register ST0() {
2897  Register reg( ::fcml_reg_ST0 );
2898  return reg;
2899  }
2900 
2906  static const Register ST1() {
2907  Register reg( ::fcml_reg_ST1 );
2908  return reg;
2909  }
2910 
2916  static const Register ST2() {
2917  Register reg( ::fcml_reg_ST2 );
2918  return reg;
2919  }
2920 
2926  static const Register ST3() {
2927  Register reg( ::fcml_reg_ST3 );
2928  return reg;
2929  }
2930 
2936  static const Register ST4() {
2937  Register reg( ::fcml_reg_ST4 );
2938  return reg;
2939  }
2940 
2946  static const Register ST5() {
2947  Register reg( ::fcml_reg_ST5 );
2948  return reg;
2949  }
2950 
2956  static const Register ST6() {
2957  Register reg( ::fcml_reg_ST6 );
2958  return reg;
2959  }
2960 
2966  static const Register ST7() {
2967  Register reg( ::fcml_reg_ST7 );
2968  return reg;
2969  }
2970 
2976  static const Register CR0() {
2977  Register reg( ::fcml_reg_CR0 );
2978  return reg;
2979  }
2980 
2986  static const Register CR2() {
2987  Register reg( ::fcml_reg_CR2 );
2988  return reg;
2989  }
2990 
2996  static const Register CR3() {
2997  Register reg( ::fcml_reg_CR3 );
2998  return reg;
2999  }
3000 
3006  static const Register CR4() {
3007  Register reg( ::fcml_reg_CR4 );
3008  return reg;
3009  }
3010 
3016  static const Register CR8() {
3017  Register reg( ::fcml_reg_CR8 );
3018  return reg;
3019  }
3020 
3026  static const Register DR0() {
3027  Register reg( ::fcml_reg_DR0 );
3028  return reg;
3029  }
3030 
3036  static const Register DR1() {
3037  Register reg( ::fcml_reg_DR1 );
3038  return reg;
3039  }
3040 
3046  static const Register DR2() {
3047  Register reg( ::fcml_reg_DR2 );
3048  return reg;
3049  }
3050 
3056  static const Register DR3() {
3057  Register reg( ::fcml_reg_DR3 );
3058  return reg;
3059  }
3060 
3066  static const Register DR4() {
3067  Register reg( ::fcml_reg_DR4 );
3068  return reg;
3069  }
3070 
3076  static const Register DR5() {
3077  Register reg( ::fcml_reg_DR5 );
3078  return reg;
3079  }
3080 
3086  static const Register DR6() {
3087  Register reg( ::fcml_reg_DR6 );
3088  return reg;
3089  }
3090 
3096  static const Register DR7() {
3097  Register reg( ::fcml_reg_DR7 );
3098  return reg;
3099  }
3100 
3106  static const Register IP() {
3107  Register reg( ::fcml_reg_IP );
3108  return reg;
3109  }
3110 
3116  static const Register EIP() {
3117  Register reg( ::fcml_reg_EIP );
3118  return reg;
3119  }
3120 
3126  static const Register RIP() {
3127  Register reg( ::fcml_reg_RIP );
3128  return reg;
3129  }
3130 
3131 private:
3132 
3134  RegisterType _type;
3136  fcml_usize _size;
3138  fcml_uint8_t _reg;
3140  bool _x64_exp;
3141 
3142 };
3143 
3148 class FarPointer {
3149 
3150 public:
3151 
3157  _segment(0),
3158  _offset_size(0),
3159  _offset16(0),
3160  _offset32(0) {
3161  }
3162 
3169  FarPointer( fcml_uint16_t segment, fcml_int16_t offset16 ) :
3170  _segment(segment),
3171  _offset_size(FCML_DS_16),
3172  _offset16(offset16),
3173  _offset32(0) {
3174  }
3181  FarPointer( fcml_uint16_t segment, fcml_int32_t offset32 ) :
3182  _segment(segment),
3183  _offset_size(FCML_DS_32),
3184  _offset16(0),
3185  _offset32(offset32) {
3186  }
3187 
3188  virtual ~FarPointer() {
3189  }
3190 
3191 public:
3192 
3199  bool operator==( const FarPointer &fp ) const {
3200  fcml_int32_t thisOffset;
3201  switch( _offset_size ) {
3202  case FCML_DS_32:
3203  thisOffset = _offset32;
3204  break;
3205  case FCML_DS_16:
3206  thisOffset = _offset16;
3207  break;
3208  }
3209  fcml_int32_t thatOffset;
3210  switch( fp._offset_size ) {
3211  case FCML_DS_32:
3212  thatOffset = fp._offset32;
3213  break;
3214  case FCML_DS_16:
3215  thatOffset = fp._offset16;
3216  break;
3217  }
3218  return thisOffset == thatOffset;
3219  }
3220 
3227  bool operator!=( const FarPointer &fp) const {
3228  return !(fp == *this);
3229  }
3230 
3231 public:
3232 
3241  static FarPointer off16( fcml_uint16_t segment, fcml_int16_t offset ) {
3242  return FarPointer(segment, offset);
3243  }
3244 
3252  static FarPointer off32( fcml_uint16_t segment, fcml_int32_t offset ) {
3253  return FarPointer(segment, offset);
3254  }
3255 
3256 public:
3257 
3264  fcml_usize getOffsetSize() const {
3265  return _offset_size;
3266  }
3267 
3274  void setOffsetSize( fcml_usize offsetSize ) {
3275  _offset_size = offsetSize;
3276  }
3277 
3284  fcml_int16_t getOffset16() const {
3285  return _offset16;
3286  }
3287 
3294  void setOffset16( fcml_int16_t offset16 ) {
3295  _offset16 = offset16;
3296  }
3297 
3304  fcml_int32_t getOffset32() const {
3305  return _offset32;
3306  }
3307 
3314  void setOffset32( fcml_int32_t offset32 ) {
3315  _offset32 = offset32;
3316  }
3317 
3324  fcml_uint16_t getSegment() const {
3325  return _segment;
3326  }
3327 
3334  void setSegment( fcml_uint16_t segment ) {
3335  _segment = segment;
3336  }
3337 
3338 private:
3339 
3341  fcml_uint16_t _segment;
3343  fcml_usize _offset_size;
3345  fcml_int16_t _offset16;
3347  fcml_int32_t _offset32;
3348 
3349 };
3350 
3356 public:
3357 
3363  _segmentSelector(),
3364  _isDefaultReg(false) {
3365  }
3366 
3373  SegmentSelector( const Register &segmentSelector, bool isDefaultReg = FCML_TRUE ) :
3374  _segmentSelector(segmentSelector),
3375  _isDefaultReg(isDefaultReg) {
3376  }
3377 
3378  virtual ~SegmentSelector() {
3379  }
3380 
3381 public:
3382 
3389  bool operator==( const SegmentSelector &segmentSelector ) const {
3390  // It really doesn't matter if it is the default segment register in a given context.
3391  return segmentSelector._segmentSelector == _segmentSelector;
3392  }
3393 
3400  bool operator!=( const SegmentSelector &segmentSelector ) const {
3401  return !(*this == segmentSelector);
3402  }
3403 
3409  operator Register() const {
3410  return _segmentSelector;
3411  }
3412 
3420  if( &reg != this ) {
3421  _isDefaultReg = reg._isDefaultReg;
3422  _segmentSelector = reg._segmentSelector;
3423  }
3424  return *this;
3425  }
3426 
3427 public:
3428 
3437  static SegmentSelector seg( const Register &segmentSelector, bool isDefaultReg ) {
3438  return SegmentSelector( segmentSelector, isDefaultReg );
3439  }
3440 
3441 public:
3442 
3450  bool isDefaultReg() const {
3451  return _isDefaultReg;
3452  }
3453 
3461  _isDefaultReg = isDefaultReg;
3462  }
3463 
3470  const Register& getSegmentSelector() const {
3471  return _segmentSelector;
3472  }
3473 
3481  return _segmentSelector;
3482  }
3483 
3490  void setSegmentSelector( const Register& segmentSelector ) {
3491  _segmentSelector = segmentSelector;
3492  }
3493 
3494 private:
3496  Register _segmentSelector;
3498  bool _isDefaultReg;
3499 };
3500 
3508 public:
3509 
3515  _scaleFactor(0){
3516  }
3517 
3523  EffectiveAddress( const Integer &displacement ) :
3524  _scaleFactor(0),
3525  _displacement(displacement) {
3526  }
3527 
3533  EffectiveAddress( const Register &base ) :
3534  _base(base),
3535  _scaleFactor(0) {
3536  }
3537 
3544  EffectiveAddress( const Register &base, const Integer &displacement ) :
3545  _base(base),
3546  _scaleFactor(0),
3547  _displacement(displacement) {
3548  }
3549 
3557  EffectiveAddress( const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement ) :
3558  _index(index),
3559  _scaleFactor(scaleFactor),
3560  _displacement(displacement) {
3561  }
3562 
3569  EffectiveAddress( const Register &base, const Register &index ) :
3570  _base(base),
3571  _index(index),
3572  _scaleFactor(0) {
3573  }
3574 
3582  EffectiveAddress( const Register &base, const Register &index, fcml_uint8_t scaleFactor ) :
3583  _base(base),
3584  _index(index),
3585  _scaleFactor(scaleFactor) {
3586  }
3587 
3596  EffectiveAddress( const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement ) :
3597  _base(base),
3598  _index(index),
3599  _scaleFactor(scaleFactor),
3600  _displacement(displacement) {
3601  }
3602 
3606  virtual ~EffectiveAddress() {
3607  }
3608 
3609 public:
3610 
3617  bool operator==( const EffectiveAddress &address ) const {
3618  if( &address == this ) {
3619  return true;
3620  }
3621  return _base == address._base &&
3622  _index == address._index &&
3623  _scaleFactor == address._scaleFactor &&
3624  _displacement == address._displacement;
3625  }
3626 
3633  bool operator!=( const EffectiveAddress &address ) const {
3634  return !(address == *this);
3635  }
3636 
3637 public:
3638 
3644  static EffectiveAddress addr( const Integer &displacement ) {
3645  return EffectiveAddress( displacement );
3646  }
3647 
3653  static EffectiveAddress addr( const Register &base ) {
3654  return EffectiveAddress( base );
3655  }
3656 
3663  static EffectiveAddress addr( const Register &base, const Integer &displacement ) {
3664  return EffectiveAddress( base, displacement );
3665  }
3666 
3674  static EffectiveAddress addr( const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement ) {
3675  return EffectiveAddress( index, scaleFactor, displacement );
3676  }
3677 
3684  static EffectiveAddress addr( const Register &base, const Register &index ) {
3685  return EffectiveAddress( base, index, 0 );
3686  }
3687 
3695  static EffectiveAddress addr( const Register &base, const Register &index, fcml_uint8_t scaleFactor ) {
3696  return EffectiveAddress( base, index, scaleFactor );
3697  }
3698 
3707  static EffectiveAddress addr( const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement ) {
3708  return EffectiveAddress( base, index, scaleFactor, displacement );
3709  }
3710 
3711 public:
3712 
3719  const Register& getBase() const {
3720  return _base;
3721  }
3722 
3730  return _base;
3731  }
3732 
3741  _base = base;
3742  return *this;
3743  }
3744 
3751  const Integer& getDisplacement() const {
3752  return _displacement;
3753  }
3754 
3762  return _displacement;
3763  }
3764 
3772  EffectiveAddress& setDisplacement( const Integer &displacement ) {
3773  _displacement = displacement;
3774  return *this;
3775  }
3776 
3783  const Register& getIndex() const {
3784  return _index;
3785  }
3786 
3794  return _index;
3795  }
3796 
3805  _index = index;
3806  return *this;
3807  }
3808 
3815  fcml_uint8_t getScaleFactor() const {
3816  return _scaleFactor;
3817  }
3818 
3826  EffectiveAddress& setScaleFactor( fcml_uint8_t scaleFactor ) {
3827  _scaleFactor = scaleFactor;
3828  return *this;
3829  }
3830 
3831 private:
3833  Register _base;
3835  Register _index;
3837  fcml_uint8_t _scaleFactor;
3839  Integer _displacement;
3840 };
3841 
3847 class Address {
3848 
3849 public:
3850 
3861  };
3862 
3868  _size_operator( FCML_DS_UNDEF ),
3869  _address_form( AF_UNDEFINED ) {
3870  }
3871 
3879  Address( const Integer &offset, fcml_usize sizeOperator = FCML_DS_UNDEF ) :
3880  _size_operator( sizeOperator ),
3881  _address_form( AF_OFFSET ),
3882  _offset( offset ) {
3883  }
3884 
3892  Address( const EffectiveAddress &effectiveAddress, fcml_usize sizeOperator = FCML_DS_UNDEF ) :
3893  _size_operator( sizeOperator ),
3894  _address_form( AF_COMBINED ),
3895  _effective_address( effectiveAddress ) {
3896  }
3897 
3906  Address( const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector, fcml_usize sizeOperator = FCML_DS_UNDEF ) :
3907  _size_operator( sizeOperator ),
3908  _address_form( AF_COMBINED ),
3909  _segment_selector( segmentSelector ),
3910  _effective_address( effectiveAddress ) {
3911  }
3912 
3914  virtual ~Address() {
3915  }
3916 
3917 public:
3918 
3925  static Address effective( const Integer &displacement, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
3926  return effective( EffectiveAddress( displacement ), sizeOperator );
3927  }
3928 
3935  static Address effective( const Register &base, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
3936  return effective( EffectiveAddress( base ), sizeOperator );
3937  }
3938 
3946  static Address effective( const Register &base, const Integer &displacement, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
3947  return effective( EffectiveAddress( base, displacement ), sizeOperator );
3948  }
3949 
3958  static Address effective( const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
3959  return effective( EffectiveAddress( index, scaleFactor, displacement ), sizeOperator );
3960  }
3961 
3969  static Address effective( const Register &base, const Register &index, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
3970  return effective( EffectiveAddress( base, index, 0 ), sizeOperator );
3971  }
3972 
3981  static Address effective( const Register &base, const Register &index, fcml_uint8_t scaleFactor, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
3982  return effective( EffectiveAddress( base, index, scaleFactor ), sizeOperator );
3983  }
3984 
3994  static Address effective( const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
3995  return effective( EffectiveAddress( base, index, scaleFactor, displacement ), sizeOperator );
3996  }
3997 
3998 
3999 public:
4000 
4007  bool operator==( const Address &address ) const {
4008  if( &address == this ) {
4009  return true;
4010  }
4011  return _size_operator == address._size_operator &&
4012  _address_form == address._address_form &&
4013  _segment_selector == address._segment_selector &&
4014  _effective_address == address._effective_address &&
4015  _offset == address._offset;
4016  }
4017 
4024  bool operator!=( const Address &address ) const {
4025  return !(address == *this );
4026  }
4027 
4028 public:
4029 
4039  static Address effective( const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
4040  return Address( effectiveAddress, segmentSelector, sizeOperator );
4041  }
4042 
4051  static Address effective( const EffectiveAddress &effectiveAddress, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
4052  return Address( effectiveAddress, sizeOperator );
4053  }
4054 
4063  static Address offset( const Integer &offset, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
4064  return Address( offset, sizeOperator );
4065  }
4066 
4067 public:
4068 
4075  bool isEffectiveAddress() const {
4076  return _address_form == AF_COMBINED;
4077  }
4078 
4085  bool isOffset() const {
4086  return _address_form == AF_OFFSET;
4087  }
4088 
4096  return _address_form;
4097  }
4098 
4108  _address_form = addressForm;
4109  return *this;
4110  }
4111 
4119  return _effective_address;
4120  }
4121 
4129  return _effective_address;
4130  }
4131 
4139  Address& setEffectiveAddress( const EffectiveAddress& effectiveAddress ) {
4140  _effective_address = effectiveAddress;
4141  return *this;
4142  }
4143 
4150  const Integer& getOffset() const {
4151  return _offset;
4152  }
4153 
4161  return _offset;
4162  }
4163 
4172  this->_offset = offset;
4173  return *this;
4174  }
4175 
4183  return _segment_selector;
4184  }
4185 
4193  return _segment_selector;
4194  }
4195 
4203  Address& setSegmentSelector( const SegmentSelector &segmentSelector ) {
4204  _segment_selector = segmentSelector;
4205  return *this;
4206  }
4207 
4214  fcml_usize getSizeOperator() const {
4215  return _size_operator;
4216  }
4217 
4224  Address& setSizeOperator( fcml_usize sizeOperator ) {
4225  _size_operator = sizeOperator;
4226  return *this;
4227  }
4228 
4229 private:
4230 
4232  fcml_usize _size_operator;
4234  AddressForm _address_form;
4236  SegmentSelector _segment_selector;
4238  EffectiveAddress _effective_address;
4240  Integer _offset;
4241 
4242 };
4243 
4247 class Operand {
4248 public:
4249 
4264  };
4265 
4271  _hints( FCML_OP_HINT_UNDEFIEND ),
4272  _operandType( OT_NONE ) {
4273  }
4274 
4283  _hints( hints ),
4284  _operandType(OT_IMMEDIATE ),
4285  _immediate( imm ) {
4286  }
4287 
4296  _hints( hints ),
4297  _operandType( OT_FAR_POINTER ),
4298  _farPointer( pointer ) {
4299  }
4300 
4308  Operand( const Address &address, fcml_hints hints = FCML_OP_HINT_UNDEFIEND ) :
4309  _hints( hints ),
4310  _operandType( OT_ADDRESS ),
4311  _address( address ) {
4312  }
4313 
4322  _hints( hints ),
4323  _operandType( OT_REGISTER ),
4324  _register( reg ) {
4325  }
4326 
4327 public:
4328 
4336  bool operator==( const Operand &op ) const {
4337  if( &op == this ) {
4338  return true;
4339  }
4340  bool equal = false;
4341  switch( _operandType ) {
4342  case OT_ADDRESS:
4343  equal = _address == op._address;
4344  break;
4345  case OT_FAR_POINTER:
4346  equal = _farPointer == op._farPointer;
4347  break;
4348  case OT_IMMEDIATE:
4349  equal = _immediate == op._immediate;
4350  break;
4351  case OT_REGISTER:
4352  equal = _register == op._register;
4353  break;
4354  case OT_NONE:
4355  equal = true;
4356  break;
4357  }
4358  return equal && op._hints == _hints;
4359  }
4360 
4368  bool operator!=( const Operand &op ) const {
4369  return !(op == *this);
4370  }
4371 
4372 public:
4373 
4378  void undef() {
4379  _operandType = OT_NONE;
4380  }
4381 
4388  void imm( const Integer &imm ) {
4389  _operandType = OT_IMMEDIATE;
4390  _immediate = imm;
4391  }
4392 
4400  void far_ptr( fcml_uint16_t seg, fcml_int16_t addr ) {
4401  _operandType = OT_FAR_POINTER;
4402  _farPointer = FarPointer( seg, addr );
4403  }
4404 
4412  void far_ptr( fcml_uint16_t seg, fcml_int32_t addr ) {
4413  _operandType = OT_FAR_POINTER;
4414  _farPointer = FarPointer( seg, addr );
4415  }
4416 
4423  void far_ptr( const FarPointer &pointer ) {
4424  _operandType = OT_FAR_POINTER;
4425  _farPointer = pointer;
4426  }
4427 
4434  void addr( const Address &address ) {
4435  _operandType = OT_ADDRESS;
4436  _address = address;
4437  }
4438 
4446  void off( const Integer &offset, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
4447  _operandType = OT_ADDRESS;
4448  _address = Address( offset, sizeOperator );
4449  }
4450 
4458  void addr( const EffectiveAddress &effectiveAddress, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
4459  _operandType = OT_ADDRESS;
4460  _address = Address( effectiveAddress, sizeOperator );
4461  }
4462 
4471  void addr( const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
4472  _operandType = OT_ADDRESS;
4473  _address = Address( effectiveAddress, segmentSelector, sizeOperator );
4474  }
4475 
4482  void reg( const Register &reg ) {
4483  _operandType = OT_REGISTER;
4484  _register = reg;
4485  }
4486 
4496  void reg( fcml_uint8_t reg, fcml_usize size, Register::RegisterType type = Register::REG_GPR, fcml_bool x64_exp = FCML_FALSE ) {
4497  _operandType = OT_REGISTER;
4498  _register = Register( reg, size, type, x64_exp );
4499  }
4500 
4501 public:
4502 
4509  bool isImm() const {
4510  return _operandType == OT_IMMEDIATE;
4511  }
4512 
4519  bool isReg() const {
4520  return _operandType == OT_REGISTER;
4521  }
4522 
4529  bool isAddr() const {
4530  return _operandType == OT_ADDRESS;
4531  }
4532 
4539  bool isFar() const {
4540  return _operandType == OT_FAR_POINTER;
4541  }
4542 
4549  const Address& getAddress() const {
4550  return _address;
4551  }
4552 
4560  return _address;
4561  }
4562 
4570  Operand& setAddress( const Address &address ) {
4571  _address = address;
4572  return *this;
4573  }
4574 
4581  const FarPointer& getFarPointer() const {
4582  return _farPointer;
4583  }
4584 
4592  return _farPointer;
4593  }
4594 
4602  Operand& setFarPointer( const FarPointer &farPointer ) {
4603  _farPointer = farPointer;
4604  return *this;
4605  }
4606 
4613  const Integer& getImmediate() const {
4614  return _immediate;
4615  }
4616 
4624  return _immediate;
4625  }
4626 
4634  Operand& setImmediate( const Integer &immediate ) {
4635  _immediate = immediate;
4636  return *this;
4637  }
4638 
4646  return _operandType;
4647  }
4648 
4657  _operandType = operandType;
4658  return *this;
4659  }
4660 
4667  const Register& getRegister() const {
4668  return _register;
4669  }
4670 
4678  return _register;
4679  }
4680 
4689  this->_register = reg;
4690  return *this;
4691  }
4692 
4700  return _hints;
4701  }
4702 
4711  _hints = hints;
4712  return *this;
4713  }
4714 
4715  // Hints
4716 
4724  bool isMultimedia() const {
4725  return _hints & FCML_OP_HINT_MULTIMEDIA_INSTRUCTION;
4726  }
4727 
4734  bool isDisRelativeAddress() const {
4735  return ( _hints & FCML_OP_HINT_DISPLACEMENT_RELATIVE_ADDRESS ) ? true : false;
4736  }
4737 
4745  bool isPseudoOpcode() const {
4746  return ( _hints & FCML_OP_HINT_PSEUDO_OPCODE ) ? true : false;
4747  }
4748 
4755  bool isAbsoluteAddressing() const {
4756  return ( _hints & FCML_OP_HINT_ABSOLUTE_ADDRESSING ) ? true : false;
4757  }
4758 
4765  bool isRelativeAddressing() const {
4766  return ( _hints & FCML_OP_HINT_RELATIVE_ADDRESSING ) ? true : false;
4767  }
4768 
4775  bool isSIBEncoding() const {
4776  return ( _hints & FCML_OP_HINT_SIB_ENCODING ) ? true : false;
4777  }
4778 
4779 public:
4780 
4785  operator const Integer&() const {
4786  return _immediate;
4787  }
4788 
4793  operator const FarPointer&() const {
4794  return _farPointer;
4795  }
4796 
4801  operator const Address&() const {
4802  return _address;
4803  }
4804 
4809  operator const Register&() const {
4810  return _register;
4811  }
4812 
4813 private:
4814 
4816  fcml_hints _hints;
4818  OperandType _operandType;
4820  Integer _immediate;
4822  FarPointer _farPointer;
4823  /* Describes address. */
4824  Address _address;
4825  /* Describes register. */
4826  Register _register;
4827 
4828 };
4829 
4838 class OB {
4839 public:
4840 
4846  static Operand undef() {
4847  return Operand();
4848  }
4849 
4855  static Operand imm( const Integer &imm ) {
4856  return Operand( imm );
4857  }
4858 
4866  static Operand far_ptr( fcml_uint16_t seg, fcml_int16_t addr ) {
4867  return Operand( FarPointer( seg, addr ) );
4868  }
4869 
4877  static Operand far_ptr( fcml_uint16_t seg, fcml_int32_t addr ) {
4878  return Operand( FarPointer( seg, addr ) );
4879  }
4880 
4887  static Operand far_ptr( const FarPointer &pointer ) {
4888  return Operand( pointer );
4889  }
4890 
4897  static Operand addr( const Address &address ) {
4898  return Operand( address );
4899  }
4900 
4908  static Operand off( const Integer &offset, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
4909  return Operand( Address( offset, sizeOperator ) );
4910  }
4911 
4918  static Operand offb( const Integer &offset ) {
4919  return Operand( Address( offset, FCML_DS_8 ) );
4920  }
4921 
4928  static Operand offw( const Integer &offset ) {
4929  return Operand( Address( offset, FCML_DS_16 ) );
4930  }
4931 
4938  static Operand offd( const Integer &offset ) {
4939  return Operand( Address( offset, FCML_DS_32 ) );
4940  }
4941 
4948  static Operand offq( const Integer &offset ) {
4949  return Operand( Address( offset, FCML_DS_64 ) );
4950  }
4951 
4959  static Operand addr( const EffectiveAddress &effectiveAddress, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
4960  return Operand( Address( effectiveAddress, sizeOperator ) );
4961  }
4962 
4969  static Operand addrb( const EffectiveAddress &effectiveAddress ) {
4970  return Operand( Address( effectiveAddress, FCML_DS_8 ) );
4971  }
4972 
4979  static Operand addrw( const EffectiveAddress &effectiveAddress ) {
4980  return Operand( Address( effectiveAddress, FCML_DS_16 ) );
4981  }
4982 
4989  static Operand addrd( const EffectiveAddress &effectiveAddress ) {
4990  return Operand( Address( effectiveAddress, FCML_DS_32 ) );
4991  }
4992 
4999  static Operand addrq( const EffectiveAddress &effectiveAddress ) {
5000  return Operand( Address( effectiveAddress, FCML_DS_64 ) );
5001  }
5002 
5011  static Operand addr( const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
5012  return Operand( Address( effectiveAddress, segmentSelector, sizeOperator ) );
5013  }
5014 
5022  static Operand addrb( const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector ) {
5023  return Operand( Address( effectiveAddress, segmentSelector, FCML_DS_8 ) );
5024  }
5025 
5033  static Operand addrw( const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector ) {
5034  return Operand( Address( effectiveAddress, segmentSelector, FCML_DS_16 ) );
5035  }
5036 
5044  static Operand addrd( const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector ) {
5045  return Operand( Address( effectiveAddress, segmentSelector, FCML_DS_32 ) );
5046  }
5047 
5055  static Operand addrq( const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector ) {
5056  return Operand( Address( effectiveAddress, segmentSelector, FCML_DS_64 ) );
5057  }
5058 
5065  static Operand reg( const Register &reg ) {
5066  return Operand( reg );
5067  }
5068 
5078  static Operand reg( fcml_uint8_t reg, fcml_usize size, Register::RegisterType type = Register::REG_GPR, fcml_bool x64_exp = FCML_FALSE ) {
5079  return Operand( Register( reg, size, type, x64_exp ) );
5080  }
5081 
5089  static Operand eff( const Integer &displacement, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
5090  return addr( EffectiveAddress( displacement ), sizeOperator );
5091  }
5092 
5099  static Operand effb( const Integer &displacement ) {
5100  return addr( EffectiveAddress( displacement ), FCML_DS_8 );
5101  }
5102 
5109  static Operand effw( const Integer &displacement ) {
5110  return addr( EffectiveAddress( displacement ), FCML_DS_16 );
5111  }
5112 
5119  static Operand effd( const Integer &displacement ) {
5120  return addr( EffectiveAddress( displacement ), FCML_DS_32 );
5121  }
5122 
5129  static Operand effq( const Integer &displacement ) {
5130  return addr( EffectiveAddress( displacement ), FCML_DS_64 );
5131  }
5132 
5140  static Operand eff( const Register &base, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
5141  return addr( EffectiveAddress( base ), sizeOperator );
5142  }
5143 
5150  static Operand effb( const Register &base ) {
5151  return addr( EffectiveAddress( base ), FCML_DS_8 );
5152  }
5153 
5160  static Operand effw( const Register &base ) {
5161  return addr( EffectiveAddress( base ), FCML_DS_16 );
5162  }
5163 
5170  static Operand effd( const Register &base ) {
5171  return addr( EffectiveAddress( base ), FCML_DS_32 );
5172  }
5173 
5180  static Operand effq( const Register &base ) {
5181  return addr( EffectiveAddress( base ), FCML_DS_64 );
5182  }
5183 
5192  static Operand eff( const Register &base, const Integer &displacement, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
5193  return addr( EffectiveAddress( base, displacement ), sizeOperator );
5194  }
5195 
5203  static Operand effb( const Register &base, const Integer &displacement ) {
5204  return addr( EffectiveAddress( base, displacement ), FCML_DS_8 );
5205  }
5206 
5214  static Operand effw( const Register &base, const Integer &displacement ) {
5215  return addr( EffectiveAddress( base, displacement ), FCML_DS_16 );
5216  }
5217 
5225  static Operand effd( const Register &base, const Integer &displacement ) {
5226  return addr( EffectiveAddress( base, displacement ), FCML_DS_32 );
5227  }
5228 
5236  static Operand effq( const Register &base, const Integer &displacement ) {
5237  return addr( EffectiveAddress( base, displacement ), FCML_DS_64 );
5238  }
5239 
5249  static Operand eff( const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
5250  return addr( EffectiveAddress( index, scaleFactor, displacement ), sizeOperator );
5251  }
5252 
5261  static Operand effb( const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement ) {
5262  return addr( EffectiveAddress( index, scaleFactor, displacement ), FCML_DS_8 );
5263  }
5264 
5273  static Operand effw( const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement ) {
5274  return addr( EffectiveAddress( index, scaleFactor, displacement ), FCML_DS_16 );
5275  }
5276 
5285  static Operand effd( const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement ) {
5286  return addr( EffectiveAddress( index, scaleFactor, displacement ), FCML_DS_32 );
5287  }
5288 
5297  static Operand effq( const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement ) {
5298  return addr( EffectiveAddress( index, scaleFactor, displacement ), FCML_DS_64 );
5299  }
5300 
5309  static Operand eff( const Register &base, const Register &index, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
5310  return addr( EffectiveAddress( base, index ), sizeOperator );
5311  }
5312 
5320  static Operand effb( const Register &base, const Register &index ) {
5321  return addr( EffectiveAddress( base, index ), FCML_DS_8 );
5322  }
5323 
5331  static Operand effw( const Register &base, const Register &index ) {
5332  return addr( EffectiveAddress( base, index ), FCML_DS_16 );
5333  }
5334 
5342  static Operand effd( const Register &base, const Register &index ) {
5343  return addr( EffectiveAddress( base, index ), FCML_DS_32 );
5344  }
5345 
5353  static Operand effq( const Register &base, const Register &index ) {
5354  return addr( EffectiveAddress( base, index ), FCML_DS_64 );
5355  }
5356 
5366  static Operand eff( const Register &base, const Register &index, fcml_uint8_t scaleFactor, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
5367  return addr( EffectiveAddress( base, index, scaleFactor ), sizeOperator );
5368  }
5369 
5378  static Operand effb( const Register &base, const Register &index, fcml_uint8_t scaleFactor ) {
5379  return addr( EffectiveAddress( base, index, scaleFactor ), FCML_DS_8 );
5380  }
5381 
5390  static Operand effw( const Register &base, const Register &index, fcml_uint8_t scaleFactor ) {
5391  return addr( EffectiveAddress( base, index, scaleFactor ), FCML_DS_16 );
5392  }
5393 
5402  static Operand effd( const Register &base, const Register &index, fcml_uint8_t scaleFactor ) {
5403  return addr( EffectiveAddress( base, index, scaleFactor ), FCML_DS_32 );
5404  }
5405 
5414  static Operand effq( const Register &base, const Register &index, fcml_uint8_t scaleFactor ) {
5415  return addr( EffectiveAddress( base, index, scaleFactor ), FCML_DS_64 );
5416  }
5417 
5428  static Operand eff( const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
5429  return addr( EffectiveAddress( base, index, scaleFactor, displacement ), sizeOperator );
5430  }
5431 
5441  static Operand effb( const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement ) {
5442  return addr( EffectiveAddress( base, index, scaleFactor, displacement ), FCML_DS_8 );
5443  }
5444 
5454  static Operand effw( const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement ) {
5455  return addr( EffectiveAddress( base, index, scaleFactor, displacement ), FCML_DS_16 );
5456  }
5457 
5467  static Operand effd( const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement ) {
5468  return addr( EffectiveAddress( base, index, scaleFactor, displacement ), FCML_DS_32 );
5469  }
5470 
5480  static Operand effq( const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement ) {
5481  return addr( EffectiveAddress( base, index, scaleFactor, displacement ), FCML_DS_64 );
5482  }
5483 
5484 };
5485 
5492 class Condition {
5493 
5494 public:
5495 
5516  };
5517 
5523  _conditionType(CONDITION_O),
5524  _isNegation(false) {
5525  }
5526 
5534  Condition( ConditionType type, bool negation = false ) :
5535  _conditionType( type ),
5536  _isNegation( negation ) {
5537  }
5538 
5539 public:
5540 
5546  bool isO() const {
5547  return check( CONDITION_O );
5548  }
5549 
5555  static const Condition O() {
5556  const Condition condition( CONDITION_O );
5557  return condition;
5558  }
5559 
5565  bool isNO() const {
5566  return check( CONDITION_O, true );
5567  }
5568 
5574  static const Condition NO() {
5575  const Condition condition( CONDITION_O );
5576  return condition;
5577  }
5578 
5584  bool isB() const {
5585  return check( CONDITION_B );
5586  }
5587 
5593  static const Condition B() {
5594  const Condition condition( CONDITION_B );
5595  return condition;
5596  }
5597 
5603  bool isNB() const {
5604  return check( CONDITION_B, true );
5605  }
5606 
5612  static const Condition NB() {
5613  const Condition condition( CONDITION_B, true );
5614  return condition;
5615  }
5616 
5622  bool isNAE() const {
5623  return check( CONDITION_B );
5624  }
5625 
5631  static const Condition NAE() {
5632  const Condition condition( CONDITION_B );
5633  return condition;
5634  }
5635 
5641  bool isAE() const {
5642  return check( CONDITION_B, true );
5643  }
5644 
5650  static const Condition AE() {
5651  const Condition condition( CONDITION_B, true );
5652  return condition;
5653  }
5654 
5660  bool isC() const {
5661  return check( CONDITION_B );
5662  }
5663 
5669  static const Condition C() {
5670  const Condition condition( CONDITION_B );
5671  return condition;
5672  }
5673 
5679  bool isNC() const {
5680  return check( CONDITION_B, true );
5681  }
5682 
5688  static const Condition NC() {
5689  const Condition condition( CONDITION_B, true );
5690  return condition;
5691  }
5692 
5698  bool isE() const {
5699  return check( CONDITION_E );
5700  }
5701 
5707  static const Condition E() {
5708  const Condition condition( CONDITION_E );
5709  return condition;
5710  }
5711 
5717  bool isZ() const {
5718  return check( CONDITION_E );
5719  }
5720 
5726  static const Condition Z() {
5727  const Condition condition( CONDITION_E );
5728  return condition;
5729  }
5730 
5736  bool isNE() const {
5737  return check( CONDITION_E, true );
5738  }
5739 
5745  static const Condition NE() {
5746  const Condition condition( CONDITION_E, true );
5747  return condition;
5748  }
5749 
5755  bool isNZ() const {
5756  return check( CONDITION_E, true );
5757  }
5758 
5764  static const Condition NZ() {
5765  const Condition condition( CONDITION_E, true );
5766  return condition;
5767  }
5768 
5774  bool isBE() const {
5775  return check( CONDITION_BE );
5776  }
5777 
5783  static const Condition BE() {
5784  const Condition condition( CONDITION_BE );
5785  return condition;
5786  }
5787 
5793  bool isNA() const {
5794  return check( CONDITION_BE );
5795  }
5796 
5802  static const Condition NA() {
5803  const Condition condition( CONDITION_BE );
5804  return condition;
5805  }
5806 
5812  bool isNBE() const {
5813  return check( CONDITION_BE, true );
5814  }
5815 
5821  static const Condition NBE() {
5822  const Condition condition( CONDITION_BE, true );
5823  return condition;
5824  }
5825 
5831  bool isA() const {
5832  return check( CONDITION_BE, true );
5833  }
5834 
5840  static const Condition A() {
5841  const Condition condition( CONDITION_BE, true );
5842  return condition;
5843  }
5844 
5850  bool isS() const {
5851  return check( CONDITION_S );
5852  }
5853 
5859  static const Condition S() {
5860  const Condition condition( CONDITION_S );
5861  return condition;
5862  }
5863 
5869  bool isNS() const {
5870  return check( CONDITION_S, true );
5871  }
5872 
5878  static const Condition NS() {
5879  const Condition condition( CONDITION_S, true );
5880  return condition;
5881  }
5882 
5888  bool isP() const {
5889  return check( CONDITION_P );
5890  }
5891 
5897  static const Condition P() {
5898  const Condition condition( CONDITION_P );
5899  return condition;
5900  }
5901 
5907  bool isPE() const {
5908  return check( CONDITION_P );
5909  }
5910 
5916  static const Condition PE() {
5917  const Condition condition( CONDITION_P );
5918  return condition;
5919  }
5920 
5926  bool isNP() const {
5927  return check( CONDITION_P, true );
5928  }
5929 
5935  static const Condition NP() {
5936  const Condition condition( CONDITION_P, true );
5937  return condition;
5938  }
5939 
5945  bool isPO() const {
5946  return check( CONDITION_P, true );
5947  }
5948 
5954  static const Condition PO() {
5955  const Condition condition( CONDITION_P, true );
5956  return condition;
5957  }
5958 
5964  bool isL() const {
5965  return check( CONDITION_L );
5966  }
5967 
5973  static const Condition L() {
5974  const Condition condition( CONDITION_L );
5975  return condition;
5976  }
5977 
5983  bool isNGE() const {
5984  return check( CONDITION_L );
5985  }
5986 
5992  static const Condition NGE() {
5993  const Condition condition( CONDITION_L );
5994  return condition;
5995  }
5996 
6002  bool isNL() const {
6003  return check( CONDITION_L, true );
6004  }
6005 
6011  static const Condition NL() {
6012  const Condition condition( CONDITION_L, true );
6013  return condition;
6014  }
6015 
6021  bool isGE() const {
6022  return check( CONDITION_L, true );
6023  }
6024 
6030  static const Condition GE() {
6031  const Condition condition( CONDITION_L, true );
6032  return condition;
6033  }
6034 
6040  bool isLE() const {
6041  return check( CONDITION_LE );
6042  }
6043 
6049  static const Condition LE() {
6050  const Condition condition( CONDITION_LE );
6051  return condition;
6052  }
6053 
6059  bool isNG() const {
6060  return check( CONDITION_LE );
6061  }
6062 
6068  static const Condition NG() {
6069  const Condition condition( CONDITION_LE );
6070  return condition;
6071  }
6072 
6078  bool isNLE() const {
6079  return check( CONDITION_LE, true );
6080  }
6081 
6087  static const Condition NLE() {
6088  const Condition condition( CONDITION_LE, true );
6089  return condition;
6090  }
6091 
6097  bool isG() const {
6098  return check( CONDITION_LE, true );
6099  }
6100 
6106  static const Condition G() {
6107  const Condition condition( CONDITION_LE, true );
6108  return condition;
6109  }
6110 
6111 public:
6112 
6120  bool operator==( const Condition &cond ) const {
6121  return cond._conditionType == _conditionType && cond._isNegation == _isNegation;
6122  }
6123 
6131  bool operator!=( const Condition &cond ) const {
6132  return !(*this == cond);
6133  }
6134 
6135 public:
6136 
6144  return _conditionType;
6145  }
6146 
6154  _conditionType = conditionType;
6155  return *this;
6156  }
6157 
6164  bool isNegation() const {
6165  return _isNegation;
6166  }
6167 
6175  _isNegation = isNegation;
6176  return *this;
6177  }
6178 
6179 private:
6180 
6189  bool check( ConditionType type, bool negation = false ) const {
6190  return _conditionType == type && _isNegation == negation;
6191  }
6192 
6193 private:
6194 
6195  /* Condition type.*/
6196  ConditionType _conditionType;
6197  /* True if condition should be negated.*/
6198  bool _isNegation;
6199 
6200 };
6201 
6208 public:
6209 
6215  _prefixes(0),
6216  _hints(FCML_HINT_NO_HINTS),
6217  _isConditional(false),
6218  _operandsCount(0) {
6219  }
6220 
6227  Instruction( const fcml_cstring &mnemonic ) :
6228  _prefixes(0),
6229  _hints(FCML_HINT_NO_HINTS),
6230  _mnemonic(mnemonic),
6231  _isConditional(false),
6232  _operandsCount(0) {
6233  }
6234 
6235 public:
6236 
6244  void add( const Operand &operand ) {
6245  if( _operandsCount == FCML_OPERANDS_COUNT ) {
6246  throw IllegalStateException( FCML_TEXT( "No more operands allowed." ) );
6247  }
6248  _operands[_operandsCount++] = operand;
6249  }
6250 
6259  void setOperand( const Operand &operand, fcml_int index ) {
6260  if( index >= FCML_OPERANDS_COUNT ) {
6261  throw IllegalStateException( FCML_TEXT( "Operand's number exceeds maximal number of operands allowed." ) );
6262  }
6263  _operands[index] = operand;
6264  }
6265 
6273  const Operand & operator[]( fcml_int index ) const {
6274  checkArrayAccess(index);
6275  return _operands[index];
6276  }
6277 
6285  Operand & operator[]( fcml_int index ) {
6286  checkArrayAccess(index);
6287  return _operands[index];
6288  }
6289 
6294  void clean() {
6295  for( int i = 0; i < FCML_OPERANDS_COUNT; i++ ) {
6296  // Clean the operand.
6297  _operands[i] = Operand();
6298  }
6299  _operandsCount = 0;
6300  }
6301 
6302 public:
6303 
6310  const Condition& getCondition() const {
6311  return _condition;
6312  }
6313 
6321  return _condition;
6322  }
6323 
6331  Instruction& setCondition( const Condition &condition ) {
6332  _condition = condition;
6333  return *this;
6334  }
6335 
6343  return _hints;
6344  }
6345 
6354  _hints = hints;
6355  return *this;
6356  }
6357 
6364  bool isConditional() const {
6365  return _isConditional;
6366  }
6367 
6376  _isConditional = isConditional;
6377  return *this;
6378  }
6379 
6386  const fcml_cstring& getMnemonic() const {
6387  return _mnemonic;
6388  }
6389 
6397  Instruction& setMnemonic( const fcml_cstring &mnemonic ) {
6398  _mnemonic = mnemonic;
6399  return *this;
6400  }
6401 
6408  fcml_int getOperandsCount() const {
6409  return _operandsCount;
6410  }
6411 
6419  Instruction& setOperandsCount( fcml_int operandsCount ) {
6420  _operandsCount = operandsCount;
6421  return *this;
6422  }
6423 
6431  return _prefixes;
6432  }
6433 
6442  _prefixes = prefixes;
6443  return *this;
6444  }
6445 
6446 public:
6447 
6448  // Helper methods to identify prefixes and hints.
6449 
6455  bool isLock() const {
6456  return ( _prefixes & FCML_PREFIX_LOCK ) ? true : false;
6457  }
6458 
6464  bool isRepne() const {
6465  return ( _prefixes & FCML_PREFIX_REPNE ) ? true : false;
6466  }
6467 
6473  bool isRepnz() const {
6474  return ( _prefixes & FCML_PREFIX_REPNZ ) ? true : false;
6475  }
6476 
6482  bool isRep() const {
6483  return ( _prefixes & FCML_PREFIX_REP ) ? true : false;
6484  }
6485 
6491  bool isRepe() const {
6492  return ( _prefixes & FCML_PREFIX_REPE ) ? true : false;
6493  }
6494 
6500  bool isRepz() const {
6501  return ( _prefixes & FCML_PREFIX_REPZ ) ? true : false;
6502  }
6503 
6509  bool isXAcquire() const {
6510  return ( _prefixes & FCML_PREFIX_XACQUIRE ) ? true : false;
6511  }
6512 
6518  bool isXRelease() const {
6519  return ( _prefixes & FCML_PREFIX_XRELEASE ) ? true : false;
6520  }
6521 
6527  bool isBranchHint() const {
6528  return ( _prefixes & FCML_PREFIX_BRANCH_HINT ) ? true : false;
6529  }
6530 
6536  bool isNoBranchHint() const {
6537  return ( _prefixes & FCML_PREFIX_NOBRANCH_HINT ) ? true : false;
6538  }
6539 
6545  bool isFarPointer() const {
6546  return ( _hints & FCML_HINT_FAR_POINTER ) ? true : false;
6547  }
6548 
6554  bool isNearPointer() const {
6555  return ( _hints & FCML_HINT_NEAR_POINTER ) ? true : false;
6556  }
6557 
6563  bool isLongFormPointer() const {
6564  return ( _hints & FCML_HINT_LONG_FORM_POINTER ) ? true : false;
6565  }
6566 
6572  bool isIndirectPointer() const {
6573  return ( _hints & FCML_HINT_INDIRECT_POINTER ) ? true : false;
6574  }
6575 
6581  bool isDirectPointer() const {
6582  return ( _hints & FCML_HINT_DIRECT_POINTER ) ? true : false;
6583  }
6584 
6585 private:
6586 
6592  void checkArrayAccess( fcml_int index) const {
6593  if( index < 0 || index >= FCML_OPERANDS_COUNT ) {
6594  throw BadArgumentException( FCML_TEXT( "Index exceeds the allowed number of operands." ) );
6595  }
6596  }
6597 
6598 private:
6599 
6601  fcml_prefixes _prefixes;
6603  fcml_hints _hints;
6605  fcml_cstring _mnemonic;
6607  bool _isConditional;
6609  Condition _condition;
6611  Operand _operands[FCML_OPERANDS_COUNT];
6613  fcml_int _operandsCount;
6614 
6615 };
6616 
6624 class IB {
6625 
6626 public:
6627 
6633  IB( const fcml_cstring &mnemonic ) :
6634  _hints(FCML_HINT_NO_HINTS),
6635  _prefixes(0),
6636  _mnemonic(mnemonic),
6637  _operandsCount(0) {
6638  }
6639 
6647  IB( fcml_prefixes prefixes, const fcml_cstring &mnemonic ) :
6648  _hints(FCML_HINT_NO_HINTS),
6649  _prefixes(prefixes),
6650  _mnemonic(mnemonic),
6651  _operandsCount(0) {
6652  }
6653 
6661  IB( const fcml_cstring &mnemonic, fcml_hints hints) :
6662  _hints(hints),
6663  _prefixes(0),
6664  _mnemonic(mnemonic),
6665  _operandsCount(0) {
6666  }
6667 
6676  IB( fcml_prefixes prefixes, const fcml_cstring &mnemonic, fcml_hints hints ) :
6677  _hints(hints),
6678  _prefixes(prefixes),
6679  _mnemonic(mnemonic),
6680  _operandsCount(0) {
6681  }
6682 
6688  operator Instruction() const {
6689  return build();
6690  }
6691 
6698  Instruction build() const {
6699  Instruction instruction(_mnemonic);
6700  instruction.setHints(_hints);
6701  instruction.setPrefixes(_prefixes);
6702  instruction.setOperandsCount(_operandsCount);
6703  for( int i = 0; i < FCML_OPERANDS_COUNT; i++ ) {
6704  instruction.setOperand( _operands[i], i );
6705  }
6706  return instruction;
6707  }
6708 
6716  void op( const Operand &operand ) {
6717  if( _operandsCount == FCML_OPERANDS_COUNT ) {
6718  throw IllegalStateException( FCML_TEXT( "No more operands allowed." ) );
6719  }
6720  _operands[_operandsCount++] = operand;
6721  }
6722 
6730  static IB inst( const fcml_cstring &mnemonic ) {
6731  return IB(mnemonic);
6732  }
6733 
6734  // Hints.
6735 
6743  static const InstructionHint FAR_PTR() {
6745  }
6746 
6752  IB& farPtr() {
6753  _hints |= FCML_HINT_FAR_POINTER;
6754  return *this;
6755  }
6756 
6764  static const InstructionHint NEAR_PTR() {
6766  }
6767 
6774  _hints |= FCML_HINT_NEAR_POINTER;
6775  return *this;
6776  }
6777 
6787  }
6788 
6795  _hints |= FCML_HINT_LONG_FORM_POINTER;
6796  return *this;
6797  }
6798 
6808  }
6809 
6816  _hints |= FCML_HINT_INDIRECT_POINTER;
6817  return *this;
6818  }
6819 
6827  static const InstructionHint DIRECT_PTR() {
6829  }
6830 
6837  _hints |= FCML_HINT_DIRECT_POINTER;
6838  return *this;
6839  }
6840 
6841  // Prefixes.
6842 
6850  static const InstructionPrefix LOCK() {
6851  return InstructionPrefix::LOCK();
6852  }
6853 
6859  IB& lock() {
6860  _prefixes |= FCML_PREFIX_LOCK;
6861  return *this;
6862  }
6863 
6871  static const InstructionPrefix REPNE() {
6872  return InstructionPrefix::REPNE();
6873  }
6874 
6880  IB& repne() {
6881  _prefixes |= FCML_PREFIX_REPNE;
6882  return *this;
6883  }
6884 
6892  static const InstructionPrefix REPNZ() {
6893  return InstructionPrefix::REPNZ();
6894  }
6895 
6901  IB& repnz() {
6902  _prefixes |= FCML_PREFIX_REPNZ;
6903  return *this;
6904  }
6905 
6913  static const InstructionPrefix REP() {
6914  return InstructionPrefix::REP();
6915  }
6916 
6922  IB& rep() {
6923  _prefixes |= FCML_PREFIX_REP;
6924  return *this;
6925  }
6926 
6934  static const InstructionPrefix REPE() {
6935  return InstructionPrefix::REPE();
6936  }
6937 
6943  IB& repe() {
6944  _prefixes |= FCML_PREFIX_REPE;
6945  return *this;
6946  }
6947 
6955  static const InstructionPrefix REPZ() {
6956  return InstructionPrefix::REPZ();
6957  }
6958 
6964  IB& repz() {
6965  _prefixes |= FCML_PREFIX_REPZ;
6966  return *this;
6967  }
6968 
6976  static const InstructionPrefix XACQUIRE() {
6977  return InstructionPrefix::XACQUIRE();
6978  }
6979 
6986  _prefixes |= FCML_PREFIX_XACQUIRE;
6987  return *this;
6988  }
6989 
6997  static const InstructionPrefix XRELEASE() {
6998  return InstructionPrefix::XRELEASE();
6999  }
7000 
7007  _prefixes |= FCML_PREFIX_XRELEASE;
7008  return *this;
7009  }
7010 
7018  static const InstructionPrefix BRANCH() {
7020  }
7021 
7028  _prefixes |= FCML_PREFIX_BRANCH_HINT;
7029  return *this;
7030  }
7031 
7039  static const InstructionPrefix NO_BRANCH() {
7041  }
7042 
7049  _prefixes |= FCML_PREFIX_NOBRANCH_HINT;
7050  return *this;
7051  }
7052 
7058  return OperandHint::MULTIMEDIA();
7059  }
7060 
7067  }
7068 
7075  }
7076 
7081  static const OperandHint OP_SIB_ENCODING() {
7082  return OperandHint::SIB_ENCODING();
7083  }
7084 
7090  set( OP_MULTIMEDIA_HINT() );
7091  return *this;
7092  }
7093 
7099  set( OP_MULTIMEDIA_HINT() );
7100  return *this;
7101  }
7102 
7108  set( OP_MULTIMEDIA_HINT() );
7109  return *this;
7110  }
7111 
7117  set( OP_MULTIMEDIA_HINT() );
7118  return *this;
7119  }
7120 
7121  // Operands.
7122 
7128  IB& imm( const Integer &imm ) {
7129  sanityCheck();
7130  _operands[_operandsCount++].imm(imm);
7131  return *this;
7132  }
7133 
7141  IB& far_ptr( fcml_uint16_t seg, fcml_int16_t addr ) {
7142  sanityCheck();
7143  _operands[_operandsCount++].far_ptr(seg, addr);
7144  return *this;
7145  }
7146 
7154  IB& far_ptr( fcml_uint16_t seg, fcml_int32_t addr ) {
7155  sanityCheck();
7156  _operands[_operandsCount++].far_ptr(seg, addr);
7157  return *this;
7158  }
7159 
7166  IB& far_ptr( const FarPointer &pointer ) {
7167  sanityCheck();
7168  _operands[_operandsCount++].far_ptr( pointer );
7169  return *this;
7170  }
7171 
7178  IB& addr( const Address &address ) {
7179  sanityCheck();
7180  _operands[_operandsCount++].addr(address);
7181  return *this;
7182  }
7183 
7191  IB& off( const Integer &offset, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
7192  sanityCheck();
7193  _operands[_operandsCount++].off( offset, sizeOperator );
7194  return *this;
7195  }
7196 
7203  IB& offb( const Integer &offset ) {
7204  sanityCheck();
7205  _operands[_operandsCount++].off( offset, FCML_DS_8 );
7206  return *this;
7207  }
7208 
7215  IB& offw( const Integer &offset ) {
7216  sanityCheck();
7217  _operands[_operandsCount++].off( offset, FCML_DS_16 );
7218  return *this;
7219  }
7220 
7227  IB& offd( const Integer &offset ) {
7228  sanityCheck();
7229  _operands[_operandsCount++].off( offset, FCML_DS_32 );
7230  return *this;
7231  }
7232 
7239  IB& offq( const Integer &offset ) {
7240  sanityCheck();
7241  _operands[_operandsCount++].off( offset, FCML_DS_64 );
7242  return *this;
7243  }
7244 
7252  IB& addr( const EffectiveAddress &effectiveAddress, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
7253  sanityCheck();
7254  _operands[_operandsCount++].addr( effectiveAddress, sizeOperator );
7255  return *this;
7256  }
7257 
7264  IB& addrb( const EffectiveAddress &effectiveAddress ) {
7265  sanityCheck();
7266  _operands[_operandsCount++].addr( effectiveAddress, FCML_DS_8 );
7267  return *this;
7268  }
7269 
7276  IB& addrw( const EffectiveAddress &effectiveAddress ) {
7277  sanityCheck();
7278  _operands[_operandsCount++].addr( effectiveAddress, FCML_DS_16 );
7279  return *this;
7280  }
7281 
7288  IB& addrd( const EffectiveAddress &effectiveAddress ) {
7289  sanityCheck();
7290  _operands[_operandsCount++].addr( effectiveAddress, FCML_DS_32 );
7291  return *this;
7292  }
7293 
7300  IB& addrq( const EffectiveAddress &effectiveAddress ) {
7301  sanityCheck();
7302  _operands[_operandsCount++].addr( effectiveAddress, FCML_DS_64 );
7303  return *this;
7304  }
7305 
7314  IB& addr( const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
7315  sanityCheck();
7316  _operands[_operandsCount++].addr( effectiveAddress, segmentSelector, sizeOperator );
7317  return *this;
7318  }
7319 
7327  IB& addrb( const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector ) {
7328  sanityCheck();
7329  _operands[_operandsCount++].addr( effectiveAddress, segmentSelector, FCML_DS_8 );
7330  return *this;
7331  }
7332 
7340  IB& addrw( const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector ) {
7341  sanityCheck();
7342  _operands[_operandsCount++].addr( effectiveAddress, segmentSelector, FCML_DS_8 );
7343  return *this;
7344  }
7345 
7353  IB& addrd( const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector ) {
7354  sanityCheck();
7355  _operands[_operandsCount++].addr( effectiveAddress, segmentSelector, FCML_DS_8 );
7356  return *this;
7357  }
7358 
7366  IB& addrq( const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector ) {
7367  sanityCheck();
7368  _operands[_operandsCount++].addr( effectiveAddress, segmentSelector, FCML_DS_8 );
7369  return *this;
7370  }
7371 
7378  IB& reg( const Register &reg ) {
7379  sanityCheck();
7380  _operands[_operandsCount++].reg( reg );
7381  return *this;
7382  }
7383 
7393  IB& reg( fcml_uint8_t reg, fcml_usize size, Register::RegisterType type = Register::REG_GPR, fcml_bool x64_exp = FCML_FALSE ) {
7394  sanityCheck();
7395  _operands[_operandsCount++].reg( Register( reg, size, type, x64_exp ) );
7396  return *this;
7397  }
7398 
7406  IB& eff( const Integer &displacement, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
7407  next().addr( EffectiveAddress(displacement), sizeOperator );
7408  return *this;
7409  }
7410 
7417  IB& effb( const Integer &displacement ) {
7418  next().addr( EffectiveAddress(displacement), FCML_DS_8 );
7419  return *this;
7420  }
7421 
7428  IB& effw( const Integer &displacement ) {
7429  next().addr( EffectiveAddress(displacement), FCML_DS_16 );
7430  return *this;
7431  }
7432 
7439  IB& effd( const Integer &displacement ) {
7440  next().addr( EffectiveAddress(displacement), FCML_DS_32 );
7441  return *this;
7442  }
7443 
7450  IB& effq( const Integer &displacement ) {
7451  next().addr( EffectiveAddress(displacement), FCML_DS_64 );
7452  return *this;
7453  }
7454 
7462  IB& eff( const Register &base, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
7463  next().addr( EffectiveAddress(base), sizeOperator );
7464  return *this;
7465  }
7466 
7473  IB& effb( const Register &base ) {
7474  next().addr( EffectiveAddress(base), FCML_DS_8 );
7475  return *this;
7476  }
7477 
7484  IB& effw( const Register &base ) {
7485  next().addr( EffectiveAddress(base), FCML_DS_16 );
7486  return *this;
7487  }
7488 
7495  IB& effd( const Register &base ) {
7496  next().addr( EffectiveAddress(base), FCML_DS_32 );
7497  return *this;
7498  }
7499 
7506  IB& effq( const Register &base ) {
7507  next().addr( EffectiveAddress(base), FCML_DS_64 );
7508  return *this;
7509  }
7510 
7519  IB& eff( const Register &base, const Integer &displacement, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
7520  next().addr( EffectiveAddress( base, displacement ), sizeOperator );
7521  return *this;
7522  }
7523 
7531  IB& effb( const Register &base, const Integer &displacement ) {
7532  next().addr( EffectiveAddress( base, displacement ), FCML_DS_8 );
7533  return *this;
7534  }
7535 
7543  IB& effw( const Register &base, const Integer &displacement ) {
7544  next().addr( EffectiveAddress( base, displacement ), FCML_DS_16 );
7545  return *this;
7546  }
7547 
7555  IB& effd( const Register &base, const Integer &displacement ) {
7556  next().addr( EffectiveAddress( base, displacement ), FCML_DS_32 );
7557  return *this;
7558  }
7559 
7567  IB& effq( const Register &base, const Integer &displacement ) {
7568  next().addr( EffectiveAddress( base, displacement ), FCML_DS_64 );
7569  return *this;
7570  }
7571 
7581  IB& eff( const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
7582  next().addr( EffectiveAddress( index, scaleFactor, displacement ), sizeOperator );
7583  return *this;
7584  }
7585 
7594  IB& effb( const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement ) {
7595  next().addr( EffectiveAddress( index, scaleFactor, displacement ), FCML_DS_8 );
7596  return *this;
7597  }
7598 
7607  IB& effw( const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement ) {
7608  next().addr( EffectiveAddress( index, scaleFactor, displacement ), FCML_DS_16 );
7609  return *this;
7610  }
7611 
7620  IB& effd( const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement ) {
7621  next().addr( EffectiveAddress( index, scaleFactor, displacement ), FCML_DS_32 );
7622  return *this;
7623  }
7624 
7633  IB& effq( const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement ) {
7634  next().addr( EffectiveAddress( index, scaleFactor, displacement ), FCML_DS_64 );
7635  return *this;
7636  }
7637 
7646  IB& eff( const Register &base, const Register &index, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
7647  next().addr( EffectiveAddress( base, index ), sizeOperator );
7648  return *this;
7649  }
7650 
7658  IB& effb( const Register &base, const Register &index ) {
7659  next().addr( EffectiveAddress( base, index ), FCML_DS_8 );
7660  return *this;
7661  }
7662 
7670  IB& effw( const Register &base, const Register &index ) {
7671  next().addr( EffectiveAddress( base, index ), FCML_DS_16 );
7672  return *this;
7673  }
7674 
7682  IB& effd( const Register &base, const Register &index ) {
7683  next().addr( EffectiveAddress( base, index ), FCML_DS_32 );
7684  return *this;
7685  }
7686 
7694  IB& effq( const Register &base, const Register &index ) {
7695  next().addr( EffectiveAddress( base, index ), FCML_DS_64 );
7696  return *this;
7697  }
7698 
7708  IB& eff( const Register &base, const Register &index, fcml_uint8_t scaleFactor, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
7709  next().addr( EffectiveAddress( base, index, scaleFactor ), sizeOperator );
7710  return *this;
7711  }
7712 
7721  IB& effb( const Register &base, const Register &index, fcml_uint8_t scaleFactor ) {
7722  next().addr( EffectiveAddress( base, index, scaleFactor ), FCML_DS_8 );
7723  return *this;
7724  }
7725 
7734  IB& effw( const Register &base, const Register &index, fcml_uint8_t scaleFactor ) {
7735  next().addr( EffectiveAddress( base, index, scaleFactor ), FCML_DS_16 );
7736  return *this;
7737  }
7738 
7747  IB& effd( const Register &base, const Register &index, fcml_uint8_t scaleFactor ) {
7748  next().addr( EffectiveAddress( base, index, scaleFactor ), FCML_DS_32 );
7749  return *this;
7750  }
7751 
7760  IB& effq( const Register &base, const Register &index, fcml_uint8_t scaleFactor ) {
7761  next().addr( EffectiveAddress( base, index, scaleFactor ), FCML_DS_64 );
7762  return *this;
7763  }
7764 
7775  IB& eff( const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement, fcml_usize sizeOperator = FCML_DS_UNDEF ) {
7776  next().addr( EffectiveAddress( base, index, scaleFactor, displacement ), sizeOperator );
7777  return *this;
7778  }
7779 
7789  IB& effb( const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement ) {
7790  next().addr( EffectiveAddress( base, index, scaleFactor, displacement ), FCML_DS_8 );
7791  return *this;
7792  }
7793 
7803  IB& effw( const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement ) {
7804  next().addr( EffectiveAddress( base, index, scaleFactor, displacement ), FCML_DS_16 );
7805  return *this;
7806  }
7807 
7817  IB& effd( const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement ) {
7818  next().addr( EffectiveAddress( base, index, scaleFactor, displacement ), FCML_DS_32 );
7819  return *this;
7820  }
7821 
7831  IB& effq( const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement ) {
7832  next().addr( EffectiveAddress( base, index, scaleFactor, displacement ), FCML_DS_64 );
7833  return *this;
7834  }
7835 
7842  IB& operator <<(const Operand &operand) {
7843  next() = operand;
7844  return *this;
7845  }
7846 
7854  return set(prefix);
7855  }
7856 
7864  return set( hint );
7865  }
7866 
7873  IB& operator <<(const OperandHint &hint) {
7874  return set( hint );
7875  }
7876 
7883  IB& set( const InstructionPrefix &prefix ) {
7884  _prefixes |= prefix._prefix;
7885  return *this;
7886  }
7887 
7894  IB& set( const InstructionHint &hint ) {
7895  _hints |= hint._hint;
7896  return *this;
7897  }
7898 
7905  IB& set( const OperandHint &hint ) {
7906  if( _operandsCount == 0 ) {
7907  throw IllegalStateException( FCML_TEXT( "There are no operands yet for the current instruction.." ) );
7908  }
7909  _operands[_operandsCount-1].setHints( _operands[_operandsCount-1].getHints() | hint._hint );
7910  return *this;
7911  }
7912 
7913 private:
7914 
7920  Operand& next() {
7921  sanityCheck();
7922  return _operands[_operandsCount++];
7923  }
7924 
7930  void sanityCheck() const {
7931  if( _operandsCount == FCML_OPERANDS_COUNT ) {
7932  throw IllegalStateException( FCML_TEXT( "Operand's number exceeds maximal number of operands allowed." ) );
7933  }
7934  }
7935 
7936 private:
7937 
7939  fcml_hints _hints;
7941  fcml_prefixes _prefixes;
7943  fcml_cstring _mnemonic;
7945  fcml_int _operandsCount;
7947  Operand _operands[FCML_OPERANDS_COUNT];
7948 
7949 };
7950 
7956 public:
7957 
7958  static void convert( const fcml_st_entry_point &src, EntryPoint &dest ) {
7959  dest.setIP( src.ip );
7960  dest.setOpMode( static_cast<EntryPoint::OperatingMode>( src.op_mode ) );
7963  }
7964 
7965  static void convert( const EntryPoint &src, fcml_st_entry_point &dest ) {
7966  dest.ip = src.getIP();
7967  dest.op_mode = static_cast<fcml_en_operating_mode>( src.getOpMode() );
7970  }
7971 
7972  static void convert( const fcml_st_integer &src, Integer &dest ) {
7973  dest.setInt8( src.int8 );
7974  dest.setInt16( src.int16 );
7975  dest.setInt32( src.int32 );
7976  dest.setInt64( src.int64 );
7977  dest.setSigned( src.is_signed );
7978  dest.setSize( src.size );
7979  }
7980 
7981  static void convert( const Integer &src, fcml_st_integer &dest ) {
7982  dest.int8 = src.getInt8();
7983  dest.int16 = src.getInt16();
7984  dest.int32 = src.getInt32();
7985  dest.int64 = src.getInt64();
7986  dest.is_signed = src.isSigned();
7987  dest.size = src.getSize();
7988  }
7989 
7990  static void convert( const fcml_st_offset &src, Integer &dest ) {
7991  dest.setInt16( src.off16 );
7992  dest.setInt32( src.off32 );
7993  dest.setInt64( src.off64 );
7994  dest.setSigned( src.is_signed );
7995  dest.setSize( src.size );
7996  }
7997 
7998  static void convert( const Integer &src, fcml_st_offset &dest ) {
7999  dest.off16 = src.getSize() == FCML_DS_8 ? src.getInt8() : src.getInt16();
8000  dest.off32 = src.getInt32();
8001  dest.off64 = src.getInt64();
8002  dest.is_signed = src.isSigned();
8003  dest.size = src.getSize();
8004  }
8005 
8006  static void convert( const fcml_st_register &src, Register &dest ) {
8007  dest.setReg( src.reg );
8008  dest.setSize( src.size );
8009  dest.setType( static_cast<Register::RegisterType>( src.type ) );
8010  dest.setX64Exp( src.x64_exp ? true : false );
8011  }
8012 
8013  static void convert( const Register &src, fcml_st_register &dest ) {
8014  dest.reg = src.getReg();
8015  dest.size = src.getSize();
8016  dest.type = static_cast<fcml_en_register>( src.getType() );
8017  dest.x64_exp = src.getX64Exp();
8018  }
8019 
8020  static void convert( const fcml_st_far_pointer &src, FarPointer &dest ) {
8021  dest.setOffset16( src.offset16 );
8022  dest.setOffset32( src.offset32 );
8023  dest.setOffsetSize( src.offset_size );
8024  dest.setSegment( src.segment );
8025  }
8026 
8027  static void convert( const FarPointer &src, fcml_st_far_pointer &dest ) {
8028  dest.offset16 = src.getOffset16();
8029  dest.offset32 = src.getOffset32();
8030  dest.offset_size = src.getOffsetSize();
8031  dest.segment = src.getSegment();
8032  }
8033 
8034  static void convert( const fcml_st_segment_selector &src, SegmentSelector &dest ) {
8035  dest.setDefaultReg( src.is_default_reg ? true : false );
8036  convert( src.segment_selector, dest.getSegmentSelector() );
8037  }
8038 
8039  static void convert( const SegmentSelector &src, fcml_st_segment_selector &dest ) {
8040  dest.is_default_reg = src.isDefaultReg();
8041  convert( src.getSegmentSelector(), dest.segment_selector );
8042  }
8043 
8044  static void convert( const fcml_st_effective_address &src, EffectiveAddress &dest ) {
8045  convert( src.base, dest.getBase() );
8046  convert( src.index, dest.getIndex() );
8047  convert( src.displacement, dest.getDisplacement() );
8048  dest.setScaleFactor(src.scale_factor);
8049  }
8050 
8051  static void convert( const EffectiveAddress &src, fcml_st_effective_address &dest ) {
8052  convert( src.getBase(), dest.base );
8053  convert( src.getIndex(), dest.index );
8054  convert( src.getDisplacement(), dest.displacement );
8055  dest.scale_factor = src.getScaleFactor();
8056  }
8057 
8058  static void convert( const fcml_st_address &src, Address &dest ) {
8059  dest.setAddressForm( static_cast<Address::AddressForm>( src.address_form ) );
8060  dest.setSizeOperator( src.size_operator );
8061  convert( src.segment_selector, dest.getSegmentSelector() );
8062  convert( src.effective_address, dest.getEffectiveAddress() );
8063  convert( src.offset, dest.getOffset() );
8064  }
8065 
8066  static void convert( const Address &src, fcml_st_address &dest ) {
8067  dest.address_form = static_cast<fcml_en_effective_address_form>( src.getAddressForm() );
8068  dest.size_operator = src.getSizeOperator();
8069  convert( src.getSegmentSelector(), dest.segment_selector );
8070  convert( src.getEffectiveAddress(), dest.effective_address );
8071  convert( src.getOffset(), dest.offset );
8072  }
8073 
8074  static void convert( const fcml_st_operand &src, Operand &dest ) {
8075  dest.setHints( src.hints );
8076  dest.setOperandType( static_cast<Operand::OperandType>( src.type ) );
8077  convert( src.reg, dest.getRegister() );
8078  convert( src.address, dest.getAddress() );
8079  convert( src.far_pointer, dest.getFarPointer() );
8080  convert( src.immediate, dest.getImmediate() );
8081  }
8082 
8083  static void convert( const Operand &src, fcml_st_operand &dest ) {
8084  dest.hints = src.getHints();
8085  dest.type = static_cast<fcml_en_operand_type>( src.getOperandType() );
8086  convert( src.getAddress(), dest.address );
8087  convert( src.getFarPointer(), dest.far_pointer );
8088  convert( src.getImmediate(), dest.immediate );
8089  convert( src.getRegister(), dest.reg );
8090  }
8091 
8092  static void convert( const fcml_st_condition &src, Condition &dest ) {
8093  dest.setConditionType( static_cast<Condition::ConditionType>( src.condition_type ) );
8094  dest.setNegation( src.is_negation ? true : false );
8095  }
8096 
8097  static void convert( const Condition &src, fcml_st_condition &dest ) {
8098  dest.condition_type = static_cast<fcml_en_condition_type>( src.getConditionType() );
8099  dest.is_negation = src.isNegation();
8100  }
8101 
8102  static void convert( const fcml_st_instruction &src, Instruction &dest ) {
8103  dest.setMnemonic( src.mnemonic );
8104  convert( src.condition, dest.getCondition() );
8105  dest.setHints( src.hints );
8106  dest.setPrefixes( src.prefixes );
8107  dest.setConditional( src.is_conditional ? true : false );
8108  for( int i = 0; i < FCML_OPERANDS_COUNT; i++ ) {
8109  convert( src.operands[i], dest[i] );
8110  }
8111  dest.setOperandsCount(src.operands_count);
8112  }
8113 
8114  static void convert( const Instruction &src, fcml_st_instruction &dest ) {
8115  // Bear in mind that you are responsible for freeing mnemonic duplicated here.
8116  dest.mnemonic = Env::strDup( src.getMnemonic().c_str() );
8117  convert( src.getCondition(), dest.condition );
8118  dest.hints = src.getHints();
8119  dest.prefixes = src.getPrefixes();
8120  dest.is_conditional = src.isConditional();
8121  for( int i = 0; i < FCML_OPERANDS_COUNT; i++ ) {
8122  convert( src[i], dest.operands[i] );
8123  }
8124  dest.operands_count = src.getOperandsCount();
8125  }
8126 
8127  static void free( fcml_st_instruction &instruction ) {
8128  if( instruction.mnemonic ) {
8129  Env::strFree( instruction.mnemonic );
8130  instruction.mnemonic = NULL;
8131  }
8132  }
8133 };
8134 
8135 }
8136 
8137 #endif //FCML_COMMON_HPP_
fcml_char * mnemonic
Dialect-dependent instruction mnemonic.
Definition: fcml_common.h:617
IB & effw(const Register &base)
Adds an an effective address based operator for a base register and word size operator.
Definition: fcml_common.hpp:7484
EntryPoint()
Creates an empty entry point instance.
Definition: fcml_common.hpp:516
IB & eff(const Integer &displacement, fcml_usize sizeOperator=FCML_DS_UNDEF)
Adds an an effective address based operator for a displacement and optional size operator.
Definition: fcml_common.hpp:7406
An instruction builder.
Definition: fcml_common.hpp:6624
bool operator==(const fcml_uint32_t value) const
Checks if the integer is equal to the passed value.
Definition: fcml_common.hpp:846
bool isNoBranchHint() const
Returns true if no_branch_hint prefix is set.
Definition: fcml_common.hpp:6536
fcml_ip ip
Instruction pointer EIP/RIP.
Definition: fcml_common.h:657
#define FCML_PREFIX_LOCK
LOCK prefix (0xF0)
Definition: fcml_common.h:48
static Operand effw(const Register &base, const Register &index, fcml_uint8_t scaleFactor)
Factory method which creates an effective address based operator for a base register, index register, scale factor and word size operator.
Definition: fcml_common.hpp:5390
static const Register R14()
Factory method for a register.
Definition: fcml_common.hpp:2746
IB & far_ptr(fcml_uint16_t seg, fcml_int32_t addr)
Adds a far pointer operand.
Definition: fcml_common.hpp:7154
static const Register DIL()
Factory method for a register.
Definition: fcml_common.hpp:2286
static FarPointer off32(fcml_uint16_t segment, fcml_int32_t offset)
Creates FarPointer instance for 16 bit segment and 32-bit offset.
Definition: fcml_common.hpp:3252
static const Register RIP()
Factory method for a register.
Definition: fcml_common.hpp:3126
static Operand reg(const Register &reg)
Factory method which creates an register based operator for given register.
Definition: fcml_common.hpp:5065
bool isPE() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5907
static const Register YMM6()
Factory method for a register.
Definition: fcml_common.hpp:2266
static const Register EDX()
Factory method for a register.
Definition: fcml_common.hpp:1916
static Operand offb(const Integer &offset)
Factory method which builds an offset based address operand with byte size operator.
Definition: fcml_common.hpp:4918
bool isAddr() const
Returns true if operand is an address operand.
Definition: fcml_common.hpp:4529
void reg(const Register &reg)
Prepares operator for the given register.
Definition: fcml_common.hpp:4482
IB & effd(const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement)
Adds an an effective address based operator for an index register, scaleFactor, displacement and doub...
Definition: fcml_common.hpp:7620
fcml_hints getHints() const
Gets instruction level hits associated with the instruction.
Definition: fcml_common.hpp:6342
static const Register R9W()
Factory method for a register.
Definition: fcml_common.hpp:2426
EffectiveAddress & setScaleFactor(fcml_uint8_t scaleFactor)
Sets a new scale factor for the effective address.
Definition: fcml_common.hpp:3826
static const Condition S()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5859
fcml_usize getAddressSizeAttribute() const
Gets address size attribute held by the entry point.
Definition: fcml_common.hpp:576
Describes segment register.
Definition: fcml_common.h:487
static Operand eff(const Register &base, const Register &index, fcml_uint8_t scaleFactor, fcml_usize sizeOperator=FCML_DS_UNDEF)
Factory method which creates an effective address based operator for a base register, index register, scale factor and optional size operator.
Definition: fcml_common.hpp:5366
IB & eff(const Register &base, fcml_usize sizeOperator=FCML_DS_UNDEF)
Adds an an effective address based operator for a base register and optional size operator...
Definition: fcml_common.hpp:7462
static Operand addrb(const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector)
Factory method which creates address type operand for given effective address and byte size operator...
Definition: fcml_common.hpp:5022
static const Register CX()
Factory method for a register.
Definition: fcml_common.hpp:1836
IB & lock()
Sets a prefix described by the name of the method for the instruction being built.
Definition: fcml_common.hpp:6859
Register()
Creates an empty register instance.
Definition: fcml_common.hpp:1603
bool isZ() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5717
Address(const Integer &offset, fcml_usize sizeOperator=FCML_DS_UNDEF)
Creates an address instance with an offset and optional size operator set.
Definition: fcml_common.hpp:3879
static const InstructionPrefix REPNE()
Creates a prefix instance described by the name of the method.
Definition: fcml_common.hpp:6871
static const Register ESP()
Factory method for a register.
Definition: fcml_common.hpp:2066
bool operator==(const fcml_uint16_t value) const
Checks if the integer is equal to the passed value.
Definition: fcml_common.hpp:824
IB & xacquire()
Sets a prefix described by the name of the method for the instruction being built.
Definition: fcml_common.hpp:6985
static const OperandHint OP_SIB_ENCODING()
Gets SIB encoding hint for the operand.
Definition: fcml_common.hpp:7081
Integer & setSigned(fcml_bool isSigned)
Definition: fcml_common.hpp:779
static const Register SS()
Factory method for a register.
Definition: fcml_common.hpp:2856
#define FCML_PREFIX_REPNE
REPNE prefix (0xF2)
Definition: fcml_common.h:50
Operand not used.
Definition: fcml_common.hpp:4255
static const Register DH()
Factory method for a register.
Definition: fcml_common.hpp:2196
fcml_usize operand_size_attribute
Default operand size attribute (See 'D' flag of segment descriptor.)
Definition: fcml_common.h:655
fcml_usize getOffsetSize() const
Gets offset size.
Definition: fcml_common.hpp:3264
Defines instruction's condition.
Definition: fcml_common.h:370
static const Condition PO()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5954
static Integer uint64(fcml_uint64_t value)
Factory method which creates an insatnce fo the Integer for given parameter.
Definition: fcml_common.hpp:1358
Effective address combined from address components like base register, index registers, factor, displacement etc...
Definition: fcml_common.h:451
bool isIndirectPointer() const
Returns true if indirect pointer hint is set.
Definition: fcml_common.hpp:6572
bool isG() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:6097
EffectiveAddress()
Creates an empry effective address.
Definition: fcml_common.hpp:3514
bool isDisRelativeAddress() const
Returns true if it's an displacement relative address.
Definition: fcml_common.hpp:4734
Direct far pointer.
Definition: fcml_common.hpp:4259
IB & effw(const Register &base, const Register &index, fcml_uint8_t scaleFactor)
Adds an an effective address based operator for a base register, index register, scale factor and wor...
Definition: fcml_common.hpp:7734
fcml_uint16_t segment
16-bit Code segment.
Definition: fcml_common.h:428
fcml_int16_t offset16
16-bit offset.
Definition: fcml_common.h:432
static const Register YMM7()
Factory method for a register.
Definition: fcml_common.hpp:2346
static Address effective(const Register &base, const Register &index, fcml_usize sizeOperator=FCML_DS_UNDEF)
Factory method which creates an effective address instance with the base register and index register...
Definition: fcml_common.hpp:3969
Segment register.
Definition: fcml_common.hpp:1590
IB & eff(const Register &base, const Register &index, fcml_usize sizeOperator=FCML_DS_UNDEF)
Adds an an effective address based operator for a base register, index register and optional size ope...
Definition: fcml_common.hpp:7646
static IB inst(const fcml_cstring &mnemonic)
Factory method that can be used to create instruction builder.
Definition: fcml_common.hpp:6730
fcml_en_register
Register type.
Definition: fcml_common.h:303
static const Register R9L()
Factory method for a register.
Definition: fcml_common.hpp:2416
Instruction & setOperandsCount(fcml_int operandsCount)
Sets number of operands available in the instruction.
Definition: fcml_common.hpp:6419
bool operator!=(const FarPointer &fp) const
Compares two far pointers.
Definition: fcml_common.hpp:3227
bool isNC() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5679
Operand & setRegister(const Register &reg)
Sets a new register for the operand.
Definition: fcml_common.hpp:4688
Illegal state exception.
Definition: fcml_common.hpp:228
void setSegmentSelector(const Register &segmentSelector)
Sets segment register for the selector.
Definition: fcml_common.hpp:3490
static const Register DR0()
Factory method for a register.
Definition: fcml_common.hpp:3026
Two way conversion for common types.
Definition: fcml_common.hpp:7955
void setIP(fcml_ip ip)
Sets a new instruction pointer for the entry point.
Definition: fcml_common.hpp:626
void setOperandSizeAttribute(fcml_usize operandSizeAttribute)
Sets a new operand size attribute for the entry point.
Definition: fcml_common.hpp:606
fcml_st_integer immediate
Immediate value operand.
Definition: fcml_common.h:573
static Operand effd(const Integer &displacement)
Factory method which creates an effective address based operator for a displacement and double word s...
Definition: fcml_common.hpp:5119
static Operand effq(const Register &base)
Factory method which creates an effective address based operator for a base register and quadro word ...
Definition: fcml_common.hpp:5180
static Integer uint16(fcml_uint16_t value)
Factory method which creates an instance fo the Integer for given parameter.
Definition: fcml_common.hpp:1318
#define FCML_PREFIX_REPZ
REPZ prefix (0xF3)
Definition: fcml_common.h:58
void setX64Exp(bool x64Exp)
Sets x64exp flag, see manual.
Definition: fcml_common.hpp:1713
static const Register ES()
Factory method for a register.
Definition: fcml_common.hpp:2836
static const Register DL()
Factory method for a register.
Definition: fcml_common.hpp:1896
const EffectiveAddress & getEffectiveAddress() const
Gets reference to the constant effective address associated with the address.
Definition: fcml_common.hpp:4118
virtual ~Address()
Definition: fcml_common.hpp:3914
static const Condition GE()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:6030
static const Register YMM13()
Factory method for a register.
Definition: fcml_common.hpp:2706
static const Register YMM8()
Factory method for a register.
Definition: fcml_common.hpp:2406
6 Less than
Definition: fcml_common.h:362
fcml_ip getIP() const
Gets instruction pointer held by the entry point.
Definition: fcml_common.hpp:616
IB & nobranchHint()
Sets a prefix described by the name of the method for the instruction being built.
Definition: fcml_common.hpp:7048
static const OperandHint MULTIMEDIA()
Creates operand level hint: MULTIMEDIA_INSTRUCTION.
Definition: fcml_common.hpp:453
static const Register CH()
Factory method for a register.
Definition: fcml_common.hpp:2116
fcml_bool x64_exp
In case of SPL,BPL,SIL,DIL GPR registers has to be set to true.
Definition: fcml_common.h:333
Control register.
Definition: fcml_common.h:315
Condition(ConditionType type, bool negation=false)
Creates a condition for given parameters.
Definition: fcml_common.hpp:5534
Segment register.
Definition: fcml_common.h:313
bool operator!=(const fcml_uint64_t value) const
Checks if the integer is not equal to the passed value.
Definition: fcml_common.hpp:967
Describes segment register.
Definition: fcml_common.hpp:3355
Operand & setImmediate(const Integer &immediate)
Sets a new immediate value for the address.
Definition: fcml_common.hpp:4634
static const Register RBP()
Factory method for a register.
Definition: fcml_common.hpp:2156
SegmentSelector & getSegmentSelector()
Gets the segment selector associated with the address.
Definition: fcml_common.hpp:4192
fcml_uint8_t getScaleFactor() const
Gets a scale factor value associated with the effective address.
Definition: fcml_common.hpp:3815
virtual ~Register()
Definition: fcml_common.hpp:1640
static const Register RDX()
Factory method for a register.
Definition: fcml_common.hpp:1926
static const InstructionPrefix LOCK()
Creates a prefix instance described by the name of the method.
Definition: fcml_common.hpp:6850
static const Register XMM2()
Factory method for a register.
Definition: fcml_common.hpp:1946
bool operator!=(const fcml_uint32_t value) const
Checks if the integer is not equal to the passed value.
Definition: fcml_common.hpp:945
bool isB() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5584
bool isNL() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:6002
IB & operator<<(const Operand &operand)
Adds an operand to the instruction being built.
Definition: fcml_common.hpp:7842
Address operand.
Definition: fcml_common.hpp:3847
x86 - 64 register representation.
Definition: fcml_common.hpp:1574
static const Register R12W()
Factory method for a register.
Definition: fcml_common.hpp:2606
fcml_st_segment_selector segment_selector
Segment register.
Definition: fcml_common.h:503
static EffectiveAddress addr(const Register &base, const Register &index)
Factory method which creates an effective address instance with the base register and index register...
Definition: fcml_common.hpp:3684
static const Register MM1()
Factory method for a register.
Definition: fcml_common.hpp:1866
IB & effq(const Register &base, const Register &index, fcml_uint8_t scaleFactor)
Adds an an effective address based operator for a base register, index register, scale factor and qua...
Definition: fcml_common.hpp:7760
static Operand addrq(const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector)
Factory method which creates address type operand for given effective address and quadro word size op...
Definition: fcml_common.hpp:5055
IB & effq(const Register &base, const Register &index)
Adds an an effective address based operator for a base register, index register and quadro word size ...
Definition: fcml_common.hpp:7694
fcml_en_operand_type
Supported operand types.
Definition: fcml_common.h:513
const Address & getAddress() const
Gets reference to the constant address associated with the operand.
Definition: fcml_common.hpp:4549
void incrementIP(fcml_ip ip)
Increments the instruction pointer by given number of bytes.
Definition: fcml_common.hpp:656
bool isNegation() const
Returns true if condition is negated.
Definition: fcml_common.hpp:6164
bool isEffectiveAddress() const
Returns true if address holds effective address.
Definition: fcml_common.hpp:4075
bool operator==(const Register &reg) const
Compares registers.
Definition: fcml_common.hpp:1725
static Address offset(const Integer &offset, fcml_usize sizeOperator=FCML_DS_UNDEF)
Factor method which creates an address instance with an offset and optional size operator set...
Definition: fcml_common.hpp:4063
Relative address.
Definition: fcml_common.h:544
static const InstructionPrefix NO_BRANCH()
Creates a prefix instance described by the name of the method.
Definition: fcml_common.hpp:7039
fcml_uint16_t fcml_hints
Type used for storing instruction and operand hint masks.
Definition: fcml_common.h:85
fcml_bool isSigned() const
Definition: fcml_common.hpp:774
#define FCML_PREFIX_REPE
REPE prefix (0xF3)
Definition: fcml_common.h:56
static Address effective(const Integer &displacement, fcml_usize sizeOperator=FCML_DS_UNDEF)
Factory method which creates an effective address instance with the displacement only.
Definition: fcml_common.hpp:3925
Wraps operand hint and exposes factory methods for instruction hints.
Definition: fcml_common.hpp:436
IB & effb(const Register &base, const Register &index)
Adds an an effective address based operator for a base register, index register and byte size operato...
Definition: fcml_common.hpp:7658
static Operand addrd(const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector)
Factory method which creates address type operand for given effective address and double word size op...
Definition: fcml_common.hpp:5044
static const Condition A()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5840
static Operand eff(const Register &base, fcml_usize sizeOperator=FCML_DS_UNDEF)
Factory method which creates an effective address based operator for a base register and optional siz...
Definition: fcml_common.hpp:5140
Integer & operator-=(const Integer &arg)
Subtraction assignment.
Definition: fcml_common.hpp:1231
EffectiveAddress(const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement)
Creates an effective address instance with the index register, scale factor and displacement.
Definition: fcml_common.hpp:3557
IB & effd(const Register &base, const Register &index)
Adds an an effective address based operator for a base register, index register and double word size ...
Definition: fcml_common.hpp:7682
fcml_usize size
Offset size 16,32 or 64 bits.
Definition: fcml_common.h:459
General purpose register.
Definition: fcml_common.h:307
5 Parity
Definition: fcml_common.h:360
fcml_en_operating_mode
Supported processor operating modes.
Definition: fcml_common.h:73
bool isSIBEncoding() const
Returns true if the SIB byte is used.
Definition: fcml_common.hpp:4775
Integer(fcml_int8_t value)
Definition: fcml_common.hpp:684
Common general purpose utility functions.
Integer & operator/=(const Integer &arg)
Division assignment.
Definition: fcml_common.hpp:1222
bool isReg() const
Returns true if operand is a register operand.
Definition: fcml_common.hpp:4519
static const Register AH()
Factory method for a register.
Definition: fcml_common.hpp:2036
static const InstructionPrefix REPZ()
Creates a prefix instance described by the name of the method.
Definition: fcml_common.hpp:6955
ConditionType
See fcml_st_condition for more details.
Definition: fcml_common.hpp:5499
IB & branchHint()
Sets a prefix described by the name of the method for the instruction being built.
Definition: fcml_common.hpp:7027
IB & addrw(const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector)
Adds an address type operand for given effective address and byte size operator.
Definition: fcml_common.hpp:7340
Integer & setInt64(fcml_int64_t int64)
Definition: fcml_common.hpp:757
void undef()
Converts operand to the undefined one.
Definition: fcml_common.hpp:4378
static const Condition P()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5897
Instruction & setCondition(const Condition &condition)
Sets a new condition for the instruction.
Definition: fcml_common.hpp:6331
Wrapper for nullable value types.
Definition: fcml_common.hpp:120
fcml_hints getHints() const
Gets hits associated with the operand.
Definition: fcml_common.hpp:4699
static const Register DR7()
Factory method for a register.
Definition: fcml_common.hpp:3096
bool isImm() const
Returns true if operand is an immediate value operand.
Definition: fcml_common.hpp:4509
Hints instruction to use FAR pointer to address the memory.
Definition: fcml_common.h:596
bool operator==(const Condition &cond) const
Checks if two condition are equal.
Definition: fcml_common.hpp:6120
bool isDefaultReg() const
Returns true if a register stored in the segment selector is the default one in the context the segme...
Definition: fcml_common.hpp:3450
Instruction pointer register.
Definition: fcml_common.h:319
bool operator==(const Operand &op) const
Checks if two operands are equal or not.
Definition: fcml_common.hpp:4336
static const InstructionHint INDIRECT_PTR()
Creates a hint instance described by the name of the method.
Definition: fcml_common.hpp:6806
static Operand off(const Integer &offset, fcml_usize sizeOperator=FCML_DS_UNDEF)
Factory method which builds an address operand.
Definition: fcml_common.hpp:4908
bool isRep() const
Returns true if rep prefix is set.
Definition: fcml_common.hpp:6482
static const Register ST6()
Factory method for a register.
Definition: fcml_common.hpp:2956
fcml_usize getSize() const
Definition: fcml_common.hpp:785
IB & rep()
Sets a prefix described by the name of the method for the instruction being built.
Definition: fcml_common.hpp:6922
fcml_uint8_t reg
Register itself as a positive integer.
Definition: fcml_common.h:331
bool operator==(const SegmentSelector &segmentSelector) const
Checks if two segment selector are equal.
Definition: fcml_common.hpp:3389
enum fcml_en_address_form fcml_en_effective_address_form
Addressing form.
void addr(const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector, fcml_usize sizeOperator=FCML_DS_UNDEF)
Prepares address operator for given parameters.
Definition: fcml_common.hpp:4471
static Address effective(const EffectiveAddress &effectiveAddress, fcml_usize sizeOperator=FCML_DS_UNDEF)
Factor method which creates an address instance with an effective address and optional size operator ...
Definition: fcml_common.hpp:4051
bool isLongFormPointer() const
Returns true if long form pointer hint is set.
Definition: fcml_common.hpp:6563
bool isNS() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5869
static const OperandHint OP_ABSOLUTE_ADDRESSING()
Gets absolute hint for the operand.
Definition: fcml_common.hpp:7073
fcml_st_integer displacement
Displacement value.
Definition: fcml_common.h:481
#define FCML_TEXT(x)
Used to code literal strings.
Definition: fcml_types.h:61
Integer & operator+=(const Integer &arg)
Addition assignment.
Definition: fcml_common.hpp:1204
bool isLE() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:6040
const Register & getSegmentSelector() const
Gets constant segment register associated with the selector.
Definition: fcml_common.hpp:3470
static const Register R13D()
Factory method for a register.
Definition: fcml_common.hpp:2676
0 Overflow
Definition: fcml_common.h:350
Address & setSizeOperator(fcml_usize sizeOperator)
Sets a new size operator for the address.
Definition: fcml_common.hpp:4224
static const Condition NGE()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5992
EffectiveAddress(const Register &base)
Creates an effective address instance with the base register only.
Definition: fcml_common.hpp:3533
static const Register IP()
Factory method for a register.
Definition: fcml_common.hpp:3106
static const Register YMM9()
Factory method for a register.
Definition: fcml_common.hpp:2466
IB & offb(const Integer &offset)
Adds an offset based address operand with byte size operator.
Definition: fcml_common.hpp:7203
Definitions of common structures used by FCML components.
static const Register DR3()
Factory method for a register.
Definition: fcml_common.hpp:3056
bool isNB() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5603
static const Register DI()
Factory method for a register.
Definition: fcml_common.hpp:2296
static Operand effw(const Register &base, const Register &index)
Factory method which creates an effective address based operator for a base register, index register and word size operator.
Definition: fcml_common.hpp:5331
Encode ModR/M with optional SIB byte if possible.
Definition: fcml_common.h:561
fcml_int8_t getInt8() const
Definition: fcml_common.hpp:763
static const Condition NZ()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5764
IB & effb(const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement)
Adds an an effective address based operator for a base register, index register, scale factor and byt...
Definition: fcml_common.hpp:7789
static const Register EDI()
Factory method for a register.
Definition: fcml_common.hpp:2306
bool isXAcquire() const
Returns true if xacquire prefix is set.
Definition: fcml_common.hpp:6509
static const Condition NP()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5935
static const InstructionPrefix XRELEASE()
Creates a prefix instance described by the name of the method.
Definition: fcml_common.hpp:6997
static const Register XMM9()
Factory method for a register.
Definition: fcml_common.hpp:2456
EntryPoint(OperatingMode opMode, fcml_ip ip=0, fcml_usize addressSizeAttribute=FCML_DS_UNDEF, fcml_usize operandSizeAttribute=FCML_DS_UNDEF)
Creates an entry point instance for given processor operating mode, instruction pointer and optionall...
Definition: fcml_common.hpp:531
IB & effq(const Integer &displacement)
Adds an an effective address based operator for a displacement and quadro byte size operator...
Definition: fcml_common.hpp:7450
bool operator!=(const Address &address) const
Checks if two addresses are equal or not.
Definition: fcml_common.hpp:4024
bool isE() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5698
static SegmentSelector seg(const Register &segmentSelector, bool isDefaultReg)
Creates segment selector for the given register.
Definition: fcml_common.hpp:3437
static const Register R12()
Factory method for a register.
Definition: fcml_common.hpp:2626
FarPointer(fcml_uint16_t segment, fcml_int32_t offset32)
Creates an far pointer instance.
Definition: fcml_common.hpp:3181
Holds instruction pointer, processor operating mode and memory segment flags.
Definition: fcml_common.hpp:499
fcml_int16_t getOffset16() const
Gets the 16-bit offset.
Definition: fcml_common.hpp:3284
void setSegment(fcml_uint16_t segment)
Sets segment selector.
Definition: fcml_common.hpp:3334
static const InstructionPrefix REPZ()
Creates instruction prefix: REPZ.
Definition: fcml_common.hpp:339
static const OperandHint OP_MULTIMEDIA_HINT()
Gets multimedia hint for the operand.
Definition: fcml_common.hpp:7057
static const Register GS()
Factory method for a register.
Definition: fcml_common.hpp:2886
static Operand effq(const Register &base, const Integer &displacement)
Factory method which creates an effective address based operator for a base register, displacement and quadro word size operator.
Definition: fcml_common.hpp:5236
IB & effw(const Integer &displacement)
Adds an an effective address based operator for a displacement and word size operator.
Definition: fcml_common.hpp:7428
static Operand addr(const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector, fcml_usize sizeOperator=FCML_DS_UNDEF)
Factory method which creates address type operand for given segment selector, effective address and o...
Definition: fcml_common.hpp:5011
static Operand effd(const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement)
Factory method which creates an effective address based operator for a base register, index register, scale factor and double word size operator.
Definition: fcml_common.hpp:5467
static const Condition NBE()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5821
static Address effective(const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement, fcml_usize sizeOperator=FCML_DS_UNDEF)
Factory method which creates an effective address instance with the index register, scale factor and displacement.
Definition: fcml_common.hpp:3958
static const Register DR1()
Factory method for a register.
Definition: fcml_common.hpp:3036
Default value set if memory addressing hasn't been configured.
Definition: fcml_common.hpp:3856
bool operator!=(const fcml_int8_t value) const
Checks if the integer is not equal to the passed value.
Definition: fcml_common.hpp:912
OperatingMode getOpMode() const
Gets processor operating mode.
Definition: fcml_common.hpp:636
static const Register ST0()
Factory method for a register.
Definition: fcml_common.hpp:2896
void addr(const EffectiveAddress &effectiveAddress, fcml_usize sizeOperator=FCML_DS_UNDEF)
Prepares an address operand for given effective address and optional size operator.
Definition: fcml_common.hpp:4458
IB & off(const Integer &offset, fcml_usize sizeOperator=FCML_DS_UNDEF)
Adds an offset operand.
Definition: fcml_common.hpp:7191
bool operator==(const fcml_int64_t value) const
Checks if the integer is equal to the passed value.
Definition: fcml_common.hpp:879
bool operator==(const fcml_uint64_t value) const
Checks if the integer is equal to the passed value.
Definition: fcml_common.hpp:868
void setAddressSizeAttribute(fcml_usize addressSizeAttribute)
Sets a new address size attribute for the entry point.
Definition: fcml_common.hpp:586
Generic instruction model.
Definition: fcml_common.h:611
static const Register YMM4()
Factory method for a register.
Definition: fcml_common.hpp:2106
bool operator!=(const fcml_int32_t value) const
Checks if the integer is not equal to the passed value.
Definition: fcml_common.hpp:956
fcml_int32_t offset32
32-bit offset.
Definition: fcml_common.h:434
static Operand eff(const Register &base, const Register &index, fcml_usize sizeOperator=FCML_DS_UNDEF)
Factory method which creates an effective address based operator for a base register, index register and optional size operator.
Definition: fcml_common.hpp:5309
Instruction()
Creates an empty instruction.
Definition: fcml_common.hpp:6214
Register & getBase()
Gets the base register associated with the effective address.
Definition: fcml_common.hpp:3729
IB & repnz()
Sets a prefix described by the name of the method for the instruction being built.
Definition: fcml_common.hpp:6901
Processor register.
Definition: fcml_common.hpp:4263
Instruction pointer register.
Definition: fcml_common.hpp:1596
bool isPseudoOpcode() const
Returns true if it's pseudo opcode operand.
Definition: fcml_common.hpp:4745
IB & effd(const Integer &displacement)
Adds an an effective address based operator for a displacement and double word size operator...
Definition: fcml_common.hpp:7439
void setType(RegisterType type)
Sets the register type.
Definition: fcml_common.hpp:1695
static const Condition Z()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5726
Integer & setSize(fcml_usize size)
Definition: fcml_common.hpp:790
static Operand offd(const Integer &offset)
Factory method which builds an offset based address operand with double word size operator...
Definition: fcml_common.hpp:4938
FPU register.
Definition: fcml_common.hpp:1588
IB & operandSIBEncodingHint()
Sets preferred encoding to SIB for the lastly added ModR/M operand.
Definition: fcml_common.hpp:7116
Operand builder.
Definition: fcml_common.hpp:4838
void add(const Operand &operand)
Adds a new operand to the instruction.
Definition: fcml_common.hpp:6244
IB & effd(const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement)
Adds an an effective address based operator for a base register, index register, scale factor and dou...
Definition: fcml_common.hpp:7817
Address & getAddress()
Gets reference to the address associated with the operand.
Definition: fcml_common.hpp:4559
void addr(const Address &address)
Prepares address operand for given address.
Definition: fcml_common.hpp:4434
bool operator==(const Address &address) const
Checks if two addresses are equal or not.
Definition: fcml_common.hpp:4007
IB & effq(const Register &base)
Adds an an effective address based operator for a base register and quadro word size operator...
Definition: fcml_common.hpp:7506
IB & effw(const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement)
Adds an an effective address based operator for an index register, scaleFactor, displacement and word...
Definition: fcml_common.hpp:7607
Describes far pointer.
Definition: fcml_common.hpp:3148
static Operand effq(const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement)
Factory method which creates an effective address based operator for an index register, scaleFactor, displacement and quadro word size operator.
Definition: fcml_common.hpp:5297
static Operand far_ptr(fcml_uint16_t seg, fcml_int16_t addr)
Factory method which builds a far pointer operand.
Definition: fcml_common.hpp:4866
bool isRepe() const
Returns true if repe prefix is set.
Definition: fcml_common.hpp:6491
#define FCML_PREFIX_XACQUIRE
XACQUIRE prefix (0xF2)
Definition: fcml_common.h:60
static const Register ECX()
Factory method for a register.
Definition: fcml_common.hpp:1846
bool isNearPointer() const
Returns true if near pointer hint is set.
Definition: fcml_common.hpp:6554
Integer & setInt8(fcml_int8_t int8)
Definition: fcml_common.hpp:768
static const Register R11L()
Factory method for a register.
Definition: fcml_common.hpp:2536
bool isAbsoluteAddressing() const
Returns true if it's an absolute offset being set in the operand.
Definition: fcml_common.hpp:4755
Integer & setInt32(fcml_int32_t int32)
Definition: fcml_common.hpp:746
Definition: fcml_assembler.hpp:39
2 Equal
Definition: fcml_common.hpp:5505
Operand & operator[](fcml_int index)
Gets reference to the operand at given index.
Definition: fcml_common.hpp:6285
bool operator!=(const SegmentSelector &segmentSelector) const
Checks if two segment selector are not equal.
Definition: fcml_common.hpp:3400
fcml_bool is_default_reg
Set to true if given segment register is a default one in given context.
Definition: fcml_common.h:491
static Operand offw(const Integer &offset)
Factory method which builds an offset based address operand with word size operator.
Definition: fcml_common.hpp:4928
virtual bool hasNext()=0
Gets true if there is an another element in the iterator.
static const Register XMM1()
Factory method for a register.
Definition: fcml_common.hpp:1876
IB & eff(const Register &base, const Register &index, fcml_uint8_t scaleFactor, fcml_usize sizeOperator=FCML_DS_UNDEF)
Adds an an effective address based operator for a base register, index register, scale factor and opt...
Definition: fcml_common.hpp:7708
Offset should be encoded as relative address.
Definition: fcml_common.h:557
static const InstructionPrefix NOBRANCH_HINT()
Creates instruction prefix: NOBRANCH_HINT.
Definition: fcml_common.hpp:367
static Operand eff(const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement, fcml_usize sizeOperator=FCML_DS_UNDEF)
Factory method which creates an effective address based operator for a base register, index register, scale factor and optional size operator.
Definition: fcml_common.hpp:5428
#define FCML_PREFIX_REPNZ
REPNZ prefix (0xF2)
Definition: fcml_common.h:52
IB & effd(const Register &base, const Register &index, fcml_uint8_t scaleFactor)
Adds an an effective address based operator for a base register, index register, scale factor and dou...
Definition: fcml_common.hpp:7747
bool isNE() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5736
static const Register DS()
Factory method for a register.
Definition: fcml_common.hpp:2866
static Operand imm(const Integer &imm)
Factory method which builds an immediate operand.
Definition: fcml_common.hpp:4855
IB & directPtr()
Sets a hint described by the name of the method for the instruction being built.
Definition: fcml_common.hpp:6836
#define FCML_OPERANDS_COUNT
Maximal number of the instruction operands.
Definition: fcml_common.h:35
Integer & getOffset()
Gets the offset associated with the address.
Definition: fcml_common.hpp:4160
Wraps instruction hint and exposes factory methods for instruction hints.
Definition: fcml_common.hpp:377
static Operand effd(const Register &base, const Register &index)
Factory method which creates an effective address based operator for a base register, index register and double word size operator.
Definition: fcml_common.hpp:5342
IB & addr(const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector, fcml_usize sizeOperator=FCML_DS_UNDEF)
Adds an address type operand for given segment selector, effective address and optional size operator...
Definition: fcml_common.hpp:7314
Integer operator*(const Integer &src) const
Multiplication operator.
Definition: fcml_common.hpp:1262
bool operator!=(const EffectiveAddress &address) const
Checks whether two effective addresses are equal or not.
Definition: fcml_common.hpp:3633
This hint is used only by assembler in order to force it to generate three byte VEX/XOP prefix even i...
Definition: fcml_common.h:600
void clean()
Cleans the instruction by removing all operands from it.
Definition: fcml_common.hpp:6294
bool isOffset() const
Returns true if address holds an offset only.
Definition: fcml_common.hpp:4085
bool operator==(const fcml_int32_t value) const
Checks if the integer is equal to the passed value.
Definition: fcml_common.hpp:857
bool isNA() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5793
static Operand effb(const Register &base, const Register &index)
Factory method which creates an effective address based operator for a base register, index register and byte size operator.
Definition: fcml_common.hpp:5320
EffectiveAddress & setDisplacement(const Integer &displacement)
Sets a new displacement value for the effective address.
Definition: fcml_common.hpp:3772
bool isRelativeAddressing() const
Returns true is relative addressing is used.
Definition: fcml_common.hpp:4765
static const Register XMM3()
Factory method for a register.
Definition: fcml_common.hpp:2016
FarPointer & getFarPointer()
Gets a reference to the far pointer instance associated with the address.
Definition: fcml_common.hpp:4591
IB & indirectPtr()
Sets a hint described by the name of the method for the instruction being built.
Definition: fcml_common.hpp:6815
bool isNLE() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:6078
3 Below or equal
Definition: fcml_common.hpp:5507
Offset should be encoded as absolute address.
Definition: fcml_common.h:553
static const Register XMM10()
Factory method for a register.
Definition: fcml_common.hpp:2516
static const Register BP()
Factory method for a register.
Definition: fcml_common.hpp:2136
static const Register AX()
Factory method for a register.
Definition: fcml_common.hpp:1766
bool isGE() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:6021
bool operator!=(const Register &reg) const
Compares registers.
Definition: fcml_common.hpp:1735
static const Register R14W()
Factory method for a register.
Definition: fcml_common.hpp:2726
static const InstructionPrefix BRANCH_HINT()
Creates instruction prefix: BRANCH_HINT.
Definition: fcml_common.hpp:360
static Integer int32(fcml_int32_t value)
Factory method which creates an insatnce fo the Integer for given parameter.
Definition: fcml_common.hpp:1328
bool isA() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5831
static Operand reg(fcml_uint8_t reg, fcml_usize size, Register::RegisterType type=Register::REG_GPR, fcml_bool x64_exp=FCML_FALSE)
Factory method which creates an register based operator for given parameters.
Definition: fcml_common.hpp:5078
static const Register YMM0()
Factory method for a register.
Definition: fcml_common.hpp:1816
IB & repe()
Sets a prefix described by the name of the method for the instruction being built.
Definition: fcml_common.hpp:6943
Structure describes x86_64 register.
Definition: fcml_common.h:325
Base exception for all exceptions exposed by FCML library.
Definition: fcml_common.hpp:162
static const InstructionPrefix REPNZ()
Creates instruction prefix: REPNZ.
Definition: fcml_common.hpp:318
Instruction operand.
Definition: fcml_common.hpp:4247
static Operand effw(const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement)
Factory method which creates an effective address based operator for a base register, index register, scale factor and word size operator.
Definition: fcml_common.hpp:5454
Hints instruction to use DIRECT memory addressing.
Definition: fcml_common.h:604
static FarPointer off16(fcml_uint16_t segment, fcml_int16_t offset)
Creates FarPointer instance for 16 bit segment and 16-bit offset.
Definition: fcml_common.hpp:3241
static const Register MM2()
Factory method for a register.
Definition: fcml_common.hpp:1936
void setOffset16(fcml_int16_t offset16)
Sets 16-bit offset.
Definition: fcml_common.hpp:3294
static const Register R14D()
Factory method for a register.
Definition: fcml_common.hpp:2736
static const Register MM4()
Factory method for a register.
Definition: fcml_common.hpp:2086
static const Register RBX()
Factory method for a register.
Definition: fcml_common.hpp:1996
7 Less than or equal to
Definition: fcml_common.hpp:5515
Instruction build() const
Builds an instruction instance for the current state of the builder.
Definition: fcml_common.hpp:6698
const SegmentSelector & getSegmentSelector() const
Gets the constant segment selector associated with the address.
Definition: fcml_common.hpp:4182
static Operand effb(const Register &base, const Integer &displacement)
Factory method which creates an effective address based operator for a base register, displacement and byte size operator.
Definition: fcml_common.hpp:5203
static EffectiveAddress addr(const Register &base, const Integer &displacement)
Factory method which creates an effective address instance with the base register and displacement...
Definition: fcml_common.hpp:3663
static const Register ST3()
Factory method for a register.
Definition: fcml_common.hpp:2926
bool isBranchHint() const
Returns true if branch_hint prefix is set.
Definition: fcml_common.hpp:6527
static Integer uint32(fcml_uint32_t value)
Factory method which creates an insatnce fo the Integer for given parameter.
Definition: fcml_common.hpp:1338
IB & operandRelativeHint()
Marks the lastly added address operand as a relative one.
Definition: fcml_common.hpp:7098
static const Condition L()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5973
3 Below or equal
Definition: fcml_common.h:356
IB & addrb(const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector)
Adds an address type operand for given effective address and byte size operator.
Definition: fcml_common.hpp:7327
fcml_en_condition_type
Condition type.
Definition: fcml_common.h:348
IB & repz()
Sets a prefix described by the name of the method for the instruction being built.
Definition: fcml_common.hpp:6964
Represents integer value.
Definition: fcml_common.hpp:675
static const Register DR5()
Factory method for a register.
Definition: fcml_common.hpp:3076
static Operand effd(const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement)
Factory method which creates an effective address based operator for an index register, scaleFactor, displacement and double word size operator.
Definition: fcml_common.hpp:5285
fcml_usize getSize() const
Gets the register size.
Definition: fcml_common.hpp:1668
static const OperandHint ABSOLUTE_ADDRESSING()
Creates operand level hint: ABSOLUTE_ADDRESSING.
Definition: fcml_common.hpp:474
fcml_prefixes getPrefixes() const
Gets prefixes associated with the instruction.
Definition: fcml_common.hpp:6430
static Operand effq(const Register &base, const Register &index, fcml_uint8_t scaleFactor)
Factory method which creates an effective address based operator for a base register, index register, scale factor and quadro word size operator.
Definition: fcml_common.hpp:5414
static Operand effb(const Register &base)
Factory method which creates an effective address based operator for a base register and byte size op...
Definition: fcml_common.hpp:5150
bool isBE() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5774
static const Register YMM10()
Factory method for a register.
Definition: fcml_common.hpp:2526
static const InstructionHint DIRECT_PTR()
Creates a hint instance described by the name of the method.
Definition: fcml_common.hpp:6827
fcml_st_register reg
Register operand.
Definition: fcml_common.h:579
fcml_en_operating_mode op_mode
Processor operating mode 16/32/64-bit.
Definition: fcml_common.h:651
IB & longFormPtr()
Sets a hint described by the name of the method for the instruction being built.
Definition: fcml_common.hpp:6794
static EffectiveAddress addr(const Integer &displacement)
Factory method which creates an effective address instance with the displacement only.
Definition: fcml_common.hpp:3644
static const Register XMM15()
Factory method for a register.
Definition: fcml_common.hpp:2816
Operand not used.
Definition: fcml_common.h:515
static fcml_string strDup(const fcml_string str)
Definition: fcml_common.hpp:74
static const Condition NAE()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5631
static const InstructionHint INDIRECT_POINTER()
Creates instruction hint: INDIRECT_POINTER.
Definition: fcml_common.hpp:419
FPU register.
Definition: fcml_common.h:311
static const Register EIP()
Factory method for a register.
Definition: fcml_common.hpp:3116
static const OperandHint UNDEFIEND()
Creates operand level hint: UNDEFIEND.
Definition: fcml_common.hpp:446
static const Register R15()
Factory method for a register.
Definition: fcml_common.hpp:2806
Processor register.
Definition: fcml_common.h:523
4 Sign
Definition: fcml_common.hpp:5509
fcml_prefixes prefixes
Describes explicit instruction prefixes.
Definition: fcml_common.h:613
Integer(fcml_uint16_t value)
Definition: fcml_common.hpp:709
static const OperandHint RELATIVE_ADDRESSING()
Creates operand level hint: RELATIVE_ADDRESSING.
Definition: fcml_common.hpp:481
fcml_st_register base
GPR base register.
Definition: fcml_common.h:475
EffectiveAddress(const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement)
Creates an effective address instance with the base register, index register, scale factor and displa...
Definition: fcml_common.hpp:3596
static const Condition C()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5669
static const Register XMM6()
Factory method for a register.
Definition: fcml_common.hpp:2256
Integer operator+(const Integer &src) const
Addition operator.
Definition: fcml_common.hpp:1240
bool isFarPointer() const
Returns true if far pointer hint is set.
Definition: fcml_common.hpp:6545
static const Register CR4()
Factory method for a register.
Definition: fcml_common.hpp:3006
bool operator==(const EntryPoint &ep) const
Checks if two entry points are equal.
Definition: fcml_common.hpp:550
static Operand eff(const Integer &displacement, fcml_usize sizeOperator=FCML_DS_UNDEF)
Factory method which creates an effective address based operator for a displacement and optional size...
Definition: fcml_common.hpp:5089
bool isO() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5546
IB & far_ptr(const FarPointer &pointer)
Adds a far pointer operand.
Definition: fcml_common.hpp:7166
static Integer int64(fcml_int64_t value)
Factory method which creates an insatnce fo the Integer for given parameter.
Definition: fcml_common.hpp:1348
void imm(const Integer &imm)
Sets given immediate value for the operand and makes it to be an immediate operand.
Definition: fcml_common.hpp:4388
FarPointer()
Creates an far pointer instance.
Definition: fcml_common.hpp:3156
IB & effq(const Register &base, const Integer &displacement)
Adds an an effective address based operator for a base register, displacement and quadro word size op...
Definition: fcml_common.hpp:7567
Effective address combined from address components like base register, index registers, factor, displacement etc...
Definition: fcml_common.hpp:3860
void op(const Operand &operand)
Sets a next operand for the instruction.
Definition: fcml_common.hpp:6716
FarPointer(fcml_uint16_t segment, fcml_int16_t offset16)
Creates an far pointer instance.
Definition: fcml_common.hpp:3169
static const Condition NL()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:6011
fcml_usize address_size_attribute
Default address size attribute (See 'D' flag of segment descriptor.)
Definition: fcml_common.h:653
static const Register R9D()
Factory method for a register.
Definition: fcml_common.hpp:2436
Operand & setHints(fcml_hints hints)
Sets new operand level hits for the operand.
Definition: fcml_common.hpp:4710
IB & effb(const Register &base, const Register &index, fcml_uint8_t scaleFactor)
Adds an an effective address based operator for a base register, index register, scale factor and byt...
Definition: fcml_common.hpp:7721
fcml_usize getSizeOperator() const
Gets the size operator associated with the address.
Definition: fcml_common.hpp:4214
IB & addr(const EffectiveAddress &effectiveAddress, fcml_usize sizeOperator=FCML_DS_UNDEF)
Adds an address type operand for given effective address and optional size operator.
Definition: fcml_common.hpp:7252
EffectiveAddress(const Register &base, const Register &index)
Creates an effective address instance with the base register and index register.
Definition: fcml_common.hpp:3569
Exposes API responsible for environment specific operations, even if standard CPP library is used to ...
Definition: fcml_common.hpp:68
static Operand offq(const Integer &offset)
Factory method which builds an offset based address operand with quadro word size operator...
Definition: fcml_common.hpp:4948
Operand & setFarPointer(const FarPointer &farPointer)
Sets a new far pointer for the operand.
Definition: fcml_common.hpp:4602
static const InstructionPrefix BRANCH()
Creates a prefix instance described by the name of the method.
Definition: fcml_common.hpp:7018
static Operand far_ptr(fcml_uint16_t seg, fcml_int32_t addr)
Factory method which builds a far pointer operand.
Definition: fcml_common.hpp:4877
static const Register YMM2()
Factory method for a register.
Definition: fcml_common.hpp:1956
Integer(fcml_uint32_t value)
Definition: fcml_common.hpp:714
static Operand addrb(const EffectiveAddress &effectiveAddress)
Factory method which creates address type operand for given effective address and byte size operator...
Definition: fcml_common.hpp:4969
fcml_int64_t fcml_ip
General instruction pointer holder.
Definition: fcml_common.h:95
static const Register CR0()
Factory method for a register.
Definition: fcml_common.hpp:2976
Debug register.
Definition: fcml_common.h:317
bool isMultimedia() const
Returns information if the operand is multimedia one or not.
Definition: fcml_common.hpp:4724
bool isNBE() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5812
AddressForm
Addressing type, see fcml_en_address_form enumerator.
Definition: fcml_common.hpp:3854
fcml_uint16_t getSegment() const
Gets segment selector.
Definition: fcml_common.hpp:3324
IB & effb(const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement)
Adds an an effective address based operator for an index register, scaleFactor, displacement and byte...
Definition: fcml_common.hpp:7594
static const Register DR6()
Factory method for a register.
Definition: fcml_common.hpp:3086
Protected/Compatibility mode when 'D' segment descriptor flag is set to 1.
Definition: fcml_common.h:77
Condition()
Creates an empty condition.
Definition: fcml_common.hpp:5522
bool operator==(const Integer &value) const
Checks if the integer is equal to the passed value.
Definition: fcml_common.hpp:890
static const Register MM7()
Factory method for a register.
Definition: fcml_common.hpp:2326
Immediate integer value.
Definition: fcml_common.h:517
bool isC() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5660
EffectiveAddress(const Register &base, const Integer &displacement)
Creates an effective address instance with the base register and displacement only.
Definition: fcml_common.hpp:3544
virtual ~Integer()
Definition: fcml_common.hpp:724
fcml_hints hints
Holds instruction level hints.
Definition: fcml_common.h:615
static const Condition NC()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5688
Absolute offset (address).
Definition: fcml_common.h:449
bool operator!=(const Condition &cond) const
Checks if two condition are equal.
Definition: fcml_common.hpp:6131
6 Less than
Definition: fcml_common.hpp:5513
bool isP() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5888
static const Register SIL()
Factory method for a register.
Definition: fcml_common.hpp:2206
static Operand addrw(const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector)
Factory method which creates address type operand for given effective address and word size operator...
Definition: fcml_common.hpp:5033
static const Register RDI()
Factory method for a register.
Definition: fcml_common.hpp:2316
const Integer & getOffset() const
Gets the constant offset associated with the address.
Definition: fcml_common.hpp:4150
static const Register MM0()
Factory method for a register.
Definition: fcml_common.hpp:1796
bool getX64Exp() const
Gets true if it's a 8-bit general purpose register for REX aware instruction.
Definition: fcml_common.hpp:1704
bool operator!=(const fcml_int16_t value) const
Checks if the integer is not equal to the passed value.
Definition: fcml_common.hpp:934
fcml_hints hints
Optional operand level hints.
Definition: fcml_common.h:571
void setDefaultReg(bool isDefaultReg)
Sets "default" flag for the segment selector.
Definition: fcml_common.hpp:3460
Integer & getDisplacement()
Gets the displacement associated with the effective address.
Definition: fcml_common.hpp:3761
static const Register ST5()
Factory method for a register.
Definition: fcml_common.hpp:2946
Integer operator-(const Integer &src) const
Subtraction operator.
Definition: fcml_common.hpp:1251
Integer(fcml_int64_t value)
Definition: fcml_common.hpp:699
SIMD operand.
Definition: fcml_common.h:539
fcml_int operands_count
Number of operands defined for instruction.
Definition: fcml_common.h:625
Integer()
Definition: fcml_common.hpp:679
#define FCML_PREFIX_XRELEASE
XRELEASE prefix (0xF3)
Definition: fcml_common.h:62
const Integer & getImmediate() const
Gets a reference to the constant immediate value associated with the operand.
Definition: fcml_common.hpp:4613
fcml_st_address address
Effective address or absolute offset.
Definition: fcml_common.h:577
fcml_int32_t getInt32() const
Definition: fcml_common.hpp:741
static Operand effb(const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement)
Factory method which creates an effective address based operator for a base register, index register, scale factor and byte size operator.
Definition: fcml_common.hpp:5441
bool isFar() const
Returns true if operand is a far pointer operand.
Definition: fcml_common.hpp:4539
SegmentSelector()
Creates an empty segment selector instance.
Definition: fcml_common.hpp:3362
static const Condition LE()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:6049
static const Register BX()
Factory method for a register.
Definition: fcml_common.hpp:1976
static Address effective(const Register &base, fcml_usize sizeOperator=FCML_DS_UNDEF)
Factory method which creates an effective address instance with the base register only...
Definition: fcml_common.hpp:3935
static const InstructionHint NEAR_POINTER()
Creates instruction hint: NEAR_POINTER.
Definition: fcml_common.hpp:398
IB & imm(const Integer &imm)
Adds an immediate operand.
Definition: fcml_common.hpp:7128
static const InstructionPrefix XRELEASE()
Creates instruction prefix: XRELEASE.
Definition: fcml_common.hpp:353
static const OperandHint PSEUDO_OPCODE()
Creates operand level hint: PSEUDO_OPCODE.
Definition: fcml_common.hpp:467
static const Condition G()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:6106
Condition & setNegation(bool isNegation)
Sets negation flag for the condition.
Definition: fcml_common.hpp:6174
const Register & getRegister() const
Returns a reference to the constant register associated with the operand.
Definition: fcml_common.hpp:4667
static const Register R13L()
Factory method for a register.
Definition: fcml_common.hpp:2656
Undefined.
Definition: fcml_common.h:534
Undefined register type.
Definition: fcml_common.h:305
static const InstructionHint FAR_PTR()
Creates a hint instance described by the name of the method.
Definition: fcml_common.hpp:6743
Operand(const Integer &imm, fcml_hints hints=FCML_OP_HINT_UNDEFIEND)
Creates an immediate value operand for given integer.
Definition: fcml_common.hpp:4282
static const Condition NG()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:6068
fcml_st_effective_address effective_address
Memory address for FCML_AF_COMBINED form.
Definition: fcml_common.h:505
fcml_int16_t getInt16() const
Definition: fcml_common.hpp:730
Operand(const FarPointer &pointer, fcml_hints hints=FCML_OP_HINT_UNDEFIEND)
Creates a far pointer operand for given far pointer.
Definition: fcml_common.hpp:4295
Integer(fcml_uint64_t value)
Definition: fcml_common.hpp:719
OperatingMode
Supported operating modes.
Definition: fcml_common.hpp:506
SegmentSelector(const Register &segmentSelector, bool isDefaultReg=FCML_TRUE)
Creates a segment selector instance for given parameters.
Definition: fcml_common.hpp:3373
RegisterType getType() const
Gets the register type.
Definition: fcml_common.hpp:1686
bool isRepz() const
Returns true if repz prefix is set.
Definition: fcml_common.hpp:6500
static const Register YMM15()
Factory method for a register.
Definition: fcml_common.hpp:2826
bool operator==(const fcml_int16_t value) const
Checks if the integer is equal to the passed value.
Definition: fcml_common.hpp:835
General purpose register.
Definition: fcml_common.hpp:1584
static EffectiveAddress addr(const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement)
Factory method which creates an effective address instance with the index register, scale factor and displacement.
Definition: fcml_common.hpp:3674
bool isNP() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5926
static const OperandHint SIB_ENCODING()
Creates operand level hint: SIB_ENCODING.
Definition: fcml_common.hpp:488
const Register & getBase() const
Gets the constant base register associated with the effective address.
Definition: fcml_common.hpp:3719
static Operand effw(const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement)
Factory method which creates an effective address based operator for an index register, scaleFactor, displacement and word size operator.
Definition: fcml_common.hpp:5273
static const InstructionHint FAR_POINTER()
Creates instruction hint: FAR_POINTER.
Definition: fcml_common.hpp:405
IB(fcml_prefixes prefixes, const fcml_cstring &mnemonic, fcml_hints hints)
Creates an instruction builder for given prefixes, mnemonic and hints.
Definition: fcml_common.hpp:6676
bool isNAE() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5622
static const Register XMM7()
Factory method for a register.
Definition: fcml_common.hpp:2336
static const Register BL()
Factory method for a register.
Definition: fcml_common.hpp:1966
fcml_uint8_t scale_factor
Scale factor 1,2,4 or 8.
Definition: fcml_common.h:479
IB & effw(const Register &base, const Register &index)
Adds an an effective address based operator for a base register, index register and word size operato...
Definition: fcml_common.hpp:7670
bool operator==(const fcml_uint8_t value) const
Checks if the integer is equal to the passed value.
Definition: fcml_common.hpp:802
static const Register XMM5()
Factory method for a register.
Definition: fcml_common.hpp:2176
static const Register CS()
Factory method for a register.
Definition: fcml_common.hpp:2846
void setReg(fcml_uint8_t reg)
Sets the register number.
Definition: fcml_common.hpp:1659
Address()
Creates an empty address.
Definition: fcml_common.hpp:3867
Integer & setInt16(fcml_int16_t int16)
Definition: fcml_common.hpp:735
Operand(const Register &reg, fcml_hints hints=FCML_OP_HINT_UNDEFIEND)
Creates a new register operand for given register.
Definition: fcml_common.hpp:4321
bool isNGE() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5983
fcml_st_far_pointer far_pointer
Far pointer operand.
Definition: fcml_common.h:575
A base iterator interface.
Definition: fcml_common.hpp:98
Operand(const Address &address, fcml_hints hints=FCML_OP_HINT_UNDEFIEND)
Creates an address operand for given address.
Definition: fcml_common.hpp:4308
static const Register AL()
Factory method for a register.
Definition: fcml_common.hpp:1756
IB & offd(const Integer &offset)
Adds an offset based address operand with double word size operator.
Definition: fcml_common.hpp:7227
static const Register SP()
Factory method for a register.
Definition: fcml_common.hpp:2056
IB & effw(const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement)
Adds an an effective address based operator for a base register, index register, scale factor and wor...
Definition: fcml_common.hpp:7803
static const Register R15D()
Factory method for a register.
Definition: fcml_common.hpp:2796
Condition & setConditionType(ConditionType conditionType)
Sets condition type.
Definition: fcml_common.hpp:6153
bool isXRelease() const
Returns true if xrelease prefix is set.
Definition: fcml_common.hpp:6518
Default value set if memory addressing hasn't been configured.
Definition: fcml_common.h:447
0 Overflow
Definition: fcml_common.hpp:5501
static Operand effd(const Register &base, const Integer &displacement)
Factory method which creates an effective address based operator for a base register, displacement and double word size operator.
Definition: fcml_common.hpp:5225
bool operator!=(const Integer &value) const
Checks if the integer is not equal to the passed value.
Definition: fcml_common.hpp:989
AddressForm getAddressForm() const
Gets an address form.
Definition: fcml_common.hpp:4095
Register(const fcml_st_register &reg)
Creates a register instance for given register structure.
Definition: fcml_common.hpp:1615
Address(const EffectiveAddress &effectiveAddress, fcml_usize sizeOperator=FCML_DS_UNDEF)
Creates an address instance with an effective address and optional size operator set.
Definition: fcml_common.hpp:3892
#define FCML_PREFIX_NOBRANCH_HINT
nobranch hint (0x3E) (SSE2 extension)
Definition: fcml_common.h:66
static const Register XMM4()
Factory method for a register.
Definition: fcml_common.hpp:2096
void far_ptr(const FarPointer &pointer)
Prepares far pointer operand for given far pointer.
Definition: fcml_common.hpp:4423
fcml_int16_t off16
Place for 16-bit absolute offset.
Definition: fcml_common.h:463
const FarPointer & getFarPointer() const
Gets a reference to the constant far pointer instance associated with the address.
Definition: fcml_common.hpp:4581
Instruction condition.
Definition: fcml_common.hpp:5492
static const Condition AE()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5650
EffectiveAddress & setBase(const Register &base)
Sets a new base register for the effective address.
Definition: fcml_common.hpp:3740
static const Register ST7()
Factory method for a register.
Definition: fcml_common.hpp:2966
IB(const fcml_cstring &mnemonic, fcml_hints hints)
Creates an instruction builder for given mnemonic and hints.
Definition: fcml_common.hpp:6661
virtual ~EffectiveAddress()
Definition: fcml_common.hpp:3606
Operand & setOperandType(OperandType operandType)
Sets a new operand type.
Definition: fcml_common.hpp:4656
EffectiveAddress & setIndex(const Register &index)
Sets a new index register for the effective address.
Definition: fcml_common.hpp:3804
Integer(fcml_int16_t value)
Definition: fcml_common.hpp:689
static const Register RCX()
Factory method for a register.
Definition: fcml_common.hpp:1856
static Operand effb(const Integer &displacement)
Factory method which creates an effective address based operator for a displacement and byte size ope...
Definition: fcml_common.hpp:5099
static const Register RSP()
Factory method for a register.
Definition: fcml_common.hpp:2076
static const Register ST4()
Factory method for a register.
Definition: fcml_common.hpp:2936
static const Register SPL()
Factory method for a register.
Definition: fcml_common.hpp:2046
SIMD (SSE, MMX) register.
Definition: fcml_common.hpp:1586
IB & far_ptr(fcml_uint16_t seg, fcml_int16_t addr)
Adds a far pointer operand.
Definition: fcml_common.hpp:7141
Immediate integer value.
Definition: fcml_common.hpp:4257
EffectiveAddress(const Integer &displacement)
Creates an effective address instance with the displacement only.
Definition: fcml_common.hpp:3523
static EffectiveAddress addr(const Register &base, const Register &index, fcml_uint8_t scaleFactor)
Factory method which creates an effective address instance with the base register, index register and scale factor.
Definition: fcml_common.hpp:3695
Hints instruction to use INDIRECT pointer to address the memory.
Definition: fcml_common.h:602
7 Less than or equal to
Definition: fcml_common.h:364
Operand & setAddress(const Address &address)
Sets a new address for the operand.
Definition: fcml_common.hpp:4570
ConditionType getConditionType() const
Gets a type of the condition.
Definition: fcml_common.hpp:6143
Address(const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector, fcml_usize sizeOperator=FCML_DS_UNDEF)
Creates an address instance with an effective address, segment selector and optional size operator se...
Definition: fcml_common.hpp:3906
static const Register R10L()
Factory method for a register.
Definition: fcml_common.hpp:2476
bool isNG() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:6059
static const Register XMM11()
Factory method for a register.
Definition: fcml_common.hpp:2576
static Operand eff(const Register &base, const Integer &displacement, fcml_usize sizeOperator=FCML_DS_UNDEF)
Factory method which creates an effective address based operator for a base register, displacement and optional size operator.
Definition: fcml_common.hpp:5192
static const Condition NS()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5878
static const Register R8()
Factory method for a register.
Definition: fcml_common.hpp:2386
SIMD (SSE, MMX) register.
Definition: fcml_common.h:309
fcml_en_instruction_hints
Instruction level hints.
Definition: fcml_common.h:592
Definition: fcml_types.h:257
IB & effb(const Register &base, const Integer &displacement)
Adds an an effective address based operator for a base register, displacement and byte size operator...
Definition: fcml_common.hpp:7531
static const Register R13W()
Factory method for a register.
Definition: fcml_common.hpp:2666
Debug register.
Definition: fcml_common.hpp:1594
Operand()
Creates an undefined operand.
Definition: fcml_common.hpp:4270
OperandType getOperandType() const
Gets operand type.
Definition: fcml_common.hpp:4645
static const Register EAX()
Factory method for a register.
Definition: fcml_common.hpp:1776
Integer(fcml_int32_t value)
Definition: fcml_common.hpp:694
static const Condition NA()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5802
IB & addrw(const EffectiveAddress &effectiveAddress)
Adds an address type operand for given effective address and word size operator.
Definition: fcml_common.hpp:7276
Direct far pointer.
Definition: fcml_common.h:519
bool operator==(const EffectiveAddress &address) const
Checks whether two effective addresses are equal or not.
Definition: fcml_common.hpp:3617
static Operand addr(const EffectiveAddress &effectiveAddress, fcml_usize sizeOperator=FCML_DS_UNDEF)
Factory method which creates address type operand for given effective address and optional size opera...
Definition: fcml_common.hpp:4959
bool isRepnz() const
Returns true if lock repnz is set.
Definition: fcml_common.hpp:6473
static const Register R11D()
Factory method for a register.
Definition: fcml_common.hpp:2556
void setSize(fcml_usize size)
Sets the register size.
Definition: fcml_common.hpp:1677
static const Register FS()
Factory method for a register.
Definition: fcml_common.hpp:2876
Condition & getCondition()
Gets a pointer to the condition associated with the instruction.
Definition: fcml_common.hpp:6320
Real-addressing mode, virtual 8086 mode.
Definition: fcml_common.h:75
IB & addr(const Address &address)
Adds an address operand.
Definition: fcml_common.hpp:7178
static const Register CR2()
Factory method for a register.
Definition: fcml_common.hpp:2986
IB & reg(const Register &reg)
Adds an an register based operator for given register.
Definition: fcml_common.hpp:7378
IB & effb(const Integer &displacement)
Adds an an effective address based operator for a displacement and byte size operator.
Definition: fcml_common.hpp:7417
EffectiveAddress(const Register &base, const Register &index, fcml_uint8_t scaleFactor)
Creates an effective address instance with the base register, index register and scale factor set...
Definition: fcml_common.hpp:3582
Hints instruction to use NEAR pointer to address the memory.
Definition: fcml_common.h:598
SegmentSelector & operator=(const SegmentSelector &reg)
Copies one segment selector to another.
Definition: fcml_common.hpp:3419
static Operand eff(const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement, fcml_usize sizeOperator=FCML_DS_UNDEF)
Factory method which creates an effective address based operator for an index register, scaleFactor, displacement and optional size operator.
Definition: fcml_common.hpp:5249
Memory address.
Definition: fcml_common.hpp:4261
fcml_st_operand operands[FCML_OPERANDS_COUNT]
Fixed size array of instruction operands.
Definition: fcml_common.h:623
IB & offw(const Integer &offset)
Adds an offset based address operand with word size operator.
Definition: fcml_common.hpp:7215
static const InstructionPrefix REP()
Creates a prefix instance described by the name of the method.
Definition: fcml_common.hpp:6913
void setOpMode(OperatingMode opMode)
Sets a new processor operating mode for the entry point.
Definition: fcml_common.hpp:646
Describes an instruction.
Definition: fcml_common.hpp:6207
IB & set(const InstructionHint &hint)
Adds an instruction level hint to the instruction being built.
Definition: fcml_common.hpp:7894
bool operator!=(const fcml_uint16_t value) const
Checks if the integer is not equal to the passed value.
Definition: fcml_common.hpp:923
Instruction operand.
Definition: fcml_common.h:567
static const InstructionHint DIRECT_POINTER()
Creates instruction hint: DIRECT_POINTER.
Definition: fcml_common.hpp:426
fcml_usize offset_size
Size of the offset.
Definition: fcml_common.h:430
Wraps instruction prefix and prepares factory methods for the hints.
Definition: fcml_common.hpp:287
bool isNO() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5565
const Register & getIndex() const
Gets the constant index register associated with the effective address.
Definition: fcml_common.hpp:3783
IB & addrd(const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector)
Adds an address type operand for given effective address and double word size operator.
Definition: fcml_common.hpp:7353
Instruction & setPrefixes(fcml_prefixes prefixes)
Sets a new set of prefixes for the instruction.
Definition: fcml_common.hpp:6441
static const Register R13()
Factory method for a register.
Definition: fcml_common.hpp:2686
static const Register R10W()
Factory method for a register.
Definition: fcml_common.hpp:2486
static const Register CL()
Factory method for a register.
Definition: fcml_common.hpp:1826
bool isRepne() const
Returns true if repne prefix is set.
Definition: fcml_common.hpp:6464
static Operand effq(const Register &base, const Register &index)
Factory method which creates an effective address based operator for a base register, index register and quadro word size operator.
Definition: fcml_common.hpp:5353
const Condition & getCondition() const
Gets a pointer to the constant condition associated with the instruction.
Definition: fcml_common.hpp:6310
static const Register R8W()
Factory method for a register.
Definition: fcml_common.hpp:2366
Register & getSegmentSelector()
Gets segment register associated with the selector.
Definition: fcml_common.hpp:3480
Integer & operator*=(const Integer &arg)
Multiplication assignment.
Definition: fcml_common.hpp:1213
1 Below
Definition: fcml_common.hpp:5503
static const Register BPL()
Factory method for a register.
Definition: fcml_common.hpp:2126
static const Condition NE()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5745
static const OperandHint DISPLACEMENT_RELATIVE_ADDRESS()
Creates operand level hint: DISPLACEMENT_RELATIVE_ADDRESS.
Definition: fcml_common.hpp:460
#define FCML_PREFIX_BRANCH_HINT
branch hint (0x2E) (SSE2 extension)
Definition: fcml_common.h:64
static EffectiveAddress addr(const Register &base)
Factory method which creates an effective address instance with the base register only...
Definition: fcml_common.hpp:3653
static const Register BH()
Factory method for a register.
Definition: fcml_common.hpp:2276
Instruction & setMnemonic(const fcml_cstring &mnemonic)
Sets a new mnemonic for the instruction.
Definition: fcml_common.hpp:6397
Operation succeed.
Definition: fcml_errors.h:42
static const Register R8D()
Factory method for a register.
Definition: fcml_common.hpp:2376
fcml_st_register segment_selector
Used segment register.
Definition: fcml_common.h:489
bool operator==(const FarPointer &fp) const
Compares two far pointers.
Definition: fcml_common.hpp:3199
static const Register R8L()
Factory method for a register.
Definition: fcml_common.hpp:2356
fcml_bool is_signed
True if offset should be treated as signed value.
Definition: fcml_common.h:461
bool isConditional() const
Gets true if it's a conditional instruction.
Definition: fcml_common.hpp:6364
Address & setAddressForm(AddressForm addressForm)
Sets a new address form for the effective address.
Definition: fcml_common.hpp:4107
fcml_usize size
Register size in bits.
Definition: fcml_common.h:329
bool isAE() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5641
static Address effective(const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector, fcml_usize sizeOperator=FCML_DS_UNDEF)
Factor method which creates an instance of the address for an effective address, segment selector and...
Definition: fcml_common.hpp:4039
void setOffset32(fcml_int32_t offset32)
Sets 32-bit offset.
Definition: fcml_common.hpp:3314
Instruction & setHints(fcml_hints hints)
Sets new instruction hints.
Definition: fcml_common.hpp:6353
bool isL() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5964
fcml_bool is_conditional
True for conditional instructions.
Definition: fcml_common.h:619
No hints defined.
Definition: fcml_common.h:594
fcml_usize getOperandSizeAttribute() const
Gets operand size attribute held by the entry point.
Definition: fcml_common.hpp:596
bool isS() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5850
Bad arguments.
Definition: fcml_common.hpp:217
static Operand effq(const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement)
Factory method which creates an effective address based operator for a base register, index register, scale factor and quardo word size operator.
Definition: fcml_common.hpp:5480
IB & effw(const Register &base, const Integer &displacement)
Adds an an effective address based operator for a base register, displacement and word size operator...
Definition: fcml_common.hpp:7543
Control register.
Definition: fcml_common.hpp:1592
static const InstructionPrefix REPE()
Creates instruction prefix: REPE.
Definition: fcml_common.hpp:332
static Operand effq(const Integer &displacement)
Factory method which creates an effective address based operator for a displacement and quadro byte s...
Definition: fcml_common.hpp:5129
static const Register EBX()
Factory method for a register.
Definition: fcml_common.hpp:1986
Representation of far pointer operand.
Definition: fcml_common.h:426
OperandType
See fcml_en_operand_type structure for more details.
Definition: fcml_common.hpp:4253
bool isNZ() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5755
void reg(fcml_uint8_t reg, fcml_usize size, Register::RegisterType type=Register::REG_GPR, fcml_bool x64_exp=FCML_FALSE)
Prepares an register operator for given register compounds.
Definition: fcml_common.hpp:4496
IB & xrelease()
Sets a prefix described by the name of the method for the instruction being built.
Definition: fcml_common.hpp:7006
IB & addrd(const EffectiveAddress &effectiveAddress)
Adds an address type operand for given effective address and double word size operator.
Definition: fcml_common.hpp:7288
Effective address.
Definition: fcml_common.h:473
fcml_st_register index
GPR index register.
Definition: fcml_common.h:477
static const Register XMM8()
Factory method for a register.
Definition: fcml_common.hpp:2396
static const Condition E()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5707
static const Register R11()
Factory method for a register.
Definition: fcml_common.hpp:2566
static Operand effd(const Register &base)
Factory method which creates an effective address based operator for a base register and double word ...
Definition: fcml_common.hpp:5170
static Operand effw(const Integer &displacement)
Factory method which creates an effective address based operator for a displacement and word size ope...
Definition: fcml_common.hpp:5109
Describes address of an instruction code.
Definition: fcml_common.h:649
4 Sign
Definition: fcml_common.h:358
bool isPO() const
Gets true the condition is of a given type.
Definition: fcml_common.hpp:5945
IB & effd(const Register &base, const Integer &displacement)
Adds an an effective address based operator for a base register, displacement and double word size op...
Definition: fcml_common.hpp:7555
static Operand effb(const Register &base, const Register &index, fcml_uint8_t scaleFactor)
Factory method which creates an effective address based operator for a base register, index register, scale factor and byte size operator.
Definition: fcml_common.hpp:5378
static Address effective(const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement, fcml_usize sizeOperator=FCML_DS_UNDEF)
Factory method which creates an effective address instance with the base register, index register, scale factor and displacement.
Definition: fcml_common.hpp:3994
Address & setEffectiveAddress(const EffectiveAddress &effectiveAddress)
Sets a new effective address for the address.
Definition: fcml_common.hpp:4139
void far_ptr(fcml_uint16_t seg, fcml_int32_t addr)
Prepares far pointer operand for given components.
Definition: fcml_common.hpp:4412
static const InstructionPrefix REPE()
Creates a prefix instance described by the name of the method.
Definition: fcml_common.hpp:6934
static const Register YMM1()
Factory method for a register.
Definition: fcml_common.hpp:1886
static const InstructionPrefix REP()
Creates instruction prefix: REP.
Definition: fcml_common.hpp:325
IB & effd(const Register &base)
Adds an an effective address based operator for a base register and double word size operator...
Definition: fcml_common.hpp:7495
static const Register MM5()
Factory method for a register.
Definition: fcml_common.hpp:2166
static const Register XMM14()
Factory method for a register.
Definition: fcml_common.hpp:2756
static const Register R15W()
Factory method for a register.
Definition: fcml_common.hpp:2786
fcml_uint16_t fcml_prefixes
Type for explicit instruction prefixes bit mask.
Definition: fcml_common.h:90
EffectiveAddress & getEffectiveAddress()
Gets reference to the effective address associated with the address.
Definition: fcml_common.hpp:4128
Operation is not supported.
Definition: fcml_common.hpp:250
Memory address.
Definition: fcml_common.h:521
Generic memory addressing operator.
Definition: fcml_common.h:497
IB & reg(fcml_uint8_t reg, fcml_usize size, Register::RegisterType type=Register::REG_GPR, fcml_bool x64_exp=FCML_FALSE)
Adds an an register based operator for given parameters.
Definition: fcml_common.hpp:7393
static const Register MM3()
Factory method for a register.
Definition: fcml_common.hpp:2006
static const Register XMM13()
Factory method for a register.
Definition: fcml_common.hpp:2696
static const Condition NB()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5612
bool operator!=(const Operand &op) const
Checks if two operands are equal or not.
Definition: fcml_common.hpp:4368
void setOffsetSize(fcml_usize offsetSize)
Sets offset size.
Definition: fcml_common.hpp:3274
void far_ptr(fcml_uint16_t seg, fcml_int16_t addr)
Converts operand to the far pointer and sets the segment selector and offset for it.
Definition: fcml_common.hpp:4400
Global error handling related declarations.
static const Register XMM12()
Factory method for a register.
Definition: fcml_common.hpp:2636
static const Register ST2()
Factory method for a register.
Definition: fcml_common.hpp:2916
const Integer & getDisplacement() const
Gets the constant displacement associated with the effective address.
Definition: fcml_common.hpp:3751
static const Register YMM14()
Factory method for a register.
Definition: fcml_common.hpp:2766
fcml_int32_t getOffset32() const
Gets 32-bit offset.
Definition: fcml_common.hpp:3304
static const Register CR8()
Factory method for a register.
Definition: fcml_common.hpp:3016
Register & getRegister()
Returns a reference to the register associated with the operand.
Definition: fcml_common.hpp:4677
IB & repne()
Sets a prefix described by the name of the method for the instruction being built.
Definition: fcml_common.hpp:6880
#define FCML_PREFIX_REP
REP prefix (0xF3)
Definition: fcml_common.h:54
5 Parity
Definition: fcml_common.hpp:5511
bool isLock() const
Returns true if lock prefix is set.
Definition: fcml_common.hpp:6455
static const Register R15L()
Factory method for a register.
Definition: fcml_common.hpp:2776
bool operator!=(const EntryPoint &ep) const
Checks if two entry points are not equal.
Definition: fcml_common.hpp:564
void off(const Integer &offset, fcml_usize sizeOperator=FCML_DS_UNDEF)
Prepares address operand for given offset.
Definition: fcml_common.hpp:4446
static Operand effw(const Register &base, const Integer &displacement)
Factory method which creates an effective address based operator for a base register, displacement and word size operator.
Definition: fcml_common.hpp:5214
static const Register R12D()
Factory method for a register.
Definition: fcml_common.hpp:2616
static Operand addrw(const EffectiveAddress &effectiveAddress)
Factory method which creates address type operand for given effective address and word size operator...
Definition: fcml_common.hpp:4979
IB & addrq(const EffectiveAddress &effectiveAddress)
Adds an address type operand for given effective address and quadro word size operator.
Definition: fcml_common.hpp:7300
RegisterType
Register types.
Definition: fcml_common.hpp:1580
Integer(fcml_uint8_t value)
Definition: fcml_common.hpp:704
static const InstructionHint NEAR_PTR()
Creates a hint instance described by the name of the method.
Definition: fcml_common.hpp:6764
fcml_usize size_operator
Size of data accessed in memory.
Definition: fcml_common.h:499
Register(fcml_uint8_t reg, fcml_usize size, RegisterType type=REG_GPR, fcml_bool x64_exp=FCML_FALSE)
Creates a register instance for given parameters.
Definition: fcml_common.hpp:1630
Absolute offset.
Definition: fcml_common.h:457
IB & farPtr()
Sets a hint described by the name of the method for the instruction being built.
Definition: fcml_common.hpp:6752
static Operand addrq(const EffectiveAddress &effectiveAddress)
Factory method which creates address type operand for given effective address and quadro word size op...
Definition: fcml_common.hpp:4999
static const Register YMM11()
Factory method for a register.
Definition: fcml_common.hpp:2586
bool operator!=(const fcml_uint8_t value) const
Checks if the integer is not equal to the passed value.
Definition: fcml_common.hpp:901
static Integer int16(fcml_int16_t value)
Factory method which creates an instance fo the Integer for given parameter.
Definition: fcml_common.hpp:1308
static Operand effb(const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement)
Factory method which creates an effective address based operator for an index register, scaleFactor, displacement and byte size operator.
Definition: fcml_common.hpp:5261
static const Register RAX()
Factory method for a register.
Definition: fcml_common.hpp:1786
fcml_en_register type
Register type.
Definition: fcml_common.h:327
static const Register DR4()
Factory method for a register.
Definition: fcml_common.hpp:3066
static const Register R14L()
Factory method for a register.
Definition: fcml_common.hpp:2716
fcml_st_condition condition
Describes condition used by assembled/disassembled conditional instruction.
Definition: fcml_common.h:621
static const InstructionPrefix XACQUIRE()
Creates instruction prefix: XACQUIRE.
Definition: fcml_common.hpp:346
static const Register DX()
Factory method for a register.
Definition: fcml_common.hpp:1906
Component can not be initialized correctly.
Definition: fcml_common.hpp:206
static const InstructionHint NO_HINTS()
Creates instruction hint: NO_HINTS.
Definition: fcml_common.hpp:391
IB & effq(const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement)
Adds an an effective address based operator for a base register, index register, scale factor and qua...
Definition: fcml_common.hpp:7831
static const Register UNDEF()
Factory method for an undefined register.
Definition: fcml_common.hpp:1746
Integer & getImmediate()
Gets a reference to the immediate value associated with the operand.
Definition: fcml_common.hpp:4623
fcml_int64_t getInt64() const
Definition: fcml_common.hpp:752
bool isDirectPointer() const
Returns true if direct pointer hint is set.
Definition: fcml_common.hpp:6581
static const Register R10()
Factory method for a register.
Definition: fcml_common.hpp:2506
static const InstructionPrefix LOCK()
Creates instruction prefix: LOCK.
Definition: fcml_common.hpp:304
static Operand effd(const Register &base, const Register &index, fcml_uint8_t scaleFactor)
Factory method which creates an effective address based operator for a base register, index register, scale factor and double word size operator.
Definition: fcml_common.hpp:5402
static const Register EBP()
Factory method for a register.
Definition: fcml_common.hpp:2146
IB & offq(const Integer &offset)
Adds an offset based address operand with quadro word size operator.
Definition: fcml_common.hpp:7239
IB(fcml_prefixes prefixes, const fcml_cstring &mnemonic)
Creates builder for the given mnemonic and prefixes.
Definition: fcml_common.hpp:6647
static const Register R12L()
Factory method for a register.
Definition: fcml_common.hpp:2596
IB & eff(const Register &base, const Integer &displacement, fcml_usize sizeOperator=FCML_DS_UNDEF)
Adds an an effective address based operator for a base register, displacement and optional size opera...
Definition: fcml_common.hpp:7519
static const Register XMM0()
Factory method for a register.
Definition: fcml_common.hpp:1806
fcml_uint16_t fcml_ceh_error
All error codes should be held in variables of this type.
Definition: fcml_errors.h:139
static Operand addrd(const EffectiveAddress &effectiveAddress)
Factory method which creates address type operand for given effective address and double word size op...
Definition: fcml_common.hpp:4989
static const InstructionPrefix XACQUIRE()
Creates a prefix instance described by the name of the method.
Definition: fcml_common.hpp:6976
static const Register RSI()
Factory method for a register.
Definition: fcml_common.hpp:2236
static Operand far_ptr(const FarPointer &pointer)
Factory method which builds a far pointer operand.
Definition: fcml_common.hpp:4887
static const Register YMM3()
Factory method for a register.
Definition: fcml_common.hpp:2026
static const InstructionPrefix REPNZ()
Creates a prefix instance described by the name of the method.
Definition: fcml_common.hpp:6892
static const Register ST1()
Factory method for a register.
Definition: fcml_common.hpp:2906
static EffectiveAddress addr(const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement)
Factory method which creates an effective address instance with the base register, index register, scale factor and displacement.
Definition: fcml_common.hpp:3707
IB & effb(const Register &base)
Adds an an effective address based operator for a base register and byte size operator.
Definition: fcml_common.hpp:7473
static Operand addr(const Address &address)
Factory method which builds an address operand.
Definition: fcml_common.hpp:4897
fcml_int getOperandsCount() const
Gets number of operands associated with the instruction.
Definition: fcml_common.hpp:6408
static const Register CR3()
Factory method for a register.
Definition: fcml_common.hpp:2996
fcml_en_operand_type type
Operand type.
Definition: fcml_common.h:569
static const Condition BE()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5783
static const Register R10D()
Factory method for a register.
Definition: fcml_common.hpp:2496
static const Register YMM5()
Factory method for a register.
Definition: fcml_common.hpp:2186
static const Condition NLE()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:6087
Describes effective address.
Definition: fcml_common.hpp:3507
static Integer uint8(fcml_uint8_t value)
Factory method which creates an instance fo the Integer for given parameter.
Definition: fcml_common.hpp:1298
Instruction & setConditional(bool isConditional)
Sets conditional flag for the instruction.
Definition: fcml_common.hpp:6375
static const Register ESI()
Factory method for a register.
Definition: fcml_common.hpp:2226
const fcml_cstring & getMnemonic() const
Gets the mnemonic associated with the instruction.
Definition: fcml_common.hpp:6386
const Operand & operator[](fcml_int index) const
Gets reference to the constant operand at given index.
Definition: fcml_common.hpp:6273
fcml_int32_t off32
Place for 32-bit absolute offset.
Definition: fcml_common.h:465
IB & eff(const Register &base, const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement, fcml_usize sizeOperator=FCML_DS_UNDEF)
Adds an an effective address based operator for a base register, index register, scale factor and opt...
Definition: fcml_common.hpp:7775
static Integer int8(fcml_int8_t value)
Factory method which creates an instance fo the Integer for given parameter.
Definition: fcml_common.hpp:1288
static const Register R11W()
Factory method for a register.
Definition: fcml_common.hpp:2546
static Operand undef()
Factory method which builds an empty operand.
Definition: fcml_common.hpp:4846
static Address effective(const Register &base, const Register &index, fcml_uint8_t scaleFactor, fcml_usize sizeOperator=FCML_DS_UNDEF)
Factory method which creates an effective address instance with the base register, index register and scale factor.
Definition: fcml_common.hpp:3981
Types declarations.
fcml_en_operand_hints
Operand hints.
Definition: fcml_common.h:530
IB & operandAbsoluteHint()
Marks the lastly added address operand as a absolute one.
Definition: fcml_common.hpp:7107
IB & addrb(const EffectiveAddress &effectiveAddress)
Adds an address type operand for given effective address and byte size operator.
Definition: fcml_common.hpp:7264
2 Equal
Definition: fcml_common.h:354
Object which shouldn't be copied can inherit from this class.
Definition: fcml_common.hpp:263
IB & nearPtr()
Sets a hint described by the name of the method for the instruction being built.
Definition: fcml_common.hpp:6773
fcml_uint8_t getReg() const
Gets the register number.
Definition: fcml_common.hpp:1650
static const Condition B()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5593
IB(const fcml_cstring &mnemonic)
Creates builder for the given mnemonic.
Definition: fcml_common.hpp:6633
static const Register SI()
Factory method for a register.
Definition: fcml_common.hpp:2216
static const OperandHint OP_RELATIVE_ADDRESSING()
Gets relative address hint for the operand.
Definition: fcml_common.hpp:7065
IB & addrq(const EffectiveAddress &effectiveAddress, const SegmentSelector &segmentSelector)
Adds an address type operand for given effective address and quadro word size operator.
Definition: fcml_common.hpp:7366
fcml_en_effective_address_form address_form
Memory addressing format: absolute offset/effective address.
Definition: fcml_common.h:501
IB & set(const OperandHint &hint)
Adds an operand level hint to the instruction being built.
Definition: fcml_common.hpp:7905
IB & set(const InstructionPrefix &prefix)
Adds a prefix to the instruction being built.
Definition: fcml_common.hpp:7883
static const Register MM6()
Factory method for a register.
Definition: fcml_common.hpp:2246
Address & setOffset(const Integer &offset)
Sets a new offset for the address.
Definition: fcml_common.hpp:4171
1 Below
Definition: fcml_common.h:352
Register & getIndex()
Gets the index register associated with the effective address.
Definition: fcml_common.hpp:3793
static const InstructionPrefix REPNE()
Creates instruction prefix: REPNE.
Definition: fcml_common.hpp:311
static Address effective(const Register &base, const Integer &displacement, fcml_usize sizeOperator=FCML_DS_UNDEF)
Factory method which creates an effective address instance with the base register and displacement...
Definition: fcml_common.hpp:3946
fcml_st_offset offset
Memory address for FCML_AF_OFFSET form.
Definition: fcml_common.h:507
static const InstructionHint LONG_FORM_PTR()
Creates a hint instance described by the name of the method.
Definition: fcml_common.hpp:6785
void setOperand(const Operand &operand, fcml_int index)
Sets a new oeprand for the instruction at given index.
Definition: fcml_common.hpp:6259
Illegal argument exception.
Definition: fcml_common.hpp:239
static const Register YMM12()
Factory method for a register.
Definition: fcml_common.hpp:2646
static const Condition PE()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5916
static const Condition O()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5555
Pseudo opcode.
Definition: fcml_common.h:549
64-bit mode.
Definition: fcml_common.h:79
static const Condition NO()
Factory method which creates a condition of a given type.
Definition: fcml_common.hpp:5574
Undefined register type.
Definition: fcml_common.hpp:1582
bool operator!=(const fcml_int64_t value) const
Checks if the integer is not equal to the passed value.
Definition: fcml_common.hpp:978
Absolute offset (address).
Definition: fcml_common.hpp:3858
IB & effq(const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement)
Adds an an effective address based operator for an index register, scaleFactor, displacement and quad...
Definition: fcml_common.hpp:7633
static Operand effw(const Register &base)
Factory method which creates an effective address based operator for a base register and word size op...
Definition: fcml_common.hpp:5160
Integer operator/(const Integer &src) const
Division operator.
Definition: fcml_common.hpp:1273
virtual T next()=0
Gets a next element from the iterator.
IB & operandMultimediaHint()
Marks the lastly added operand as a multimedia one.
Definition: fcml_common.hpp:7089
fcml_int64_t off64
Place for 64-bit absolute offset.
Definition: fcml_common.h:467
static const InstructionHint LONG_FORM_POINTER()
Creates instruction hint: LONG_FORM_POINTER.
Definition: fcml_common.hpp:412
Address & setSegmentSelector(const SegmentSelector &segmentSelector)
Sets a new segment selector for the address.
Definition: fcml_common.hpp:4203
bool operator==(const fcml_int8_t value) const
Checks if the integer is equal to the passed value.
Definition: fcml_common.hpp:813
static const Register DR2()
Factory method for a register.
Definition: fcml_common.hpp:3046
static const Register R9()
Factory method for a register.
Definition: fcml_common.hpp:2446
IB & eff(const Register &index, fcml_uint8_t scaleFactor, const Integer &displacement, fcml_usize sizeOperator=FCML_DS_UNDEF)
Adds an an effective address based operator for an index register, scaleFactor, displacement and opti...
Definition: fcml_common.hpp:7581
Instruction(const fcml_cstring &mnemonic)
Creates an empty instruction for given mnemonic.
Definition: fcml_common.hpp:6227