XED
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
xed-immdis.h
Go to the documentation of this file.
1 /*BEGIN_LEGAL
2 Intel Open Source License
3 
4 Copyright (c) 2002-2014 Intel Corporation. All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are
8 met:
9 
10 Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer. Redistributions
12 in binary form must reproduce the above copyright notice, this list of
13 conditions and the following disclaimer in the documentation and/or
14 other materials provided with the distribution. Neither the name of
15 the Intel Corporation nor the names of its contributors may be used to
16 endorse or promote products derived from this software without
17 specific prior written permission.
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR
23 ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 END_LEGAL */
33 
34 
35 
36 #ifndef _XED_IMMDIS_H_
37 # define _XED_IMMDIS_H_
38 
39 #include "xed-types.h"
40 #include "xed-common-defs.h"
41 #include "xed-util.h"
42 
43 
45 // DEFINES
47 
49 // TYPES
52 // PROTOTYPES
54 
56 // GLOBALS
58 
59 #define XED_MAX_IMMDIS_BYTES 8
60 
61 // A union for speed of zeroing
63 {
64  xed_uint8_t x[XED_MAX_IMMDIS_BYTES];// STORED LITTLE ENDIAN. BYTE 0 is LSB
65  xed_uint64_t q;
66 };
67 
69 typedef struct xed_immdis_s {
71  unsigned int currently_used_space :4; // current number of assigned bytes
72  unsigned int max_allocated_space :4; // max allocation, 4 or 8
75 } xed_immdis_t;
76 
78 
79 
80 XED_DLL_EXPORT void xed_immdis_init(xed_immdis_t* p, int max_bytes);
81 
83 
84 XED_DLL_EXPORT unsigned int xed_immdis_get_bytes(const xed_immdis_t* p) ;
86 
88 
90 
91 XED_DLL_EXPORT xed_int64_t
93 
94 XED_DLL_EXPORT xed_uint64_t
96 
99 
102 
104 XED_DLL_EXPORT xed_uint8_t xed_immdis_get_byte(const xed_immdis_t* p, unsigned int i) ;
106 
108 
110 
114 
115 
117 
118 XED_DLL_EXPORT void xed_immdis_set_max_len(xed_immdis_t* p, unsigned int mx) ;
119 XED_DLL_EXPORT void
121 
123 
125 
127 
134 
136 XED_DLL_EXPORT void
139 XED_DLL_EXPORT void
142 
143 
145 
146 XED_DLL_EXPORT void
147 xed_immdis_add_byte(xed_immdis_t* p, xed_uint8_t b);
148 
149 
150 XED_DLL_EXPORT void
151 xed_immdis_add_byte_array(xed_immdis_t* p, int nb, xed_uint8_t* ba);
152 
162 XED_DLL_EXPORT void
163 xed_immdis_add_shortest_width_signed(xed_immdis_t* p, xed_int64_t x, xed_uint8_t legal_widths);
164 
166 XED_DLL_EXPORT void
167 xed_immdis_add_shortest_width_unsigned(xed_immdis_t* p, xed_uint64_t x, xed_uint8_t legal_widths );
168 
169 
171 XED_DLL_EXPORT void
172 xed_immdis_add8(xed_immdis_t* p, xed_int8_t d);
173 
175 XED_DLL_EXPORT void
176 xed_immdis_add16(xed_immdis_t* p, xed_int16_t d);
177 
179 XED_DLL_EXPORT void
180 xed_immdis_add32(xed_immdis_t* p, xed_int32_t d);
181 
183 XED_DLL_EXPORT void
184 xed_immdis_add64(xed_immdis_t* p, xed_int64_t d);
185 
187 
188 
190 
191 
193 XED_DLL_EXPORT int xed_immdis_print(const xed_immdis_t* p, char* buf, int buflen);
194 
197 XED_DLL_EXPORT int
198 xed_immdis_print_signed_or_unsigned(const xed_immdis_t* p, char* buf, int buflen);
199 
201 XED_DLL_EXPORT int
202 xed_immdis_print_value_signed(const xed_immdis_t* p, char* buf, int buflen);
203 
205 XED_DLL_EXPORT int
206 xed_immdis_print_value_unsigned(const xed_immdis_t* p, char* buf, int buflen);
207 
208 int xed_immdis__print_ptr(const xed_immdis_t* p, char* buf, int buflen);
209 #endif
210 
212 
213 
XED_DLL_EXPORT void xed_immdis_add8(xed_immdis_t *p, xed_int8_t d)
add an 8 bit value to the byte array
xed_bool_t immediate_is_unsigned
Definition: xed-immdis.h:74
XED_DLL_EXPORT xed_bool_t xed_immdis_is_unsigned(const xed_immdis_t *p)
Return true if signed.
XED_DLL_EXPORT int xed_immdis_print_value_signed(const xed_immdis_t *p, char *buf, int buflen)
print the signed value, appropriate width, with a leading 0x
XED_DLL_EXPORT void xed_immdis_add_byte(xed_immdis_t *p, xed_uint8_t b)
XED_DLL_EXPORT void xed_immdis_add_shortest_width_unsigned(xed_immdis_t *p, xed_uint64_t x, xed_uint8_t legal_widths)
See add_shortest_width_signed()
XED_DLL_EXPORT unsigned int xed_immdis_get_bytes(const xed_immdis_t *p)
return the number of bytes added
xed_uint8_t x[XED_MAX_IMMDIS_BYTES]
Definition: xed-immdis.h:64
int xed_immdis__print_ptr(const xed_immdis_t *p, char *buf, int buflen)
XED_DLL_EXPORT void xed_immdis_add32(xed_immdis_t *p, xed_int32_t d)
add a 32 bit value to the byte array
unsigned int xed_bool_t
Definition: xed-types.h:68
XED_DLL_EXPORT xed_uint64_t xed_immdis_get_unsigned64(const xed_immdis_t *p)
XED_DLL_EXPORT void xed_immdis_add16(xed_immdis_t *p, xed_int16_t d)
add a 16 bit value to the byte array
XED_DLL_EXPORT void xed_immdis_set_max_len(xed_immdis_t *p, unsigned int mx)
XED_DLL_EXPORT xed_bool_t xed_immdis_is_signed(const xed_immdis_t *p)
Return true if signed.
XED_DLL_EXPORT xed_uint8_t xed_immdis_get_byte(const xed_immdis_t *p, unsigned int i)
Access the i'th byte of the immediate.
XED_DLL_EXPORT int xed_immdis_print(const xed_immdis_t *p, char *buf, int buflen)
just print the raw bytes in hex with a leading 0x
XED_DLL_EXPORT void xed_immdis_add_byte_array(xed_immdis_t *p, int nb, xed_uint8_t *ba)
some pervasive defines
XED_DLL_EXPORT void xed_immdis_zero(xed_immdis_t *p)
XED_DLL_EXPORT void xed_immdis_add_shortest_width_signed(xed_immdis_t *p, xed_int64_t x, xed_uint8_t legal_widths)
Add 1, 2, 4 or 8 bytes depending on the value x and the mask of legal_widths.
XED_DLL_EXPORT void xed_immdis__check(xed_immdis_t *q, int p)
XED_DLL_EXPORT void xed_immdis_set_unsigned(xed_immdis_t *p)
Set the immediate to be unsigned; For decoder use only.
XED_DLL_EXPORT void xed_immdis_set_signed(xed_immdis_t *p)
Set the immediate to be signed; For decoder use only.
#define XED_MAX_IMMDIS_BYTES
Definition: xed-immdis.h:59
xed_bool_t present
Definition: xed-immdis.h:73
XED_DLL_EXPORT void xed_immdis_init(xed_immdis_t *p, int max_bytes)
XED_DLL_EXPORT xed_int64_t xed_immdis_get_signed64(const xed_immdis_t *p)
unsigned int max_allocated_space
Definition: xed-immdis.h:72
struct xed_immdis_s xed_immdis_t
Stores immediates and displacements for the encoder & decoder.
XED_DLL_EXPORT xed_bool_t xed_immdis_is_one(const xed_immdis_t *p)
XED_DLL_EXPORT void xed_immdis_set_present(xed_immdis_t *p)
unsigned int currently_used_space
Definition: xed-immdis.h:71
xed_uint64_t q
Definition: xed-immdis.h:65
union xed_immdis_values_t value
Definition: xed-immdis.h:70
XED_DLL_EXPORT int xed_immdis_print_value_unsigned(const xed_immdis_t *p, char *buf, int buflen)
print the unsigned value, appropriate width, with a leading 0x
XED_DLL_EXPORT unsigned int xed_immdis_get_max_length(const xed_immdis_t *p)
Stores immediates and displacements for the encoder & decoder.
Definition: xed-immdis.h:69
XED_DLL_EXPORT int xed_immdis_print_signed_or_unsigned(const xed_immdis_t *p, char *buf, int buflen)
Print the value as a signed or unsigned number depending on the value of the immediate_is_unsigned va...
XED_DLL_EXPORT xed_bool_t xed_immdis_is_present(const xed_immdis_t *p)
True if the object has had a value or individual bytes added to it.
#define XED_DLL_EXPORT
XED_DLL_EXPORT void xed_immdis_add64(xed_immdis_t *p, xed_int64_t d)
add a 64 bit value to the byte array.
XED_DLL_EXPORT xed_bool_t xed_immdis_is_zero(const xed_immdis_t *p)