|
34 | 34 | /* |
35 | 35 | * assemble.c code generation for the Netwide Assembler |
36 | 36 | * |
37 | | - * Bytecode specification |
38 | | - * ---------------------- |
39 | | - * |
40 | | - * |
41 | | - * Codes Mnemonic Explanation |
42 | | - * |
43 | | - * \0 terminates the code. (Unless it's a literal of course.) |
44 | | - * \1..\4 that many literal bytes follow in the code stream |
45 | | - * \5 add 4 to the primary operand number (b, low octdigit) |
46 | | - * \6 add 4 to the secondary operand number (a, middle octdigit) |
47 | | - * \7 add 4 to both the primary and the secondary operand number |
48 | | - * \10..\13 a literal byte follows in the code stream, to be added |
49 | | - * to the register value of operand 0..3 |
50 | | - * \14..\17 the position of index register operand in MIB (BND insns) |
51 | | - * \20..\23 ib a byte immediate operand, from operand 0..3 |
52 | | - * \24..\27 ib,u a zero-extended byte immediate operand, from operand 0..3 |
53 | | - * \30..\33 iw a word immediate operand, from operand 0..3 |
54 | | - * \34..\37 iwd select between \3[0-3] and \4[0-3] depending on 16/32 bit |
55 | | - * assembly mode or the operand-size override on the operand |
56 | | - * \40..\43 id a long immediate operand, from operand 0..3 |
57 | | - * \44..\47 iwdq select between \3[0-3], \4[0-3] and \5[4-7] |
58 | | - * depending on the address size of the instruction. |
59 | | - * \50..\53 rel8 a byte relative operand, from operand 0..3 |
60 | | - * \54..\57 iq a qword immediate operand, from operand 0..3 |
61 | | - * \60..\63 rel16 a word relative operand, from operand 0..3 |
62 | | - * \64..\67 rel select between \6[0-3] and \7[0-3] depending on 16/32 bit |
63 | | - * assembly mode or the operand-size override on the operand |
64 | | - * \70..\73 rel32 a long relative operand, from operand 0..3 |
65 | | - * \74..\77 seg a word constant, from the _segment_ part of operand 0..3 |
66 | | - * \1ab /r a ModRM, calculated on EA in operand a, with the reg |
67 | | - * field the register value of operand b. |
68 | | - * \171\mab /mrb (e.g /3r0) a ModRM, with the reg field taken from operand a, and the m |
69 | | - * and b fields set to the specified values. |
70 | | - * \172\ab /is4 the register number from operand a in bits 7..4, with |
71 | | - * the 4-bit immediate from operand b in bits 3..0. |
72 | | - * \173\xab the register number from operand a in bits 7..4, with |
73 | | - * the value b in bits 3..0. |
74 | | - * \174..\177 the register number from operand 0..3 in bits 7..4, and |
75 | | - * an arbitrary value in bits 3..0 (assembled as zero.) |
76 | | - * \2ab /b a ModRM, calculated on EA in operand a, with the reg |
77 | | - * field equal to digit b. |
78 | | - * \240..\243 this instruction uses EVEX rather than REX or VEX/XOP, with the |
79 | | - * V field taken from operand 0..3. |
80 | | - * \250 this instruction uses EVEX rather than REX or VEX/XOP, with the |
81 | | - * V field set to 1111b. |
82 | | - * |
83 | | - * EVEX prefixes are followed by the sequence: |
84 | | - * \cm\wlp\tup where cm is: |
85 | | - * cc 00m mmm |
86 | | - * c = 2 for EVEX and mmmm is the M field (EVEX.P0[3:0]) |
87 | | - * and wlp is: |
88 | | - * 00 wwl lpp |
89 | | - * [l0] ll = 0 (.128, .lz) |
90 | | - * [l1] ll = 1 (.256) |
91 | | - * [l2] ll = 2 (.512) |
92 | | - * [lig] ll = 3 for EVEX.L'L don't care (always assembled as 0) |
93 | | - * |
94 | | - * [w0] ww = 0 for W = 0 |
95 | | - * [w1] ww = 1 for W = 1 |
96 | | - * [wig] ww = 2 for W don't care (always assembled as 0) |
97 | | - * [ww] ww = 3 for W used as REX.W |
98 | | - * |
99 | | - * [p0] pp = 0 for no prefix |
100 | | - * [60] pp = 1 for legacy prefix 60 |
101 | | - * [f3] pp = 2 |
102 | | - * [f2] pp = 3 |
103 | | - * |
104 | | - * tup is tuple type for Disp8*N from %tuple_codes in insns.pl |
105 | | - * (compressed displacement encoding) |
106 | | - * |
107 | | - * \254..\257 id,s a signed 32-bit operand to be extended to 64 bits. |
108 | | - * \260..\263 this instruction uses VEX/XOP rather than REX, with the |
109 | | - * V field taken from operand 0..3. |
110 | | - * \270 this instruction uses VEX/XOP rather than REX, with the |
111 | | - * V field set to 1111b. |
112 | | - * VEX/XOP prefixes are followed by the sequence: |
113 | | - * \tmm\wlp where mm is the M field; and wlp is: |
114 | | - * 00 wwl lpp |
115 | | - * [l0] ll = 0 for L = 0 (.128, .lz) |
116 | | - * [l1] ll = 1 for L = 1 (.256) |
117 | | - * [lig] ll = 2 for L don't care (always assembled as 0) |
118 | | - * |
119 | | - * [w0] ww = 0 for W = 0 |
120 | | - * [w1 ] ww = 1 for W = 1 |
121 | | - * [wig] ww = 2 for W don't care (always assembled as 0) |
122 | | - * [ww] ww = 3 for W used as REX.W |
123 | | - * |
124 | | - * t = 0 for VEX (C4/C5), t = 1 for XOP (8F). |
125 | | - * |
126 | | - * \271 hlexr instruction takes XRELEASE (F3) with or without lock |
127 | | - * \272 hlenl instruction takes XACQUIRE/XRELEASE with or without lock |
128 | | - * \273 hle instruction takes XACQUIRE/XRELEASE with lock only |
129 | | - * \274..\277 ib,s a byte immediate operand, from operand 0..3, sign-extended |
130 | | - * to the operand size (if o16/o32/o64 present) or the bit size |
131 | | - * \310 a16 indicates fixed 16-bit address size, i.e. optional 0x67. |
132 | | - * \311 a32 indicates fixed 32-bit address size, i.e. optional 0x67. |
133 | | - * \312 adf (disassembler only) invalid with non-default address size. |
134 | | - * \313 a64 indicates fixed 64-bit address size, 0x67 invalid. |
135 | | - * \314 norexb (disassembler only) invalid with REX.B |
136 | | - * \315 norexx (disassembler only) invalid with REX.X |
137 | | - * \316 norexr (disassembler only) invalid with REX.R |
138 | | - * \317 norexw (disassembler only) invalid with REX.W |
139 | | - * \320 o16 indicates fixed 16-bit operand size, i.e. optional 0x66. |
140 | | - * \321 o32 indicates fixed 32-bit operand size, i.e. optional 0x66. |
141 | | - * \322 odf indicates that this instruction is only valid when the |
142 | | - * operand size is the default (instruction to disassembler, |
143 | | - * generates no code in the assembler) |
144 | | - * \323 o64nw indicates fixed 64-bit operand size, REX on extensions only. |
145 | | - * \324 o64 indicates 64-bit operand size requiring REX prefix. |
146 | | - * \325 nohi instruction which always uses spl/bpl/sil/dil |
147 | | - * \326 nof3 instruction not valid with 0xF3 REP prefix. Hint for |
148 | | - disassembler only; for SSE instructions. |
149 | | - * \331 norep instruction not valid with REP prefix. Hint for |
150 | | - * disassembler only; for SSE instructions. |
151 | | - * \332 f2i REP prefix (0xF2 byte) used as opcode extension. |
152 | | - * \333 f3i REP prefix (0xF3 byte) used as opcode extension. |
153 | | - * \334 rex.l LOCK prefix used as REX.R (used in non-64-bit mode) |
154 | | - * \335 repe disassemble a rep (0xF3 byte) prefix as repe not rep. |
155 | | - * \336 mustrep force a REP(E) prefix (0xF3) even if not specified. |
156 | | - * \337 mustrepne force a REPNE prefix (0xF2) even if not specified. |
157 | | - * \336-\337 are still listed as prefixes in the disassembler. |
158 | | - * \340 resb reserve <operand 0> bytes of uninitialized storage. |
159 | | - * Operand 0 had better be a segmentless constant. |
160 | | - * \341 wait this instruction needs a WAIT "prefix" |
161 | | - * \360 np no SSE prefix (== \364\331) |
162 | | - * \361 66 SSE prefix (== \366\331) |
163 | | - * \364 !osp operand-size prefix (0x66) not permitted |
164 | | - * \365 !asp address-size prefix (0x67) not permitted |
165 | | - * \366 operand-size prefix (0x66) used as opcode extension |
166 | | - * \367 address-size prefix (0x67) used as opcode extension |
167 | | - * \370,\371 jcc8 match only if operand 0 meets byte jump criteria. |
168 | | - * jmp8 370 is used for Jcc, 371 is used for JMP. |
169 | | - * \373 jlen assemble 0x03 if bits==16, 0x05 if bits==32; |
170 | | - * used for conditional jump over longer jump |
171 | | - * \374 vsibx|vm32x|vm64x this instruction takes an XMM VSIB memory EA |
172 | | - * \375 vsiby|vm32y|vm64y this instruction takes an YMM VSIB memory EA |
173 | | - * \376 vsibz|vm32z|vm64z this instruction takes an ZMM VSIB memory EA |
174 | 37 | */ |
175 | 38 |
|
176 | 39 | #include "compiler.h" |
|
0 commit comments