xed-immdis.h

Go to the documentation of this file.
00001 /*BEGIN_LEGAL 
00002 Copyright (c) 2007, Intel Corp.
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are
00007 met:
00008 
00009     * Redistributions of source code must retain the above copyright
00010       notice, this list of conditions and the following disclaimer.
00011 
00012     * Redistributions in binary form must reproduce the above
00013       copyright notice, this list of conditions and the following
00014       disclaimer in the documentation and/or other materials provided
00015       with the distribution.
00016 
00017     * Neither the name of Intel Corporation nor the names of its
00018       contributors may be used to endorse or promote products derived
00019       from this software without specific prior written permission.
00020 
00021 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00024 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00025 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00026 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00027 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00028 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00029 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00030 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00031 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00032 END_LEGAL */
00035 
00036 
00037 
00038 #ifndef _XED_IMMDIS_H_
00039 # define _XED_IMMDIS_H_
00040 
00041 #include "xed-types.h"
00042 #include "xed-common-defs.h"
00043 #include "xed-util.h"
00044 
00045 
00047 // DEFINES
00049 
00051 // TYPES
00054 // PROTOTYPES
00056 
00058 // GLOBALS
00060 
00061 #define XED_MAX_IMMDIS_BYTES 8
00062 
00063 // A union for speed of zeroing
00064 union xed_immdis_values_t
00065 {
00066     xed_uint8_t x[XED_MAX_IMMDIS_BYTES];// STORED LITTLE ENDIAN. BYTE 0 is LSB
00067     xed_uint64_t q;
00068 };
00069 
00071 typedef struct XED_DLL_EXPORT xed_immdis_s {
00072     union xed_immdis_values_t value;
00073     unsigned int currently_used_space :4; // current number of assigned bytes
00074     unsigned int max_allocated_space :4; // max allocation, 4 or 8
00075     xed_bool_t present : 1;
00076     xed_bool_t immediate_is_unsigned : 1;
00077 } xed_immdis_t;
00078 
00079 XED_DLL_EXPORT void xed_immdis__check(xed_immdis_t* q, int p) ;
00080 
00081 
00082 XED_DLL_EXPORT void xed_immdis_init(xed_immdis_t* p, int max_bytes);
00083 
00085 
00086 
00087 XED_DLL_EXPORT unsigned int xed_immdis_get_bytes(const xed_immdis_t* p) ;
00088 
00090 
00092 
00093 XED_DLL_EXPORT xed_int64_t 
00094 xed_immdis_get_signed64(const xed_immdis_t* p);
00095 
00096 XED_DLL_EXPORT xed_uint64_t 
00097 xed_immdis_get_unsigned64(const xed_immdis_t* p);
00098 
00099 XED_DLL_EXPORT xed_bool_t
00100 xed_immdis_is_zero(const xed_immdis_t* p) ;
00101 
00102 XED_DLL_EXPORT xed_bool_t
00103 xed_immdis_is_one(const xed_immdis_t* p) ;
00104 
00106 XED_DLL_EXPORT xed_uint8_t   xed_immdis_get_byte(const xed_immdis_t* p, unsigned int i) ;
00108 
00110 
00111 XED_DLL_EXPORT void    xed_immdis_set_present(xed_immdis_t* p) ;
00112 
00114 XED_DLL_EXPORT xed_bool_t    xed_immdis_is_present(const xed_immdis_t* p) ;
00116 
00117 
00119 
00120 XED_DLL_EXPORT void     xed_immdis_set_max_len(xed_immdis_t* p, unsigned int mx) ;
00121 XED_DLL_EXPORT void
00122 xed_immdis_zero(xed_immdis_t* p);
00123 
00124 XED_DLL_EXPORT unsigned int    xed_immdis_get_max_length(const xed_immdis_t* p) ;
00125 
00127 
00129 
00130 
00131 XED_DLL_EXPORT xed_bool_t
00132 xed_immdis_is_unsigned(const xed_immdis_t* p) ;
00134 XED_DLL_EXPORT xed_bool_t
00135 xed_immdis_is_signed(const xed_immdis_t* p) ;
00136     
00138 XED_DLL_EXPORT void 
00139 xed_immdis_set_signed(xed_immdis_t* p) ;
00141 XED_DLL_EXPORT void 
00142 xed_immdis_set_unsigned( xed_immdis_t* p) ;
00144 
00145 
00147 
00148 XED_DLL_EXPORT void
00149 xed_immdis_add_byte(xed_immdis_t* p, xed_uint8_t b);
00150 
00151 
00152 XED_DLL_EXPORT void
00153 xed_immdis_add_byte_array(xed_immdis_t* p, int nb, xed_uint8_t* ba);
00154 
00164 XED_DLL_EXPORT void
00165 xed_immdis_add_shortest_width_signed(xed_immdis_t* p, xed_int64_t x, xed_uint8_t legal_widths);
00166 
00168 XED_DLL_EXPORT void
00169 xed_immdis_add_shortest_width_unsigned(xed_immdis_t* p, xed_uint64_t x, xed_uint8_t legal_widths );
00170 
00171 
00173 XED_DLL_EXPORT void
00174 xed_immdis_add8(xed_immdis_t* p, xed_int8_t d);
00175 
00177 XED_DLL_EXPORT void
00178 xed_immdis_add16(xed_immdis_t* p, xed_int16_t d);
00179 
00181 XED_DLL_EXPORT void
00182 xed_immdis_add32(xed_immdis_t* p, xed_int32_t d);
00183 
00185 XED_DLL_EXPORT void
00186 xed_immdis_add64(xed_immdis_t* p, xed_int64_t d);
00187 
00189 
00190 
00192 
00193 
00195 XED_DLL_EXPORT int xed_immdis_print(const xed_immdis_t* p, char* buf, int buflen);
00196 
00199 XED_DLL_EXPORT int
00200 xed_immdis_print_signed_or_unsigned(const xed_immdis_t* p, char* buf, int buflen);
00201 
00203 XED_DLL_EXPORT int
00204 xed_immdis_print_value_signed(const xed_immdis_t* p, char* buf, int buflen);
00205 
00207 XED_DLL_EXPORT int
00208 xed_immdis_print_value_unsigned(const xed_immdis_t* p, char* buf, int buflen);
00209 
00210 int xed_immdis__print_ptr(const xed_immdis_t* p, char* buf, int buflen);
00211 #endif
00212 
00214 
00215 
00217 //Local Variables:
00218 //pref: "../../xed-immdis.c"
00219 //End:

Generated on Thu May 15 03:15:09 2008 for XED2 by  doxygen 1.4.6