1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3 <title>XED2: XED2 User Guide - Thu May 15 03:15:09 2008 </title>
4 <link href="doxygen.css" rel="stylesheet" type="text/css">
5 <link href="tabs.css" rel="stylesheet" type="text/css">
7 <!-- Generated by Doxygen 1.4.6 -->
10 <li><a href="main.html"><span>Main Page</span></a></li>
11 <li><a href="modules.html"><span>Modules</span></a></li>
12 <li><a href="classes.html"><span>Data Structures</span></a></li>
13 <li><a href="files.html"><span>Files</span></a></li>
15 <form action="search.php" method="get">
16 <table cellspacing="0" cellpadding="0" border="0">
18 <td><label> <u>S</u>earch for </label></td>
19 <td><input type="text" name="query" value="" size="20" accesskey="s"/></td>
25 <h1>XED command interface</h1>The command line tool called xed or xed.exe is built when you build the examples (<a class="el" href="group__EXAMPLES.html">Examples of using XED</a>) that come with XED. The xed-ex3 is just encode portion of the xed command line tool.<p>
26 This tool is useful for encoding and decoding or even decoding-then-re-encoding a single instruction or all the instructions in the text segment of an ELF binary (32 or 64b). For decoding, just jump to the examples.<p>
27 This section also explains a little language for writing the instructions for encode requests (-e option). I am constantly using this tool and updating it. The xed-ex3 (xed-ex3.exe) example is just the encoder portion of the xed command line tool.<p>
28 The SUPPRESSED operands emitted by the decoder are not used when encoding. They are ignored. They are not required to select an encoding.<p>
29 The syntax for encodable strings is as follows: <div class="fragment"><pre class="fragment"> Opcode[/width] [operand [operand]]
31 The width is a 8, 16, 32 or 64, indicating the effective operand width if it differs from the default. 8b operations generally require this. Or since most operations that default to 32b widths in 64b mode, it is required for 64b operation widths in 64b mode.<p>
32 The operand specifier is one of the following.<p>
34 <li>A register name such as EAX or R8B, etc. Case does not matter.</li></ul>
37 <li>An immediate specifier such as IMM(12ff) . Note: most shells require quotes because of the parens.</li></ul>
40 <li>A displacement specifier such as DISP(0000001f) . Note: need the quotes.</li></ul>
43 <li>A memory specifier that indicates the base register, index register, scale value, and displacement value. If one of the fields is not required, a - is necessary. The displacement is omittable. For example: MEM4(ESI,EAX,8,ff) or MEM4(EBX,-,-). The first one specifies that the memory address 4 bytes and should be ESI + EAX * 8 + 0xff. The second one specifies that EBX should be used to access 4 bytes of memory; note the displacement is omitted. A segment override can be specified as follows: MEM4(GS:EAX,-,-,-), by using a segment-name followed by a ":" before the base register. If there is no base register, you can use a "-", for example: MEM4(GS:-,-,11223344). One also needs to specify a memory operation width. This can be accomplished by indicating a number of bytes just after the MEM specifier. For example: MEM2(EAX,-,-) indicates a 2 byte memory operation.</li></ul>
46 <li>An address generation specifer that has the same syntax as the above MEM() specifier, but is only used for LEA instructions. Example: AGEN(EAX,EBX,2,-)</li></ul>
48 Here is the help message:<p>
49 <div class="fragment"><pre class="fragment">% obj/xed -h
50 Usage: obj/xed [options]
51 One of the following is required:
52 -i input_file (decode file)
53 -ide input_file (decode/encode file)
54 -d hex-string (decode one instruction)
55 -e instruction (encode, must be last)
56 -de hex-string (decode-then-encode)
59 -v verbosity (0=quiet, 1=errors, 2=useful-info, 3=trace, 5=very verbose)
60 -n number-of-instructions-to-decode (default 10,000, accepts K/M/G qualifiers)
61 -I (Intel SYSV syntax for disassembly)
62 -A (ATT SYSV syntax for disassembly)
63 -16 (for LEGACY_16 mode)
64 -32 (for LEGACY_32 mode, default)
65 -64 (for LONG_64 mode w/64b addressing)
66 -a32 (32b addressing, default, not in LONG_64 mode)
67 -a16 (16b addressing, not in LONG_64 mode)
68 -s32 (32b stack addressing, default, not in LONG_64 mode)
69 -s16 (16b stack addressing, not in LONG_64 mode)
71 Here are a couple of examples:<p>
72 <div class="fragment"><pre class="fragment">% xed -d 0000
73 ADD INT_ALU BASE Opcode: 00 MODRM: 00 Bytes: 2
74 Eb/EXPLICIT/RW Gb/EXPLICIT/R
76 MachineMode: LEGACY_32 AddrWidth: 32b StackAddrWidth: 32b
77 MEM/EXPLICIT/RW REG/AL(REG8)/EXPLICIT/R
78 Read Write BASE= EAX(REG32) MemopLength = 1
80 rFLAGS: of-mod sf-mod zf-mod af-mod pf-mod cf-mod Read: Written: of sf zf af pf cf writes
85 xed -e ADD EAX 'MEM4(ESP,EBX,4)'
89 PUSH INT_ALU BASE Opcode: 6a Immed: 00 Bytes: 2
90 Ib/EXPLICIT/R STACKPUSH/SUPPRESSED/R
92 MachineMode: LEGACY_32 AddrWidth: 32b StackAddrWidth: 32b
93 MEM/SUPPRESSED/W REG/ESP(REG32)/SUPPRESSED/RW IMM/EXPLICIT/R
94 Write SEG= SS BASE= ESP(REG32) MemopLength = 4
99 % xed -e MOV EAX 'MEM4(SS:ESP,-,-)'
102 Or using the xed-ex3 example tool: <div class="fragment"><pre class="fragment">% obj/xed-ex3
103 Usage: obj/xed-ex3 [-16|-32|-64] [-a16|-a32] [-s16|-s32] encode-string
105 The -16, -32 or -64 are for specifying the major mode of the machine. The -a16 and -a32 are for specifying 16 or 32 bit addressing. The default addressing mode in 64b mode is 64b addressing. The -s16 and -a32 are for specifying 16 or 32 bit stack addressing in 16 or 32 bit modes.<p>
106 <div class="fragment"><pre class="fragment">% obj/xed-ex3 -64 PUSH/64 RAX
108 PUSH Prefixes: EffOpWidth: 64b EffAddrWidth: 64b
109 MachineMode: LONG_64 AddrWidth: 64b StackAddrWidth: 32b
110 REG/RAX(REG64)/EXPLICIT/RW
115 % obj/xed-ex3 MOV 'MEM4(EAX,-,-)<span class="charliteral">' '</span>IMM(11223344)'
117 MOV Prefixes: EffOpWidth: 32b EffAddrWidth: 32b
118 MachineMode: LEGACY_32 AddrWidth: 32b StackAddrWidth: 32b
119 MEM0/EXPLICIT/RW IMM/EXPLICIT/RW
120 TmpltIdx=0 BASE= EAX(REG32) MemopLength = 0
121 IMMED: 0x11223344 <span class="keywordtype">signed</span>: 1144201745 starts@byte: 1
123 Encodable! c70011223344
124 </pre></div><h2><a class="anchor" name="ENCODE_EXAMPLE">
125 An example of using the encoder</a></h2>
126 The encoder language file which is part of the xed command line tool shows how to build up instructions from scratch. The example uses a string to drive the creation of the instruction, but that is just an example. Look at the parse_encode_request function for the required pieces.<p>
127 <div class="fragment"><pre class="fragment"><span class="comment">/*BEGIN_LEGAL </span>
128 <span class="comment">Copyright (c) 2007, Intel Corp.</span>
129 <span class="comment">All rights reserved.</span>
130 <span class="comment"></span>
131 <span class="comment">Redistribution and use in source and binary forms, with or without</span>
132 <span class="comment">modification, are permitted provided that the following conditions are</span>
133 <span class="comment">met:</span>
134 <span class="comment"></span>
135 <span class="comment"> * Redistributions of source code must retain the above copyright</span>
136 <span class="comment"> notice, this list of conditions and the following disclaimer.</span>
137 <span class="comment"></span>
138 <span class="comment"> * Redistributions in binary form must reproduce the above</span>
139 <span class="comment"> copyright notice, this list of conditions and the following</span>
140 <span class="comment"> disclaimer in the documentation and/or other materials provided</span>
141 <span class="comment"> with the distribution.</span>
142 <span class="comment"></span>
143 <span class="comment"> * Neither the name of Intel Corporation nor the names of its</span>
144 <span class="comment"> contributors may be used to endorse or promote products derived</span>
145 <span class="comment"> from this software without specific prior written permission.</span>
146 <span class="comment"></span>
147 <span class="comment">THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span>
148 <span class="comment">"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span>
149 <span class="comment">LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span>
150 <span class="comment">A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span>
151 <span class="comment">OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span>
152 <span class="comment">SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span>
153 <span class="comment">LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span>
154 <span class="comment">DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span>
155 <span class="comment">THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span>
156 <span class="comment">(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span>
157 <span class="comment">OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
158 <span class="comment">END_LEGAL */</span>
160 <span class="comment">// This is an example of how to use the encoder from scratch in the context</span>
161 <span class="comment">// of parsing a string from the command line. </span>
164 <span class="preprocessor">#include <iostream></span>
165 <span class="preprocessor">#include <iomanip></span>
166 <span class="preprocessor">#include <vector></span>
167 <span class="preprocessor">#include <sstream></span>
168 <span class="preprocessor">#include <cassert></span>
169 <span class="keyword">extern</span> <span class="stringliteral">"C"</span> {
170 <span class="preprocessor">#include "<a class="code" href="xed-interface_8h.html">xed-interface.h</a>"</span>
171 <span class="preprocessor">#include "<a class="code" href="xed-portability_8h.html">xed-portability.h</a>"</span>
172 <span class="preprocessor">#include "xed-examples-util.h"</span>
174 <span class="preprocessor">#include "xed-enc-lang.H"</span>
179 <span class="keyword">using namespace </span>std;
180 <span class="keyword">static</span> <span class="keywordtype">char</span> xed_enc_lang_toupper(<span class="keywordtype">char</span> c) {
181 <span class="keywordflow">if</span> (c >= <span class="charliteral">'a'</span> && c <= <span class="charliteral">'z'</span>)
182 <span class="keywordflow">return</span> c-<span class="charliteral">'a'</span>+<span class="charliteral">'A'</span>;
183 <span class="keywordflow">return</span> c;
186 <span class="keyword">static</span> string upcase(string s) {
187 string t = <span class="stringliteral">""</span>;
188 <a class="code" href="xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> len = static_cast<xed_uint_t>(s.size());
189 <a class="code" href="xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> i;
190 <span class="keywordflow">for</span>(i=0 ; i < len ; i++ )
191 t = t + xed_enc_lang_toupper(s[i]);
192 <span class="keywordflow">return</span> t;
195 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>
196 xed_split_args(<span class="keyword">const</span> string& sep,
197 <span class="keyword">const</span> string& input,
198 vector<string>& output_array)
200 <span class="comment">// returns the number of args</span>
201 <span class="comment">// rip off the separator characters and split the src string based on separators.</span>
203 <span class="comment">// find the string between last_pos and pos. pos is after last_pos</span>
204 string::size_type last_pos = input.find_first_not_of(sep, 0);
205 string::size_type pos = input.find_first_of(sep, last_pos);
206 <span class="keywordflow">if</span> (CLIENT_VERBOSE3)
207 printf(<span class="stringliteral">"input %s\tlast_pos "</span> <a class="code" href="xed-portability_8h.html#9091b96f5482bcfd24989443027cf922">XED_FMT_U</a> <span class="stringliteral">" pos "</span> <a class="code" href="xed-portability_8h.html#9091b96f5482bcfd24989443027cf922">XED_FMT_U</a> <span class="stringliteral">"\n"</span>,
208 input.c_str() , <a class="code" href="xed-portability_8h.html#8f026df65b9734e9def65ff4059605c5">STATIC_CAST</a>(<a class="code" href="xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a>,last_pos), <a class="code" href="xed-portability_8h.html#8f026df65b9734e9def65ff4059605c5">STATIC_CAST</a>(<a class="code" href="xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a>,pos));
209 <span class="keywordtype">int</span> i=0;
210 <span class="keywordflow">while</span>( pos != string::npos && last_pos != string::npos )
212 string a = input.substr(last_pos, pos-last_pos);
213 output_array.push_back(a);
214 <span class="keywordflow">if</span> (CLIENT_VERBOSE3)
215 printf(<span class="stringliteral">"\t\tlast_pos "</span> XED_FMT_U <span class="stringliteral">" pos "</span> XED_FMT_U <span class="stringliteral">" i %d\n"</span>,
216 <a class="code" href="xed-portability_8h.html#8f026df65b9734e9def65ff4059605c5">STATIC_CAST</a>(<a class="code" href="xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a>,last_pos),
217 <a class="code" href="xed-portability_8h.html#8f026df65b9734e9def65ff4059605c5">STATIC_CAST</a>(<a class="code" href="xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a>,pos),
219 last_pos = input.find_first_not_of(sep, pos);
220 pos = input.find_first_of(sep, last_pos);
223 <span class="keywordflow">if</span> (last_pos != string::npos && pos == string::npos)
225 <span class="keywordflow">if</span> (CLIENT_VERBOSE3)
226 printf(<span class="stringliteral">"\t\tGetting last substring at "</span> XED_FMT_U <span class="stringliteral">"\n"</span>, <a class="code" href="xed-portability_8h.html#8f026df65b9734e9def65ff4059605c5">STATIC_CAST</a>(<a class="code" href="xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a>,last_pos));
227 string a = input.substr(last_pos); <span class="comment">// get the rest of the string</span>
228 output_array.push_back(a);
231 <span class="keywordflow">if</span> (CLIENT_VERBOSE3)
232 printf(<span class="stringliteral">"\t returning %d\n"</span>,i);
233 <span class="keywordflow">return</span> i;
237 tokenize(<span class="keyword">const</span> string& s,
238 <span class="keyword">const</span> string& delimiter) {
239 vector<string> v;
240 (void) xed_split_args(delimiter, s, v);
241 <span class="keywordflow">return</span> v;
245 <span class="keywordtype">void</span> slash_split(<span class="keyword">const</span> string& src,
246 string& first, <span class="comment">// output</span>
247 string& second) <span class="comment">//output</span>
249 string::size_type p = src.find(<span class="stringliteral">"/"</span>);
250 <span class="keywordflow">if</span> (p == string::npos) {
252 second = <span class="stringliteral">""</span>;
254 <span class="keywordflow">else</span> {
255 first = src.substr(0,p);
256 second = src.substr(p+1);
260 <span class="keyword">class </span>immed_parser_t {
261 <span class="keyword">public</span>:
262 <a class="code" href="xed-types_8h.html#d355c921b747945a82d62233a599c7b5">xed_bool_t</a> valid;
264 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> width_bits;
265 xed_uint64_t immed_val;
268 immed_parser_t(<span class="keyword">const</span> string& s,
269 <span class="keyword">const</span> string& arg_tok0) <span class="comment">//CONS</span>
273 vector<string> vs = tokenize(s,<span class="stringliteral">"(),"</span>);
274 <span class="keywordflow">if</span> (vs.size() == 2) {
275 <span class="keywordflow">if</span> (vs[0] == tok0) {
276 string immed_str = vs[1];
277 immed_val = convert_ascii_hex_to_int(immed_str.c_str());
278 width_bits = static_cast<unsigned int>(immed_str.size()*4); <span class="comment">// nibbles to bits</span>
279 valid = <span class="keyword">true</span>;
284 <span class="keywordtype">void</span>
285 print(ostream& o)<span class="keyword"> const </span>{
287 << <span class="stringliteral">"("</span> ;
288 <span class="keywordflow">if</span> (valid)
289 o << hex << immed_val << dec;
290 <span class="keywordflow">else</span>
291 o << <span class="stringliteral">"???"</span>;
292 o << <span class="stringliteral">")"</span>;
297 ostream& operator<<(ostream& o, <span class="keyword">const</span> immed_parser_t& x)
300 <span class="keywordflow">return</span> o;
304 <span class="keyword">class </span>seg_parser_t
306 <span class="keyword">public</span>:
307 <a class="code" href="xed-types_8h.html#d355c921b747945a82d62233a599c7b5">xed_bool_t</a> valid;
308 <a class="code" href="xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> segment_reg;
311 seg_parser_t(<span class="keyword">const</span> string& s) <span class="comment">// CONS</span>
313 segment_reg(<a class="code" href="xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61fac474058f0819d415285511086bf219">XED_REG_INVALID</a>)
315 vector<string> vs = tokenize(s,<span class="stringliteral">"(),"</span>);
316 <a class="code" href="xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> ntokens = static_cast<xed_uint_t>(vs.size());
317 cerr << <span class="stringliteral">"ntokens "</span> << ntokens << <span class="stringliteral">": "</span> ;
318 <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0;i<ntokens;i++) cerr << <span class="charliteral">'['</span> << vs[i] << <span class="stringliteral">"] "</span>;
320 <span class="keywordflow">if</span> (ntokens == 2 && vs[0] == <span class="stringliteral">"SEG"</span>) {
322 segment_reg = <a class="code" href="xed-reg-enum_8h.html#48dc3d086b469ae580ca47917043c2fd">str2xed_reg_enum_t</a>(segment.c_str());
323 <span class="keywordflow">if</span> (segment_reg != <a class="code" href="xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61fac474058f0819d415285511086bf219">XED_REG_INVALID</a> && <a class="code" href="group__REGINTFC.html#g9003309edac48c9c1dfca2187497c613">xed_reg_class</a>(segment_reg) == <a class="code" href="xed-reg-class-enum_8h.html#8ac6bf3f9f78208385c46ea25324ea76b02b323ba71ce251bca0ac4206b7d028">XED_REG_CLASS_SR</a>) {
324 valid=<span class="keyword">true</span>;
331 <span class="keyword">class </span>mem_bis_parser_t
333 <span class="comment">// parse: MEM[length]([segment:]base,index,scale[,displacement])</span>
334 <span class="comment">// parse: AGEN(base,index,scale[,displacement])</span>
335 <span class="comment">// The displacement is optional</span>
336 <span class="comment">// The length of the memop is usually optional </span>
337 <span class="comment">// but required for x87 ops, for example.</span>
338 <span class="keyword">public</span>:
339 <a class="code" href="xed-types_8h.html#d355c921b747945a82d62233a599c7b5">xed_bool_t</a> valid;
340 <a class="code" href="xed-types_8h.html#d355c921b747945a82d62233a599c7b5">xed_bool_t</a> mem;
342 <a class="code" href="xed-types_8h.html#d355c921b747945a82d62233a599c7b5">xed_bool_t</a> agen;
343 <a class="code" href="xed-types_8h.html#d355c921b747945a82d62233a599c7b5">xed_bool_t</a> disp_valid;
348 string disp; <span class="comment">//displacement</span>
349 <a class="code" href="xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> segment_reg;
350 <a class="code" href="xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> base_reg;
351 <a class="code" href="xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> index_reg;
352 xed_uint8_t scale_val;
355 xed_int64_t disp_val;
356 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> disp_width_bits;
358 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> mem_len;
360 <span class="keywordtype">void</span>
361 print(ostream& o)<span class="keyword"> const </span>{
362 <span class="keywordflow">if</span> (agen)
363 o << <span class="stringliteral">"AGEN"</span>;
364 <span class="keywordflow">if</span> (mem)
365 o << <span class="stringliteral">"MEM"</span>;
366 <span class="keywordflow">if</span> (mem_len)
367 o << setw(1) << mem_len;
368 o << <span class="stringliteral">"("</span>;
369 <span class="keywordflow">if</span> (segment_reg != <a class="code" href="xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61fac474058f0819d415285511086bf219">XED_REG_INVALID</a>)
370 o << segment_reg << <span class="stringliteral">":"</span>;
372 o << <span class="stringliteral">","</span> << index_reg
373 << <span class="stringliteral">","</span>
374 << (<span class="keywordtype">unsigned</span> int) scale_val;
375 <span class="keywordflow">if</span> (disp_valid)
376 o << <span class="stringliteral">","</span> << disp;
377 o << <span class="stringliteral">")"</span>;
381 mem_bis_parser_t(<span class="keyword">const</span> string& s) <span class="comment">//CONS</span>
384 base(<span class="stringliteral">"INVALID"</span>),
385 index(<span class="stringliteral">"INVALID"</span>),
386 scale(<span class="stringliteral">"1"</span>),
387 segment_reg(<a class="code" href="xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61fac474058f0819d415285511086bf219">XED_REG_INVALID</a>),
388 base_reg(<a class="code" href="xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61fac474058f0819d415285511086bf219">XED_REG_INVALID</a>),
389 index_reg(<a class="code" href="xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61fac474058f0819d415285511086bf219">XED_REG_INVALID</a>),
395 mem = <span class="keyword">false</span>;
396 agen = <span class="keyword">false</span>;
397 vector<string> vs = tokenize(s,<span class="stringliteral">"(),"</span>);
398 <a class="code" href="xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> ntokens = static_cast<xed_uint_t>(vs.size());
399 <span class="keywordflow">if</span> (ntokens >= 2 && ntokens <= 5) {
400 <span class="keywordflow">if</span> (vs[0] == <span class="stringliteral">"AGEN"</span>) {
401 agen = <span class="keyword">true</span>;
403 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (vs[0].substr(0,3) == <span class="stringliteral">"MEM"</span>) {
404 mem = <span class="keyword">true</span>;
405 <span class="keywordflow">if</span> (vs[0].size() > 3) {
406 string len = vs[0].substr(3);
407 mem_len = strtol(len.c_str(),0,0);
408 <span class="comment">//printf("mem_len = " XED_FMT_U "\n", mem_len);</span>
411 <span class="keywordflow">else</span> {
412 <span class="keywordflow">return</span>;
415 segment = <span class="stringliteral">"INVALID"</span>;
416 string seg_and_base = upcase(vs[1]);
417 vector<string> sb = tokenize(seg_and_base,<span class="stringliteral">":"</span>);
418 <span class="keywordtype">int</span> seg_and_base_tokens = <a class="code" href="xed-portability_8h.html#8f026df65b9734e9def65ff4059605c5">STATIC_CAST</a>(<span class="keywordtype">int</span>,sb.size());
419 <span class="keywordflow">if</span> (seg_and_base_tokens == 1) {
420 segment = <span class="stringliteral">"INVALID"</span>;
423 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (seg_and_base_tokens == 2) {
424 <span class="keywordflow">if</span> (agen) {
425 xedex_derror(<span class="stringliteral">"AGENs cannot have segment overrides"</span>);
430 <span class="keywordflow">else</span> {
431 printf(<span class="stringliteral">"seg_and_base_tokens = %d\n"</span>,seg_and_base_tokens);
432 xedex_derror(<span class="stringliteral">"Bad segment-and-base specifier."</span>);
435 <span class="keywordflow">if</span> (base == <span class="stringliteral">"-"</span> || base == <span class="stringliteral">"NA"</span>) {
436 base = <span class="stringliteral">"INVALID"</span>;
438 <span class="keywordflow">if</span> (ntokens > 2) {
439 index = upcase(vs[2]);
440 <span class="keywordflow">if</span> (index == <span class="stringliteral">"-"</span> || index == <span class="stringliteral">"NA"</span>) {
441 index = <span class="stringliteral">"INVALID"</span>;
445 <span class="keywordflow">if</span> (ntokens > 3) {
447 <span class="keywordflow">if</span> (scale == <span class="stringliteral">"-"</span> || scale == <span class="stringliteral">"NA"</span>) {
448 scale = <span class="stringliteral">"1"</span>;
451 <span class="keywordflow">if</span> (scale == <span class="stringliteral">"1"</span> || scale == <span class="stringliteral">"2"</span> || scale == <span class="stringliteral">"4"</span> || scale == <span class="stringliteral">"8"</span>) {
452 valid=<span class="keyword">true</span>;
453 scale_val = <a class="code" href="xed-portability_8h.html#8f026df65b9734e9def65ff4059605c5">STATIC_CAST</a>(xed_uint8_t,strtol(scale.c_str(), 0, 10));
454 segment_reg = <a class="code" href="xed-reg-enum_8h.html#48dc3d086b469ae580ca47917043c2fd">str2xed_reg_enum_t</a>(segment.c_str());
455 base_reg = <a class="code" href="xed-reg-enum_8h.html#48dc3d086b469ae580ca47917043c2fd">str2xed_reg_enum_t</a>(base.c_str());
456 index_reg = <a class="code" href="xed-reg-enum_8h.html#48dc3d086b469ae580ca47917043c2fd">str2xed_reg_enum_t</a>(index.c_str());
458 <span class="comment">// look for a displacement</span>
459 <span class="keywordflow">if</span> (ntokens == 5 && vs[4] != <span class="stringliteral">"-"</span>) {
461 disp_valid = <span class="keyword">true</span>;
462 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nibbles = <a class="code" href="xed-portability_8h.html#8f026df65b9734e9def65ff4059605c5">STATIC_CAST</a>(<span class="keywordtype">int</span>,disp.size());
463 <span class="keywordflow">if</span> (nibbles & 1) {
464 <span class="comment">// ensure an even number of nibbles</span>
465 string zero(<span class="stringliteral">"0"</span>);
469 disp_val = convert_ascii_hex_to_int(disp.c_str());
470 disp_width_bits = nibbles*4; <span class="comment">// nibbles to bits</span>
479 ostream& operator<<(ostream& o, <span class="keyword">const</span> mem_bis_parser_t& x) {
481 <span class="keywordflow">return</span> o;
484 <a class="code" href="group__ENC.html#g6f914541ddfa1ffe609acebff72d0b5f">xed_encoder_request_t</a> parse_encode_request(ascii_encode_request_t& areq) {
485 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i;
486 <a class="code" href="group__ENC.html#g6f914541ddfa1ffe609acebff72d0b5f">xed_encoder_request_t</a> req;
487 <a class="code" href="group__ENC.html#g8a379853ad688ff61de9e73862617e40">xed_encoder_request_zero_set_mode</a>(&req,&(areq.dstate)); <span class="comment">// calls xed_encoder_request_zero()</span>
489 <span class="comment">/* This is the important function here. This encodes an instruction from scratch.</span>
490 <span class="comment"> </span>
491 <span class="comment"> You must set:</span>
492 <span class="comment"> the machine mode (machine width, addressing widths)</span>
493 <span class="comment"> the effective operand width</span>
494 <span class="comment"> the iclass</span>
495 <span class="comment"> for some instructions you need to specify prefixes (like REP or LOCK).</span>
496 <span class="comment"> the operands:</span>
497 <span class="comment"> operand kind (XED_OPERAND_{AGEN,MEM0,MEM1,IMM0,IMM1,RELBR,PTR,REG0...REG15}</span>
498 <span class="comment"> operand order </span>
499 <span class="comment"> xed_encoder_request_set_operand_order(&req,operand_index, XED_OPERAND_*);</span>
500 <span class="comment"> where the operand_index is a sequential index starting at zero.</span>
501 <span class="comment"></span>
502 <span class="comment"> operand details </span>
503 <span class="comment"> FOR MEMOPS: base,segment,index,scale,displacement for memops, </span>
504 <span class="comment"> FOR REGISTERS: register name</span>
505 <span class="comment"> FOR IMMEDIATES: immediate values</span>
506 <span class="comment"> </span>
507 <span class="comment"> */</span>
510 <span class="keywordflow">switch</span>(<a class="code" href="group__INIT.html#g8b1fc00b95c50fd54959889d72dc569a">xed_state_get_machine_mode</a>(&(areq.dstate))) {
511 <span class="comment">// set the default width.</span>
512 <span class="keywordflow">case</span> <a class="code" href="xed-machine-mode-enum_8h.html#754db9d73c5365644094cd161fe570a7708dc25876ca1910c387c0a4f2f066cb">XED_MACHINE_MODE_LONG_64</a>:
513 <a class="code" href="group__ENC.html#g53b937905ca110c4dd4b20e5695d8937">xed_encoder_request_set_effective_operand_width</a>(&req, 32);
514 <a class="code" href="group__ENC.html#gb416edcadb0d2b59fb62cfcd93991c3d">xed_encoder_request_set_effective_address_size</a>(&req, 64);
515 <span class="keywordflow">break</span>;
517 <span class="keywordflow">case</span> <a class="code" href="xed-machine-mode-enum_8h.html#754db9d73c5365644094cd161fe570a7a96a9d517621e28100e179eff7c92458">XED_MACHINE_MODE_LEGACY_32</a>:
518 <span class="keywordflow">case</span> <a class="code" href="xed-machine-mode-enum_8h.html#754db9d73c5365644094cd161fe570a71f0b512a8836f22da0b51bee9c656cd2">XED_MACHINE_MODE_LONG_COMPAT_32</a>:
519 <a class="code" href="group__ENC.html#g53b937905ca110c4dd4b20e5695d8937">xed_encoder_request_set_effective_operand_width</a>(&req, 32);
520 <a class="code" href="group__ENC.html#gb416edcadb0d2b59fb62cfcd93991c3d">xed_encoder_request_set_effective_address_size</a>(&req, 32);
521 <span class="keywordflow">break</span>;
523 <span class="keywordflow">case</span> <a class="code" href="xed-machine-mode-enum_8h.html#754db9d73c5365644094cd161fe570a7389547057da410225afe20064b3a4c0e">XED_MACHINE_MODE_LEGACY_16</a>:
524 <span class="keywordflow">case</span> <a class="code" href="xed-machine-mode-enum_8h.html#754db9d73c5365644094cd161fe570a74cfc0a828f9fce37f07d0764d49a0976">XED_MACHINE_MODE_LONG_COMPAT_16</a>:
525 <a class="code" href="group__ENC.html#g53b937905ca110c4dd4b20e5695d8937">xed_encoder_request_set_effective_operand_width</a>(&req, 16);
526 <a class="code" href="group__ENC.html#gb416edcadb0d2b59fb62cfcd93991c3d">xed_encoder_request_set_effective_address_size</a>(&req, 16);
527 <span class="keywordflow">break</span>;
529 <span class="keywordflow">default</span>:
533 <span class="comment">//FIXME: allow changing the effective address size from the above defaults.</span>
535 vector<string> tokens = tokenize(areq.command,<span class="stringliteral">" "</span>);
536 <span class="comment">// first token has the operand and our temporary hack for the immediate</span>
538 string first, second;
539 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> token_index = 0;
541 <span class="keywordflow">while</span>(token_index < tokens.size()) {
542 slash_split(tokens[token_index], first, second);
543 <span class="keywordflow">if</span> (CLIENT_VERBOSE3)
544 printf( <span class="stringliteral">"[%s][%s][%s]\n"</span>, tokens[0].c_str(), first.c_str(), second.c_str());
546 <span class="keywordflow">if</span> (token_index == 0 && first == <span class="stringliteral">"REP"</span>) {
547 <a class="code" href="group__ENC.html#g71d03e9d694f56fc362974f2d81e5464">xed_encoder_request_set_rep</a>(&req);
549 <span class="keywordflow">continue</span>;
551 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (token_index == 0 && first == <span class="stringliteral">"REPNE"</span>) {
552 <a class="code" href="group__ENC.html#gf651a483ec90cbf4495f87b114facc0b">xed_encoder_request_set_repne</a>(&req);
554 <span class="keywordflow">continue</span>;
558 <span class="keywordflow">break</span>;
561 <span class="comment">// we can attempt to override the mode </span>
562 <span class="keywordflow">if</span> (second == <span class="stringliteral">"8"</span>)
563 <a class="code" href="group__ENC.html#g53b937905ca110c4dd4b20e5695d8937">xed_encoder_request_set_effective_operand_width</a>(&req, 8);
564 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (second == <span class="stringliteral">"16"</span>)
565 <a class="code" href="group__ENC.html#g53b937905ca110c4dd4b20e5695d8937">xed_encoder_request_set_effective_operand_width</a>(&req, 16);
566 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (second == <span class="stringliteral">"32"</span>)
567 <a class="code" href="group__ENC.html#g53b937905ca110c4dd4b20e5695d8937">xed_encoder_request_set_effective_operand_width</a>(&req, 32);
568 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (second == <span class="stringliteral">"64"</span>)
569 <a class="code" href="group__ENC.html#g53b937905ca110c4dd4b20e5695d8937">xed_encoder_request_set_effective_operand_width</a>(&req, 64);
571 first = upcase(first);
572 <a class="code" href="xed-iclass-enum_8h.html#d318511ae9cc50f102251b3c91a1ab9f">xed_iclass_enum_t</a> iclass = <a class="code" href="xed-iclass-enum_8h.html#c4b76adf6ede75bbc5754866187fcfa2">str2xed_iclass_enum_t</a>(first.c_str());
573 <span class="keywordflow">if</span> (iclass == <a class="code" href="xed-iclass-enum_8h.html#d318511ae9cc50f102251b3c91a1ab9f2c77d475f97998fe763062db09fd15de">XED_ICLASS_INVALID</a>) {
575 os << <span class="stringliteral">"Bad instruction name: "</span> << first;
576 xedex_derror(os.str().c_str());
578 <a class="code" href="group__ENC.html#gff030e16b97deae21b1f7613684c54c7">xed_encoder_request_set_iclass</a>(&req, iclass );
580 <a class="code" href="xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> memop = 0;
581 <a class="code" href="xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> regnum = 0;
582 <span class="comment">// put the operands in the request. Loop through tokens </span>
583 <span class="comment">// (skip the opcode iclass, handled above)</span>
584 <a class="code" href="xed-types_8h.html#0c92e8263b7ca02d8e4826ae5b79bb30">xed_uint_t</a> operand_index = 0;
585 <span class="keywordflow">for</span>( i=token_index; i < tokens.size(); i++, operand_index++ ) {
586 string str_res_reg, second_x;
587 slash_split(tokens[i], str_res_reg, second_x);
588 str_res_reg = upcase(str_res_reg);
589 <span class="comment">// prune the AGEN or MEM(base,index,scale[,displacement]) text from str_res_reg</span>
590 <span class="comment">// FIXME: add MEM(immed) for the OC1_A and OC1_O types????</span>
591 mem_bis_parser_t mem_bis(str_res_reg);
592 <span class="keywordflow">if</span> (mem_bis.valid) {
593 <span class="keywordflow">if</span> (mem_bis.mem) {
594 <span class="keywordflow">if</span> (memop == 0) {
595 <span class="comment">// Tell XED that we have a memory operand</span>
596 <a class="code" href="group__ENC.html#g7b4e446882bcc615e917132f3fbb16b3">xed_encoder_request_set_mem0</a>(&req);
597 <span class="comment">// Tell XED that the mem0 operand is the next operand:</span>
598 <a class="code" href="group__ENC.html#g1e46ce602263f0de591b3ebc268cc12e">xed_encoder_request_set_operand_order</a>(&req,operand_index, <a class="code" href="xed-operand-enum_8h.html#09c2a35d8bb7bfe68bb3d34b0a5e011a17757f8f75fb149d6a9ceff628403994">XED_OPERAND_MEM0</a>);
600 <span class="keywordflow">else</span> {
601 <a class="code" href="group__ENC.html#gfe70e5db7dc59e9880f2db3ec7e71d9d">xed_encoder_request_set_mem1</a>(&req);
602 <span class="comment">// Tell XED that the mem1 operand is the next operand:</span>
603 <a class="code" href="group__ENC.html#g1e46ce602263f0de591b3ebc268cc12e">xed_encoder_request_set_operand_order</a>(&req,operand_index, <a class="code" href="xed-operand-enum_8h.html#09c2a35d8bb7bfe68bb3d34b0a5e011abe26987877ba7bfe6b67c7106fd77286">XED_OPERAND_MEM1</a>);
607 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (mem_bis.agen) {
608 <span class="comment">// Tell XED we have an AGEN</span>
609 <a class="code" href="group__ENC.html#gac846d407fd6537461a6efaccff7609d">xed_encoder_request_set_agen</a>(&req);
610 <span class="comment">// The AGEN is the next operand</span>
611 <a class="code" href="group__ENC.html#g1e46ce602263f0de591b3ebc268cc12e">xed_encoder_request_set_operand_order</a>(&req,operand_index, <a class="code" href="xed-operand-enum_8h.html#09c2a35d8bb7bfe68bb3d34b0a5e011a3ce839ecfbe4f991f6c46b7cb767a703">XED_OPERAND_AGEN</a>);
613 <span class="keywordflow">else</span>
614 assert(mem_bis.agen || mem_bis.mem);
616 <a class="code" href="xed-reg-class-enum_8h.html#8ac6bf3f9f78208385c46ea25324ea76">xed_reg_class_enum_t</a> rc = <a class="code" href="group__REGINTFC.html#g46208c55a69fb76e42f1b5755aa4923e">xed_gpr_reg_class</a>(mem_bis.base_reg);
617 <a class="code" href="xed-reg-class-enum_8h.html#8ac6bf3f9f78208385c46ea25324ea76">xed_reg_class_enum_t</a> rci = <a class="code" href="group__REGINTFC.html#g46208c55a69fb76e42f1b5755aa4923e">xed_gpr_reg_class</a>(mem_bis.index_reg);
618 <span class="keywordflow">if</span> (mem_bis.base_reg != <a class="code" href="xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61fac474058f0819d415285511086bf219">XED_REG_INVALID</a> && mem_bis.index_reg != <a class="code" href="xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61fac474058f0819d415285511086bf219">XED_REG_INVALID</a>)
619 <span class="keywordflow">if</span> (rc != rci) {
621 os << <span class="stringliteral">"The base and index regs do not agree on the address size"</span> << endl;
622 xedex_derror(os.str().c_str()); <span class="comment">// dies</span>
625 <span class="keywordflow">if</span> (rc == <a class="code" href="xed-reg-class-enum_8h.html#8ac6bf3f9f78208385c46ea25324ea76aca8356f5ea67683de3d49fb3de4583f">XED_REG_CLASS_GPR32</a> || rci == <a class="code" href="xed-reg-class-enum_8h.html#8ac6bf3f9f78208385c46ea25324ea76aca8356f5ea67683de3d49fb3de4583f">XED_REG_CLASS_GPR32</a>)
626 <a class="code" href="group__ENC.html#gb416edcadb0d2b59fb62cfcd93991c3d">xed_encoder_request_set_effective_address_size</a>(&req, 32);
628 <span class="comment">// fill in the memory fields</span>
629 <a class="code" href="group__ENC.html#g9002c58e013af93550df7bd9b37e13ed">xed_encoder_request_set_base0</a>(&req, mem_bis.base_reg);
630 <a class="code" href="group__ENC.html#gd436ed3d253f15e11f4c943e0308db06">xed_encoder_request_set_index</a>(&req, mem_bis.index_reg);
631 <a class="code" href="group__ENC.html#gca791f284c852c6ae4c071ba5751d257">xed_encoder_request_set_scale</a>(&req, mem_bis.scale_val);
632 <a class="code" href="group__ENC.html#g72a43d42aa1c15bba69bcab84439471a">xed_encoder_request_set_seg0</a>(&req, mem_bis.segment_reg);
634 <span class="keywordflow">if</span> (mem_bis.mem_len)
635 <a class="code" href="group__ENC.html#g03790a14a625c544edcbda559e359f14">xed_encoder_request_set_memory_operand_length</a>(&req, mem_bis.mem_len ); <span class="comment">// BYTES</span>
636 <span class="keywordflow">if</span> (mem_bis.disp_valid)
637 <a class="code" href="group__ENC.html#gf745dfb40af1361b8a9b9f1ecb4f0228">xed_encoder_request_set_memory_displacement</a>(&req,
639 mem_bis.disp_width_bits/8);
640 <span class="keywordflow">continue</span>;
643 seg_parser_t seg_parser(str_res_reg);
644 <span class="keywordflow">if</span> (seg_parser.valid) {
645 printf(<span class="stringliteral">"Setting segment to %s\n"</span>, <a class="code" href="xed-reg-enum_8h.html#2219331ccd4d809d431e81fe5e857e95">xed_reg_enum_t2str</a>(seg_parser.segment_reg));
646 <a class="code" href="group__ENC.html#g72a43d42aa1c15bba69bcab84439471a">xed_encoder_request_set_seg0</a>(&req, seg_parser.segment_reg);
647 <a class="code" href="group__ENC.html#g1e46ce602263f0de591b3ebc268cc12e">xed_encoder_request_set_operand_order</a>(&req, operand_index, <a class="code" href="xed-operand-enum_8h.html#09c2a35d8bb7bfe68bb3d34b0a5e011a2c3c0c5a73438245c6d52fc0f1e4ea1d">XED_OPERAND_SEG0</a>);
648 <span class="keywordflow">continue</span>;
651 immed_parser_t imm(str_res_reg, <span class="stringliteral">"IMM"</span>);
652 <span class="keywordflow">if</span> (imm.valid) {
653 <span class="keywordflow">if</span> (CLIENT_VERBOSE3)
654 printf(<span class="stringliteral">"Setting immediate value to "</span> <a class="code" href="xed-portability_8h.html#99b93e37a937348afa3e458fb1e04fb1">XED_FMT_LX</a> <span class="stringliteral">"\n"</span>, imm.immed_val);
655 <a class="code" href="group__ENC.html#g5dcaec413dfefdd6ca2ad179e5a181c9">xed_encoder_request_set_uimm0_bits</a>(&req,
658 <a class="code" href="group__ENC.html#g1e46ce602263f0de591b3ebc268cc12e">xed_encoder_request_set_operand_order</a>(&req,operand_index, <a class="code" href="xed-operand-enum_8h.html#09c2a35d8bb7bfe68bb3d34b0a5e011a7cfee5454147cd3ea586172facd26f30">XED_OPERAND_IMM0</a>);
659 <span class="keywordflow">continue</span>;
661 immed_parser_t simm(str_res_reg, <span class="stringliteral">"SIMM"</span>);
662 <span class="keywordflow">if</span> (simm.valid) {
663 <span class="keywordflow">if</span> (CLIENT_VERBOSE3)
664 printf(<span class="stringliteral">"Setting immediate value to "</span> <a class="code" href="xed-portability_8h.html#99b93e37a937348afa3e458fb1e04fb1">XED_FMT_LX</a> <span class="stringliteral">"\n"</span>, simm.immed_val);
665 <a class="code" href="group__ENC.html#gf2477dc50a13ec112d7cf3f3fa5c9178">xed_encoder_request_set_simm</a>(&req,
666 <a class="code" href="xed-portability_8h.html#8f026df65b9734e9def65ff4059605c5">STATIC_CAST</a>(xed_int32_t,simm.immed_val),
667 simm.width_bits/8); <span class="comment">//FIXME</span>
668 <a class="code" href="group__ENC.html#g1e46ce602263f0de591b3ebc268cc12e">xed_encoder_request_set_operand_order</a>(&req,operand_index, <a class="code" href="xed-operand-enum_8h.html#09c2a35d8bb7bfe68bb3d34b0a5e011a7cfee5454147cd3ea586172facd26f30">XED_OPERAND_IMM0</a>);
669 <span class="keywordflow">continue</span>;
671 immed_parser_t imm2(str_res_reg, <span class="stringliteral">"IMM2"</span>);
672 <span class="keywordflow">if</span> (imm2.valid) {
673 <span class="keywordflow">if</span> (imm2.width_bits != 8)
674 xedex_derror(<span class="stringliteral">"2nd immediate must be just 1 byte long"</span>);
675 <a class="code" href="group__ENC.html#g4edd1347ebaceee3811584123b4daa9b">xed_encoder_request_set_uimm1</a>(&req, imm2.immed_val);
676 <a class="code" href="group__ENC.html#g1e46ce602263f0de591b3ebc268cc12e">xed_encoder_request_set_operand_order</a>(&req,operand_index, <a class="code" href="xed-operand-enum_8h.html#09c2a35d8bb7bfe68bb3d34b0a5e011aecf4b40f8ec183182501a80b93b5b4dc">XED_OPERAND_IMM1</a>);
677 <span class="keywordflow">continue</span>;
680 immed_parser_t disp(str_res_reg, <span class="stringliteral">"BRDISP"</span>);
681 <span class="keywordflow">if</span> (disp.valid) {
682 <span class="keywordflow">if</span> (CLIENT_VERBOSE3)
683 printf(<span class="stringliteral">"Setting displacement value to "</span> <a class="code" href="xed-portability_8h.html#99b93e37a937348afa3e458fb1e04fb1">XED_FMT_LX</a> <span class="stringliteral">"\n"</span>, disp.immed_val);
684 <a class="code" href="group__ENC.html#g3594acbdb2001a816da28b7554b2ae4c">xed_encoder_request_set_branch_displacement</a>(&req,
685 <a class="code" href="xed-portability_8h.html#8f026df65b9734e9def65ff4059605c5">STATIC_CAST</a>(xed_uint32_t,disp.immed_val),
686 disp.width_bits/8); <span class="comment">//FIXME</span>
687 <a class="code" href="group__ENC.html#g1e46ce602263f0de591b3ebc268cc12e">xed_encoder_request_set_operand_order</a>(&req,operand_index, <a class="code" href="xed-operand-enum_8h.html#09c2a35d8bb7bfe68bb3d34b0a5e011a6f36302cd147e020b2662b75fa314c17">XED_OPERAND_RELBR</a>);
688 <a class="code" href="group__ENC.html#gd447fb779e58b7eaae0dd54e51af6066">xed_encoder_request_set_relbr</a>(&req);
689 <span class="keywordflow">continue</span>;
692 immed_parser_t ptr_disp(str_res_reg, <span class="stringliteral">"PTR"</span>);
693 <span class="keywordflow">if</span> (ptr_disp.valid) {
694 <span class="keywordflow">if</span> (CLIENT_VERBOSE3)
695 printf(<span class="stringliteral">"Setting pointer displacement value to "</span> <a class="code" href="xed-portability_8h.html#99b93e37a937348afa3e458fb1e04fb1">XED_FMT_LX</a> <span class="stringliteral">"\n"</span>, ptr_disp.immed_val);
696 <a class="code" href="group__ENC.html#g3594acbdb2001a816da28b7554b2ae4c">xed_encoder_request_set_branch_displacement</a>(&req,
697 <a class="code" href="xed-portability_8h.html#8f026df65b9734e9def65ff4059605c5">STATIC_CAST</a>(xed_uint32_t,ptr_disp.immed_val),
698 ptr_disp.width_bits/8); <span class="comment">//FIXME</span>
699 <a class="code" href="group__ENC.html#g1e46ce602263f0de591b3ebc268cc12e">xed_encoder_request_set_operand_order</a>(&req,operand_index, <a class="code" href="xed-operand-enum_8h.html#09c2a35d8bb7bfe68bb3d34b0a5e011af84141b5908fd0d494f446a66f3eeef3">XED_OPERAND_PTR</a>);
700 <a class="code" href="group__ENC.html#g7be1c7da28a5d88f485f7e80b67959b4">xed_encoder_request_set_ptr</a>(&req);
701 <span class="keywordflow">continue</span>;
704 <a class="code" href="xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61">xed_reg_enum_t</a> reg = <a class="code" href="xed-reg-enum_8h.html#48dc3d086b469ae580ca47917043c2fd">str2xed_reg_enum_t</a>(str_res_reg.c_str());
705 <span class="keywordflow">if</span> (reg == <a class="code" href="xed-reg-enum_8h.html#f05c33c5a68e9304d1d8ac0408ae3f61fac474058f0819d415285511086bf219">XED_REG_INVALID</a>) {
707 os << <span class="stringliteral">"Bad register name: "</span> << str_res_reg << <span class="stringliteral">" on operand "</span> << i;
708 xedex_derror(os.str().c_str()); <span class="comment">// dies</span>
710 <span class="comment">// The registers operands aer numbered starting from the first one</span>
711 <span class="comment">// as XED_OPERAND_REG0. We incremenet regnum (below) every time we add a</span>
712 <span class="comment">// register operands.</span>
713 <a class="code" href="xed-operand-enum_8h.html#09c2a35d8bb7bfe68bb3d34b0a5e011a">xed_operand_enum_t</a> r = <a class="code" href="xed-portability_8h.html#8f026df65b9734e9def65ff4059605c5">STATIC_CAST</a>(<a class="code" href="xed-operand-enum_8h.html#09c2a35d8bb7bfe68bb3d34b0a5e011a">xed_operand_enum_t</a>,<a class="code" href="xed-operand-enum_8h.html#09c2a35d8bb7bfe68bb3d34b0a5e011a4a8a5c45ea6041f25d7b98e3892bb389">XED_OPERAND_REG0</a> + regnum);
714 <span class="comment">// store the register identifer in the operand storage field</span>
715 <a class="code" href="group__ENC.html#gba22ae36cab0f632d5461830cc9a3133">xed_encoder_request_set_reg</a>(&req, r, reg);
716 <span class="comment">// store the operand storage field name in the encode-order array</span>
717 <a class="code" href="group__ENC.html#g1e46ce602263f0de591b3ebc268cc12e">xed_encoder_request_set_operand_order</a>(&req, operand_index, r);
719 } <span class="comment">// for loop</span>
721 <span class="keywordflow">return</span> req;
725 <table border="0" cellpadding="0" cellspacing="0">
728 <hr size="1"><address style="align: right;"><small>Generated on Thu May 15 03:15:09 2008 for XED2 by
729 <a href="http://www.doxygen.org/index.html">
730 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>