Rev 4039 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
31 | halyavin | 1 | |
2 | ; Copyright (c) 1999-2016, Tomasz Grysztar. |
||
6467 | dunkaist | 3 | ; All rights reserved. |
31 | halyavin | 4 | |
5 | |||
6 | cmp [code_type],64 |
||
157 | heavyiron | 7 | je illegal_instruction |
8 | simple_instruction: |
||
31 | halyavin | 9 | stos byte [edi] |
157 | heavyiron | 10 | jmp instruction_assembled |
11 | simple_instruction_only64: |
||
31 | halyavin | 12 | cmp [code_type],64 |
157 | heavyiron | 13 | jne illegal_instruction |
14 | jmp simple_instruction |
||
15 | simple_instruction_16bit_except64: |
||
31 | halyavin | 16 | cmp [code_type],64 |
157 | heavyiron | 17 | je illegal_instruction |
18 | simple_instruction_16bit: |
||
31 | halyavin | 19 | cmp [code_type],16 |
157 | heavyiron | 20 | jne size_prefix |
21 | stos byte [edi] |
||
22 | jmp instruction_assembled |
||
23 | size_prefix: |
||
31 | halyavin | 24 | mov ah,al |
157 | heavyiron | 25 | mov al,66h |
26 | stos word [edi] |
||
27 | jmp instruction_assembled |
||
28 | simple_instruction_32bit_except64: |
||
31 | halyavin | 29 | cmp [code_type],64 |
157 | heavyiron | 30 | je illegal_instruction |
31 | simple_instruction_32bit: |
||
31 | halyavin | 32 | cmp [code_type],16 |
157 | heavyiron | 33 | je size_prefix |
34 | stos byte [edi] |
||
35 | jmp instruction_assembled |
||
36 | iret_instruction: |
||
2287 | heavyiron | 37 | cmp [code_type],64 |
38 | jne simple_instruction |
||
39 | simple_instruction_64bit: |
||
31 | halyavin | 40 | cmp [code_type],64 |
157 | heavyiron | 41 | jne illegal_instruction |
42 | mov ah,al |
||
43 | mov al,48h |
||
44 | stos word [edi] |
||
45 | jmp instruction_assembled |
||
46 | simple_extended_instruction_64bit: |
||
47 | cmp [code_type],64 |
||
48 | jne illegal_instruction |
||
49 | mov byte [edi],48h |
||
1189 | heavyiron | 50 | inc edi |
51 | simple_extended_instruction: |
||
31 | halyavin | 52 | mov ah,al |
157 | heavyiron | 53 | mov al,0Fh |
54 | stos word [edi] |
||
55 | jmp instruction_assembled |
||
56 | prefix_instruction: |
||
31 | halyavin | 57 | stos byte [edi] |
157 | heavyiron | 58 | or [prefix_flags],1 |
6467 | dunkaist | 59 | jmp continue_line |
157 | heavyiron | 60 | segment_prefix: |
31 | halyavin | 61 | mov ah,al |
157 | heavyiron | 62 | shr ah,4 |
63 | cmp ah,3 |
||
6467 | dunkaist | 64 | jne illegal_instruction |
157 | heavyiron | 65 | and al,1111b |
66 | mov [segment_register],al |
||
67 | call store_segment_prefix |
||
68 | or [prefix_flags],1 |
||
6467 | dunkaist | 69 | jmp continue_line |
157 | heavyiron | 70 | bnd_prefix_instruction: |
6467 | dunkaist | 71 | stos byte [edi] |
72 | or [prefix_flags],1 + 10h |
||
73 | jmp continue_line |
||
74 | int_instruction: |
||
31 | halyavin | 75 | lods byte [esi] |
157 | heavyiron | 76 | call get_size_operator |
77 | cmp ah,1 |
||
78 | ja invalid_operand_size |
||
79 | cmp al,'(' |
||
80 | jne invalid_operand |
||
81 | call get_byte_value |
||
82 | test eax,eax |
||
2287 | heavyiron | 83 | jns int_imm_ok |
2665 | dunkaist | 84 | call recoverable_overflow |
85 | int_imm_ok: |
||
2287 | heavyiron | 86 | mov ah,al |
157 | heavyiron | 87 | mov al,0CDh |
88 | stos word [edi] |
||
89 | jmp instruction_assembled |
||
90 | aa_instruction: |
||
31 | halyavin | 91 | cmp [code_type],64 |
157 | heavyiron | 92 | je illegal_instruction |
93 | push eax |
||
94 | mov bl,10 |
||
95 | cmp byte [esi],'(' |
||
96 | jne aa_store |
||
97 | inc esi |
||
98 | xor al,al |
||
99 | xchg al,[operand_size] |
||
100 | cmp al,1 |
||
101 | ja invalid_operand_size |
||
102 | call get_byte_value |
||
103 | mov bl,al |
||
104 | aa_store: |
||
31 | halyavin | 105 | cmp [operand_size],0 |
157 | heavyiron | 106 | jne invalid_operand |
107 | pop eax |
||
108 | mov ah,bl |
||
109 | stos word [edi] |
||
110 | jmp instruction_assembled |
||
111 | |||
31 | halyavin | 112 | |
113 | mov [base_code],al |
||
157 | heavyiron | 114 | lods byte [esi] |
115 | call get_size_operator |
||
116 | cmp al,10h |
||
117 | je basic_reg |
||
118 | cmp al,'[' |
||
119 | jne invalid_operand |
||
120 | basic_mem: |
||
31 | halyavin | 121 | call get_address |
157 | heavyiron | 122 | push edx ebx ecx |
174 | heavyiron | 123 | lods byte [esi] |
157 | heavyiron | 124 | cmp al,',' |
125 | jne invalid_operand |
||
126 | lods byte [esi] |
||
127 | call get_size_operator |
||
128 | cmp al,'(' |
||
129 | je basic_mem_imm |
||
130 | cmp al,10h |
||
131 | jne invalid_operand |
||
132 | basic_mem_reg: |
||
31 | halyavin | 133 | lods byte [esi] |
157 | heavyiron | 134 | call convert_register |
135 | mov [postbyte_register],al |
||
136 | pop ecx ebx edx |
||
174 | heavyiron | 137 | mov al,ah |
157 | heavyiron | 138 | cmp al,1 |
139 | je instruction_ready |
||
1053 | heavyiron | 140 | call operand_autodetect |
157 | heavyiron | 141 | inc [base_code] |
142 | instruction_ready: |
||
1053 | heavyiron | 143 | call store_instruction |
157 | heavyiron | 144 | jmp instruction_assembled |
145 | basic_mem_imm: |
||
31 | halyavin | 146 | mov al,[operand_size] |
157 | heavyiron | 147 | cmp al,1 |
148 | jb basic_mem_imm_nosize |
||
1053 | heavyiron | 149 | je basic_mem_imm_8bit |
157 | heavyiron | 150 | cmp al,2 |
151 | je basic_mem_imm_16bit |
||
152 | cmp al,4 |
||
153 | je basic_mem_imm_32bit |
||
154 | cmp al,8 |
||
155 | jne invalid_operand_size |
||
1053 | heavyiron | 156 | basic_mem_imm_64bit: |
157 | cmp [size_declared],0 |
||
158 | jne long_immediate_not_encodable |
||
159 | call operand_64bit |
||
160 | call get_simm32 |
||
161 | cmp [value_type],4 |
||
162 | jae long_immediate_not_encodable |
||
163 | jmp basic_mem_imm_32bit_ok |
||
164 | basic_mem_imm_nosize: |
||
165 | call recoverable_unknown_size |
||
2665 | dunkaist | 166 | basic_mem_imm_8bit: |
31 | halyavin | 167 | call get_byte_value |
157 | heavyiron | 168 | mov byte [value],al |
169 | mov al,[base_code] |
||
170 | shr al,3 |
||
171 | mov [postbyte_register],al |
||
172 | pop ecx ebx edx |
||
174 | heavyiron | 173 | mov [base_code],80h |
157 | heavyiron | 174 | call store_instruction_with_imm8 |
175 | jmp instruction_assembled |
||
176 | basic_mem_imm_16bit: |
||
31 | halyavin | 177 | call operand_16bit |
157 | heavyiron | 178 | call get_word_value |
179 | mov word [value],ax |
||
180 | mov al,[base_code] |
||
181 | shr al,3 |
||
182 | mov [postbyte_register],al |
||
183 | pop ecx ebx edx |
||
174 | heavyiron | 184 | cmp [value_type],0 |
157 | heavyiron | 185 | jne basic_mem_imm_16bit_store |
186 | cmp [size_declared],0 |
||
187 | jne basic_mem_imm_16bit_store |
||
188 | cmp word [value],80h |
||
189 | jb basic_mem_simm_8bit |
||
190 | cmp word [value],-80h |
||
191 | jae basic_mem_simm_8bit |
||
192 | basic_mem_imm_16bit_store: |
||
31 | halyavin | 193 | mov [base_code],81h |
157 | heavyiron | 194 | call store_instruction_with_imm16 |
195 | jmp instruction_assembled |
||
196 | basic_mem_simm_8bit: |
||
31 | halyavin | 197 | mov [base_code],83h |
157 | heavyiron | 198 | call store_instruction_with_imm8 |
199 | jmp instruction_assembled |
||
200 | basic_mem_imm_32bit: |
||
31 | halyavin | 201 | call operand_32bit |
157 | heavyiron | 202 | call get_dword_value |
203 | basic_mem_imm_32bit_ok: |
||
31 | halyavin | 204 | mov dword [value],eax |
157 | heavyiron | 205 | mov al,[base_code] |
206 | shr al,3 |
||
207 | mov [postbyte_register],al |
||
208 | pop ecx ebx edx |
||
174 | heavyiron | 209 | cmp [value_type],0 |
157 | heavyiron | 210 | jne basic_mem_imm_32bit_store |
211 | cmp [size_declared],0 |
||
212 | jne basic_mem_imm_32bit_store |
||
213 | cmp dword [value],80h |
||
214 | jb basic_mem_simm_8bit |
||
215 | cmp dword [value],-80h |
||
216 | jae basic_mem_simm_8bit |
||
217 | basic_mem_imm_32bit_store: |
||
31 | halyavin | 218 | mov [base_code],81h |
157 | heavyiron | 219 | call store_instruction_with_imm32 |
220 | jmp instruction_assembled |
||
221 | get_simm32: |
||
31 | halyavin | 222 | call get_qword_value |
157 | heavyiron | 223 | mov ecx,edx |
224 | cdq |
||
225 | cmp ecx,edx |
||
226 | jne value_out_of_range |
||
227 | cmp [value_type],4 |
||
205 | heavyiron | 228 | jne get_simm32_ok |
229 | mov [value_type],2 |
||
230 | get_simm32_ok: |
||
231 | ret |
||
157 | heavyiron | 232 | basic_reg: |
31 | halyavin | 233 | lods byte [esi] |
157 | heavyiron | 234 | call convert_register |
235 | mov [postbyte_register],al |
||
236 | lods byte [esi] |
||
237 | cmp al,',' |
||
238 | jne invalid_operand |
||
239 | lods byte [esi] |
||
240 | call get_size_operator |
||
241 | cmp al,10h |
||
242 | je basic_reg_reg |
||
243 | cmp al,'(' |
||
244 | je basic_reg_imm |
||
245 | cmp al,'[' |
||
246 | jne invalid_operand |
||
247 | basic_reg_mem: |
||
31 | halyavin | 248 | call get_address |
157 | heavyiron | 249 | mov al,[operand_size] |
250 | cmp al,1 |
||
251 | je basic_reg_mem_8bit |
||
252 | call operand_autodetect |
||
253 | add [base_code],3 |
||
254 | jmp instruction_ready |
||
1053 | heavyiron | 255 | basic_reg_mem_8bit: |
31 | halyavin | 256 | add [base_code],2 |
157 | heavyiron | 257 | jmp instruction_ready |
1053 | heavyiron | 258 | basic_reg_reg: |
31 | halyavin | 259 | lods byte [esi] |
157 | heavyiron | 260 | call convert_register |
261 | mov bl,[postbyte_register] |
||
262 | mov [postbyte_register],al |
||
263 | mov al,ah |
||
264 | cmp al,1 |
||
265 | je nomem_instruction_ready |
||
1053 | heavyiron | 266 | call operand_autodetect |
157 | heavyiron | 267 | inc [base_code] |
268 | nomem_instruction_ready: |
||
1053 | heavyiron | 269 | call store_nomem_instruction |
157 | heavyiron | 270 | jmp instruction_assembled |
271 | basic_reg_imm: |
||
31 | halyavin | 272 | mov al,[operand_size] |
157 | heavyiron | 273 | cmp al,1 |
274 | je basic_reg_imm_8bit |
||
275 | cmp al,2 |
||
276 | je basic_reg_imm_16bit |
||
277 | cmp al,4 |
||
278 | je basic_reg_imm_32bit |
||
279 | cmp al,8 |
||
280 | jne invalid_operand_size |
||
1053 | heavyiron | 281 | basic_reg_imm_64bit: |
282 | cmp [size_declared],0 |
||
283 | jne long_immediate_not_encodable |
||
284 | call operand_64bit |
||
285 | call get_simm32 |
||
286 | cmp [value_type],4 |
||
287 | jae long_immediate_not_encodable |
||
288 | jmp basic_reg_imm_32bit_ok |
||
289 | basic_reg_imm_8bit: |
||
31 | halyavin | 290 | call get_byte_value |
157 | heavyiron | 291 | mov dl,al |
292 | mov bl,[base_code] |
||
293 | shr bl,3 |
||
294 | xchg bl,[postbyte_register] |
||
295 | or bl,bl |
||
296 | jz basic_al_imm |
||
297 | mov [base_code],80h |
||
298 | call store_nomem_instruction |
||
299 | mov al,dl |
||
300 | stos byte [edi] |
||
301 | jmp instruction_assembled |
||
302 | basic_al_imm: |
||
31 | halyavin | 303 | mov al,[base_code] |
157 | heavyiron | 304 | add al,4 |
305 | stos byte [edi] |
||
306 | mov al,dl |
||
307 | stos byte [edi] |
||
308 | jmp instruction_assembled |
||
309 | basic_reg_imm_16bit: |
||
31 | halyavin | 310 | call operand_16bit |
157 | heavyiron | 311 | call get_word_value |
312 | mov dx,ax |
||
313 | mov bl,[base_code] |
||
314 | shr bl,3 |
||
315 | xchg bl,[postbyte_register] |
||
316 | cmp [value_type],0 |
||
317 | jne basic_reg_imm_16bit_store |
||
318 | cmp [size_declared],0 |
||
319 | jne basic_reg_imm_16bit_store |
||
320 | cmp dx,80h |
||
321 | jb basic_reg_simm_8bit |
||
322 | cmp dx,-80h |
||
323 | jae basic_reg_simm_8bit |
||
324 | basic_reg_imm_16bit_store: |
||
31 | halyavin | 325 | or bl,bl |
157 | heavyiron | 326 | jz basic_ax_imm |
327 | mov [base_code],81h |
||
328 | call store_nomem_instruction |
||
329 | basic_store_imm_16bit: |
||
1053 | heavyiron | 330 | mov ax,dx |
157 | heavyiron | 331 | call mark_relocation |
332 | stos word [edi] |
||
333 | jmp instruction_assembled |
||
334 | basic_reg_simm_8bit: |
||
31 | halyavin | 335 | mov [base_code],83h |
157 | heavyiron | 336 | call store_nomem_instruction |
337 | mov al,dl |
||
338 | stos byte [edi] |
||
339 | jmp instruction_assembled |
||
340 | basic_ax_imm: |
||
31 | halyavin | 341 | add [base_code],5 |
157 | heavyiron | 342 | call store_classic_instruction_code |
6467 | dunkaist | 343 | jmp basic_store_imm_16bit |
1053 | heavyiron | 344 | basic_reg_imm_32bit: |
31 | halyavin | 345 | call operand_32bit |
157 | heavyiron | 346 | call get_dword_value |
347 | basic_reg_imm_32bit_ok: |
||
31 | halyavin | 348 | mov edx,eax |
157 | heavyiron | 349 | mov bl,[base_code] |
350 | shr bl,3 |
||
351 | xchg bl,[postbyte_register] |
||
352 | cmp [value_type],0 |
||
353 | jne basic_reg_imm_32bit_store |
||
354 | cmp [size_declared],0 |
||
355 | jne basic_reg_imm_32bit_store |
||
356 | cmp edx,80h |
||
357 | jb basic_reg_simm_8bit |
||
358 | cmp edx,-80h |
||
359 | jae basic_reg_simm_8bit |
||
360 | basic_reg_imm_32bit_store: |
||
31 | halyavin | 361 | or bl,bl |
157 | heavyiron | 362 | jz basic_eax_imm |
363 | mov [base_code],81h |
||
364 | call store_nomem_instruction |
||
365 | basic_store_imm_32bit: |
||
1053 | heavyiron | 366 | mov eax,edx |
157 | heavyiron | 367 | call mark_relocation |
368 | stos dword [edi] |
||
369 | jmp instruction_assembled |
||
370 | basic_eax_imm: |
||
31 | halyavin | 371 | add [base_code],5 |
157 | heavyiron | 372 | call store_classic_instruction_code |
6467 | dunkaist | 373 | jmp basic_store_imm_32bit |
1053 | heavyiron | 374 | recoverable_unknown_size: |
2665 | dunkaist | 375 | cmp [error_line],0 |
376 | jne ignore_unknown_size |
||
377 | push [current_line] |
||
378 | pop [error_line] |
||
379 | mov [error],operand_size_not_specified |
||
380 | ignore_unknown_size: |
||
381 | ret |
||
382 | single_operand_instruction: |
||
31 | halyavin | 383 | mov [base_code],0F6h |
157 | heavyiron | 384 | mov [postbyte_register],al |
385 | lods byte [esi] |
||
386 | call get_size_operator |
||
387 | cmp al,10h |
||
388 | je single_reg |
||
389 | cmp al,'[' |
||
390 | jne invalid_operand |
||
391 | single_mem: |
||
31 | halyavin | 392 | call get_address |
157 | heavyiron | 393 | mov al,[operand_size] |
394 | cmp al,1 |
||
395 | je single_mem_8bit |
||
396 | jb single_mem_nosize |
||
397 | call operand_autodetect |
||
398 | inc [base_code] |
||
399 | jmp instruction_ready |
||
1053 | heavyiron | 400 | single_mem_nosize: |
31 | halyavin | 401 | call recoverable_unknown_size |
2665 | dunkaist | 402 | single_mem_8bit: |
31 | halyavin | 403 | jmp instruction_ready |
1053 | heavyiron | 404 | single_reg: |
31 | halyavin | 405 | lods byte [esi] |
157 | heavyiron | 406 | call convert_register |
407 | mov bl,al |
||
408 | mov al,ah |
||
409 | cmp al,1 |
||
410 | je single_reg_8bit |
||
411 | call operand_autodetect |
||
412 | inc [base_code] |
||
413 | single_reg_8bit: |
||
31 | halyavin | 414 | jmp nomem_instruction_ready |
1053 | heavyiron | 415 | mov_instruction: |
31 | halyavin | 416 | mov [base_code],88h |
157 | heavyiron | 417 | lods byte [esi] |
418 | call get_size_operator |
||
419 | cmp al,10h |
||
420 | je mov_reg |
||
421 | cmp al,14h |
||
6467 | dunkaist | 422 | je mov_creg |
423 | cmp al,'[' |
||
157 | heavyiron | 424 | jne invalid_operand |
425 | mov_mem: |
||
31 | halyavin | 426 | call get_address |
157 | heavyiron | 427 | push edx ebx ecx |
174 | heavyiron | 428 | lods byte [esi] |
157 | heavyiron | 429 | cmp al,',' |
430 | jne invalid_operand |
||
431 | lods byte [esi] |
||
432 | call get_size_operator |
||
433 | cmp al,'(' |
||
434 | je mov_mem_imm |
||
435 | cmp al,10h |
||
436 | jne invalid_operand |
||
437 | mov_mem_reg: |
||
31 | halyavin | 438 | lods byte [esi] |
157 | heavyiron | 439 | cmp al,30h |
6467 | dunkaist | 440 | jb mov_mem_general_reg |
157 | heavyiron | 441 | cmp al,40h |
6467 | dunkaist | 442 | jb mov_mem_sreg |
157 | heavyiron | 443 | mov_mem_general_reg: |
31 | halyavin | 444 | call convert_register |
157 | heavyiron | 445 | mov [postbyte_register],al |
446 | pop ecx ebx edx |
||
174 | heavyiron | 447 | cmp ah,1 |
157 | heavyiron | 448 | je mov_mem_reg_8bit |
449 | mov al,ah |
||
450 | call operand_autodetect |
||
451 | mov al,[postbyte_register] |
||
452 | or al,bl |
||
453 | or al,bh |
||
454 | jz mov_mem_ax |
||
455 | inc [base_code] |
||
456 | jmp instruction_ready |
||
1053 | heavyiron | 457 | mov_mem_reg_8bit: |
31 | halyavin | 458 | or al,bl |
157 | heavyiron | 459 | or al,bh |
460 | jnz instruction_ready |
||
1053 | heavyiron | 461 | mov_mem_al: |
31 | halyavin | 462 | test ch,22h |
157 | heavyiron | 463 | jnz mov_mem_address16_al |
464 | test ch,44h |
||
465 | jnz mov_mem_address32_al |
||
466 | test ch,88h |
||
467 | jnz mov_mem_address64_al |
||
468 | or ch,ch |
||
469 | jnz invalid_address_size |
||
470 | cmp [code_type],64 |
||
471 | je mov_mem_address64_al |
||
472 | cmp [code_type],32 |
||
473 | je mov_mem_address32_al |
||
474 | cmp edx,10000h |
||
475 | jb mov_mem_address16_al |
||
476 | mov_mem_address32_al: |
||
31 | halyavin | 477 | call store_segment_prefix_if_necessary |
157 | heavyiron | 478 | call address_32bit_prefix |
479 | mov [base_code],0A2h |
||
480 | store_mov_address32: |
||
31 | halyavin | 481 | call store_classic_instruction_code |
6467 | dunkaist | 482 | call store_address_32bit_value |
1189 | heavyiron | 483 | jmp instruction_assembled |
484 | mov_mem_address16_al: |
||
31 | halyavin | 485 | call store_segment_prefix_if_necessary |
157 | heavyiron | 486 | call address_16bit_prefix |
487 | mov [base_code],0A2h |
||
488 | store_mov_address16: |
||
31 | halyavin | 489 | cmp [code_type],64 |
157 | heavyiron | 490 | je invalid_address |
491 | call store_classic_instruction_code |
||
6467 | dunkaist | 492 | mov eax,edx |
157 | heavyiron | 493 | stos word [edi] |
494 | cmp edx,10000h |
||
495 | jge value_out_of_range |
||
496 | jmp instruction_assembled |
||
497 | mov_mem_address64_al: |
||
31 | halyavin | 498 | call store_segment_prefix_if_necessary |
157 | heavyiron | 499 | mov [base_code],0A2h |
500 | store_mov_address64: |
||
31 | halyavin | 501 | call store_classic_instruction_code |
6467 | dunkaist | 502 | call store_address_64bit_value |
1189 | heavyiron | 503 | jmp instruction_assembled |
504 | mov_mem_ax: |
||
31 | halyavin | 505 | test ch,22h |
157 | heavyiron | 506 | jnz mov_mem_address16_ax |
507 | test ch,44h |
||
508 | jnz mov_mem_address32_ax |
||
509 | test ch,88h |
||
510 | jnz mov_mem_address64_ax |
||
511 | or ch,ch |
||
512 | jnz invalid_address_size |
||
513 | cmp [code_type],64 |
||
514 | je mov_mem_address64_ax |
||
515 | cmp [code_type],32 |
||
516 | je mov_mem_address32_ax |
||
517 | cmp edx,10000h |
||
518 | jb mov_mem_address16_ax |
||
519 | mov_mem_address32_ax: |
||
31 | halyavin | 520 | call store_segment_prefix_if_necessary |
157 | heavyiron | 521 | call address_32bit_prefix |
522 | mov [base_code],0A3h |
||
523 | jmp store_mov_address32 |
||
524 | mov_mem_address16_ax: |
||
31 | halyavin | 525 | call store_segment_prefix_if_necessary |
157 | heavyiron | 526 | call address_16bit_prefix |
527 | mov [base_code],0A3h |
||
528 | jmp store_mov_address16 |
||
529 | mov_mem_address64_ax: |
||
31 | halyavin | 530 | call store_segment_prefix_if_necessary |
157 | heavyiron | 531 | mov [base_code],0A3h |
532 | jmp store_mov_address64 |
||
533 | mov_mem_sreg: |
||
31 | halyavin | 534 | sub al,31h |
6467 | dunkaist | 535 | mov [postbyte_register],al |
157 | heavyiron | 536 | pop ecx ebx edx |
174 | heavyiron | 537 | mov ah,[operand_size] |
157 | heavyiron | 538 | or ah,ah |
539 | jz mov_mem_sreg_store |
||
540 | cmp ah,2 |
||
541 | jne invalid_operand_size |
||
542 | mov_mem_sreg_store: |
||
31 | halyavin | 543 | mov [base_code],8Ch |
157 | heavyiron | 544 | jmp instruction_ready |
1053 | heavyiron | 545 | mov_mem_imm: |
31 | halyavin | 546 | mov al,[operand_size] |
157 | heavyiron | 547 | cmp al,1 |
548 | jb mov_mem_imm_nosize |
||
1053 | heavyiron | 549 | je mov_mem_imm_8bit |
157 | heavyiron | 550 | cmp al,2 |
551 | je mov_mem_imm_16bit |
||
552 | cmp al,4 |
||
553 | je mov_mem_imm_32bit |
||
554 | cmp al,8 |
||
555 | jne invalid_operand_size |
||
1053 | heavyiron | 556 | mov_mem_imm_64bit: |
557 | cmp [size_declared],0 |
||
558 | jne long_immediate_not_encodable |
||
559 | call operand_64bit |
||
560 | call get_simm32 |
||
561 | cmp [value_type],4 |
||
562 | jae long_immediate_not_encodable |
||
563 | jmp mov_mem_imm_32bit_store |
||
564 | mov_mem_imm_nosize: |
||
6467 | dunkaist | 565 | call recoverable_unknown_size |
566 | mov_mem_imm_8bit: |
||
31 | halyavin | 567 | call get_byte_value |
157 | heavyiron | 568 | mov byte [value],al |
569 | mov [postbyte_register],0 |
||
570 | mov [base_code],0C6h |
||
571 | pop ecx ebx edx |
||
174 | heavyiron | 572 | call store_instruction_with_imm8 |
157 | heavyiron | 573 | jmp instruction_assembled |
574 | mov_mem_imm_16bit: |
||
31 | halyavin | 575 | call operand_16bit |
157 | heavyiron | 576 | call get_word_value |
577 | mov word [value],ax |
||
578 | mov [postbyte_register],0 |
||
579 | mov [base_code],0C7h |
||
580 | pop ecx ebx edx |
||
174 | heavyiron | 581 | call store_instruction_with_imm16 |
157 | heavyiron | 582 | jmp instruction_assembled |
583 | mov_mem_imm_32bit: |
||
31 | halyavin | 584 | call operand_32bit |
157 | heavyiron | 585 | call get_dword_value |
586 | mov_mem_imm_32bit_store: |
||
31 | halyavin | 587 | mov dword [value],eax |
157 | heavyiron | 588 | mov [postbyte_register],0 |
589 | mov [base_code],0C7h |
||
590 | pop ecx ebx edx |
||
174 | heavyiron | 591 | call store_instruction_with_imm32 |
157 | heavyiron | 592 | jmp instruction_assembled |
593 | mov_reg: |
||
31 | halyavin | 594 | lods byte [esi] |
157 | heavyiron | 595 | mov ah,al |
596 | sub ah,10h |
||
597 | and ah,al |
||
598 | test ah,0F0h |
||
599 | jnz mov_sreg |
||
600 | call convert_register |
||
601 | mov [postbyte_register],al |
||
602 | lods byte [esi] |
||
603 | cmp al,',' |
||
604 | jne invalid_operand |
||
605 | lods byte [esi] |
||
606 | call get_size_operator |
||
607 | cmp al,'[' |
||
608 | je mov_reg_mem |
||
609 | cmp al,'(' |
||
610 | je mov_reg_imm |
||
611 | cmp al,14h |
||
6467 | dunkaist | 612 | je mov_reg_creg |
613 | cmp al,10h |
||
157 | heavyiron | 614 | jne invalid_operand |
615 | mov_reg_reg: |
||
31 | halyavin | 616 | lods byte [esi] |
157 | heavyiron | 617 | mov ah,al |
618 | sub ah,10h |
||
619 | and ah,al |
||
620 | test ah,0F0h |
||
621 | jnz mov_reg_sreg |
||
622 | call convert_register |
||
623 | mov bl,[postbyte_register] |
||
624 | mov [postbyte_register],al |
||
625 | mov al,ah |
||
626 | cmp al,1 |
||
627 | je mov_reg_reg_8bit |
||
628 | call operand_autodetect |
||
629 | inc [base_code] |
||
630 | mov_reg_reg_8bit: |
||
31 | halyavin | 631 | jmp nomem_instruction_ready |
1053 | heavyiron | 632 | mov_reg_sreg: |
31 | halyavin | 633 | mov bl,[postbyte_register] |
157 | heavyiron | 634 | mov ah,al |
635 | and al,1111b |
||
636 | mov [postbyte_register],al |
||
637 | shr ah,4 |
||
638 | cmp ah,3 |
||
6467 | dunkaist | 639 | jne invalid_operand |
640 | dec [postbyte_register] |
||
157 | heavyiron | 641 | cmp [operand_size],8 |
642 | je mov_reg_sreg64 |
||
643 | cmp [operand_size],4 |
||
644 | je mov_reg_sreg32 |
||
645 | cmp [operand_size],2 |
||
646 | jne invalid_operand_size |
||
647 | call operand_16bit |
||
648 | jmp mov_reg_sreg_store |
||
649 | mov_reg_sreg64: |
||
31 | halyavin | 650 | call operand_64bit |
157 | heavyiron | 651 | jmp mov_reg_sreg_store |
652 | mov_reg_sreg32: |
||
31 | halyavin | 653 | call operand_32bit |
157 | heavyiron | 654 | mov_reg_sreg_store: |
31 | halyavin | 655 | mov [base_code],8Ch |
157 | heavyiron | 656 | jmp nomem_instruction_ready |
1053 | heavyiron | 657 | mov_reg_creg: |
31 | halyavin | 658 | lods byte [esi] |
6467 | dunkaist | 659 | mov bl,al |
660 | shr al,4 |
||
661 | cmp al,4 |
||
662 | ja invalid_operand |
||
663 | add al,20h |
||
664 | mov [extended_code],al |
||
665 | and bl,1111b |
||
666 | xchg bl,[postbyte_register] |
||
667 | mov [base_code],0Fh |
||
157 | heavyiron | 668 | cmp [code_type],64 |
669 | je mov_reg_creg_64bit |
||
6467 | dunkaist | 670 | cmp [operand_size],4 |
157 | heavyiron | 671 | jne invalid_operand_size |
672 | cmp [postbyte_register],8 |
||
673 | jb mov_reg_creg_store |
||
6467 | dunkaist | 674 | cmp [extended_code],20h |
157 | heavyiron | 675 | jne mov_reg_creg_store |
6467 | dunkaist | 676 | mov al,0F0h |
157 | heavyiron | 677 | stos byte [edi] |
678 | mov [postbyte_register],0 |
||
679 | mov_reg_creg_store: |
||
6467 | dunkaist | 680 | jmp nomem_instruction_ready |
1053 | heavyiron | 681 | mov_reg_creg_64bit: |
6467 | dunkaist | 682 | cmp [operand_size],8 |
157 | heavyiron | 683 | jne invalid_operand_size |
684 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 685 | mov_reg_mem: |
31 | halyavin | 686 | call get_address |
157 | heavyiron | 687 | mov al,[operand_size] |
688 | cmp al,1 |
||
689 | je mov_reg_mem_8bit |
||
690 | call operand_autodetect |
||
691 | mov al,[postbyte_register] |
||
692 | or al,bl |
||
693 | or al,bh |
||
694 | jz mov_ax_mem |
||
695 | add [base_code],3 |
||
696 | jmp instruction_ready |
||
1053 | heavyiron | 697 | mov_reg_mem_8bit: |
31 | halyavin | 698 | mov al,[postbyte_register] |
157 | heavyiron | 699 | or al,bl |
700 | or al,bh |
||
701 | jz mov_al_mem |
||
702 | add [base_code],2 |
||
703 | jmp instruction_ready |
||
1053 | heavyiron | 704 | mov_al_mem: |
31 | halyavin | 705 | test ch,22h |
157 | heavyiron | 706 | jnz mov_al_mem_address16 |
707 | test ch,44h |
||
708 | jnz mov_al_mem_address32 |
||
709 | test ch,88h |
||
710 | jnz mov_al_mem_address64 |
||
711 | or ch,ch |
||
712 | jnz invalid_address_size |
||
713 | cmp [code_type],64 |
||
714 | je mov_al_mem_address64 |
||
715 | cmp [code_type],32 |
||
716 | je mov_al_mem_address32 |
||
717 | cmp edx,10000h |
||
718 | jb mov_al_mem_address16 |
||
719 | mov_al_mem_address32: |
||
31 | halyavin | 720 | call store_segment_prefix_if_necessary |
157 | heavyiron | 721 | call address_32bit_prefix |
722 | mov [base_code],0A0h |
||
723 | jmp store_mov_address32 |
||
724 | mov_al_mem_address16: |
||
31 | halyavin | 725 | call store_segment_prefix_if_necessary |
157 | heavyiron | 726 | call address_16bit_prefix |
727 | mov [base_code],0A0h |
||
728 | jmp store_mov_address16 |
||
729 | mov_al_mem_address64: |
||
31 | halyavin | 730 | call store_segment_prefix_if_necessary |
157 | heavyiron | 731 | mov [base_code],0A0h |
732 | jmp store_mov_address64 |
||
733 | mov_ax_mem: |
||
31 | halyavin | 734 | test ch,22h |
157 | heavyiron | 735 | jnz mov_ax_mem_address16 |
736 | test ch,44h |
||
737 | jnz mov_ax_mem_address32 |
||
738 | test ch,88h |
||
739 | jnz mov_ax_mem_address64 |
||
740 | or ch,ch |
||
741 | jnz invalid_address_size |
||
742 | cmp [code_type],64 |
||
743 | je mov_ax_mem_address64 |
||
744 | cmp [code_type],32 |
||
745 | je mov_ax_mem_address32 |
||
746 | cmp edx,10000h |
||
747 | jb mov_ax_mem_address16 |
||
748 | mov_ax_mem_address32: |
||
31 | halyavin | 749 | call store_segment_prefix_if_necessary |
157 | heavyiron | 750 | call address_32bit_prefix |
751 | mov [base_code],0A1h |
||
752 | jmp store_mov_address32 |
||
753 | mov_ax_mem_address16: |
||
31 | halyavin | 754 | call store_segment_prefix_if_necessary |
157 | heavyiron | 755 | call address_16bit_prefix |
756 | mov [base_code],0A1h |
||
757 | jmp store_mov_address16 |
||
758 | mov_ax_mem_address64: |
||
31 | halyavin | 759 | call store_segment_prefix_if_necessary |
157 | heavyiron | 760 | mov [base_code],0A1h |
761 | jmp store_mov_address64 |
||
762 | mov_reg_imm: |
||
31 | halyavin | 763 | mov al,[operand_size] |
157 | heavyiron | 764 | cmp al,1 |
765 | je mov_reg_imm_8bit |
||
766 | cmp al,2 |
||
767 | je mov_reg_imm_16bit |
||
768 | cmp al,4 |
||
769 | je mov_reg_imm_32bit |
||
770 | cmp al,8 |
||
771 | jne invalid_operand_size |
||
1053 | heavyiron | 772 | mov_reg_imm_64bit: |
773 | call operand_64bit |
||
774 | call get_qword_value |
||
775 | mov ecx,edx |
||
776 | cmp [size_declared],0 |
||
777 | jne mov_reg_imm_64bit_store |
||
778 | cmp [value_type],4 |
||
779 | jae mov_reg_imm_64bit_store |
||
780 | cdq |
||
781 | cmp ecx,edx |
||
782 | je mov_reg_64bit_imm_32bit |
||
783 | mov_reg_imm_64bit_store: |
||
784 | push eax ecx |
||
785 | mov al,0B8h |
||
786 | call store_mov_reg_imm_code |
||
787 | pop edx eax |
||
788 | call mark_relocation |
||
789 | stos dword [edi] |
||
790 | mov eax,edx |
||
791 | stos dword [edi] |
||
792 | jmp instruction_assembled |
||
793 | mov_reg_imm_8bit: |
||
31 | halyavin | 794 | call get_byte_value |
157 | heavyiron | 795 | mov dl,al |
796 | mov al,0B0h |
||
797 | call store_mov_reg_imm_code |
||
798 | mov al,dl |
||
799 | stos byte [edi] |
||
800 | jmp instruction_assembled |
||
801 | mov_reg_imm_16bit: |
||
31 | halyavin | 802 | call get_word_value |
157 | heavyiron | 803 | mov dx,ax |
804 | call operand_16bit |
||
805 | mov al,0B8h |
||
806 | call store_mov_reg_imm_code |
||
807 | mov ax,dx |
||
808 | call mark_relocation |
||
809 | stos word [edi] |
||
810 | jmp instruction_assembled |
||
811 | mov_reg_imm_32bit: |
||
31 | halyavin | 812 | call operand_32bit |
157 | heavyiron | 813 | call get_dword_value |
814 | mov edx,eax |
||
815 | mov al,0B8h |
||
816 | call store_mov_reg_imm_code |
||
817 | mov_store_imm_32bit: |
||
1053 | heavyiron | 818 | mov eax,edx |
157 | heavyiron | 819 | call mark_relocation |
820 | stos dword [edi] |
||
821 | jmp instruction_assembled |
||
822 | store_mov_reg_imm_code: |
||
31 | halyavin | 823 | mov ah,[postbyte_register] |
157 | heavyiron | 824 | test ah,1000b |
825 | jz mov_reg_imm_prefix_ok |
||
826 | or [rex_prefix],41h |
||
827 | mov_reg_imm_prefix_ok: |
||
31 | halyavin | 828 | and ah,111b |
157 | heavyiron | 829 | add al,ah |
830 | mov [base_code],al |
||
831 | call store_classic_instruction_code |
||
6467 | dunkaist | 832 | ret |
157 | heavyiron | 833 | mov_reg_64bit_imm_32bit: |
31 | halyavin | 834 | mov edx,eax |
157 | heavyiron | 835 | mov bl,[postbyte_register] |
836 | mov [postbyte_register],0 |
||
837 | mov [base_code],0C7h |
||
838 | call store_nomem_instruction |
||
839 | jmp mov_store_imm_32bit |
||
1053 | heavyiron | 840 | mov_sreg: |
31 | halyavin | 841 | mov ah,al |
157 | heavyiron | 842 | and al,1111b |
843 | mov [postbyte_register],al |
||
844 | shr ah,4 |
||
845 | cmp ah,3 |
||
6467 | dunkaist | 846 | jne invalid_operand |
847 | cmp al,2 |
||
157 | heavyiron | 848 | je illegal_instruction |
849 | dec [postbyte_register] |
||
850 | lods byte [esi] |
||
851 | cmp al,',' |
||
852 | jne invalid_operand |
||
853 | lods byte [esi] |
||
854 | call get_size_operator |
||
855 | cmp al,'[' |
||
856 | je mov_sreg_mem |
||
857 | cmp al,10h |
||
858 | jne invalid_operand |
||
859 | mov_sreg_reg: |
||
31 | halyavin | 860 | lods byte [esi] |
157 | heavyiron | 861 | call convert_register |
862 | or ah,ah |
||
863 | jz mov_sreg_reg_size_ok |
||
864 | cmp ah,2 |
||
865 | jne invalid_operand_size |
||
866 | mov bl,al |
||
867 | mov_sreg_reg_size_ok: |
||
31 | halyavin | 868 | mov [base_code],8Eh |
157 | heavyiron | 869 | jmp nomem_instruction_ready |
1053 | heavyiron | 870 | mov_sreg_mem: |
31 | halyavin | 871 | call get_address |
157 | heavyiron | 872 | mov al,[operand_size] |
873 | or al,al |
||
874 | jz mov_sreg_mem_size_ok |
||
875 | cmp al,2 |
||
876 | jne invalid_operand_size |
||
877 | mov_sreg_mem_size_ok: |
||
31 | halyavin | 878 | mov [base_code],8Eh |
157 | heavyiron | 879 | jmp instruction_ready |
1053 | heavyiron | 880 | mov_creg: |
31 | halyavin | 881 | lods byte [esi] |
6467 | dunkaist | 882 | mov ah,al |
883 | shr ah,4 |
||
884 | cmp ah,4 |
||
885 | ja invalid_operand |
||
886 | add ah,22h |
||
887 | mov [extended_code],ah |
||
888 | and al,1111b |
||
889 | mov [postbyte_register],al |
||
890 | mov [base_code],0Fh |
||
157 | heavyiron | 891 | lods byte [esi] |
892 | cmp al,',' |
||
893 | jne invalid_operand |
||
894 | call take_register |
||
6467 | dunkaist | 895 | mov bl,al |
157 | heavyiron | 896 | cmp [code_type],64 |
897 | je mov_creg_64bit |
||
6467 | dunkaist | 898 | cmp ah,4 |
157 | heavyiron | 899 | jne invalid_operand_size |
900 | cmp [postbyte_register],8 |
||
901 | jb mov_creg_store |
||
6467 | dunkaist | 902 | cmp [extended_code],22h |
157 | heavyiron | 903 | jne mov_creg_store |
6467 | dunkaist | 904 | mov al,0F0h |
157 | heavyiron | 905 | stos byte [edi] |
906 | mov [postbyte_register],0 |
||
907 | mov_creg_store: |
||
6467 | dunkaist | 908 | jmp nomem_instruction_ready |
1053 | heavyiron | 909 | mov_creg_64bit: |
6467 | dunkaist | 910 | cmp ah,8 |
157 | heavyiron | 911 | je mov_creg_store |
6467 | dunkaist | 912 | jmp invalid_operand_size |
1053 | heavyiron | 913 | test_instruction: |
31 | halyavin | 914 | mov [base_code],84h |
157 | heavyiron | 915 | lods byte [esi] |
916 | call get_size_operator |
||
917 | cmp al,10h |
||
918 | je test_reg |
||
919 | cmp al,'[' |
||
920 | jne invalid_operand |
||
921 | test_mem: |
||
31 | halyavin | 922 | call get_address |
157 | heavyiron | 923 | push edx ebx ecx |
174 | heavyiron | 924 | lods byte [esi] |
157 | heavyiron | 925 | cmp al,',' |
926 | jne invalid_operand |
||
927 | lods byte [esi] |
||
928 | call get_size_operator |
||
929 | cmp al,'(' |
||
930 | je test_mem_imm |
||
931 | cmp al,10h |
||
932 | jne invalid_operand |
||
933 | test_mem_reg: |
||
31 | halyavin | 934 | lods byte [esi] |
157 | heavyiron | 935 | call convert_register |
936 | mov [postbyte_register],al |
||
937 | pop ecx ebx edx |
||
174 | heavyiron | 938 | mov al,ah |
157 | heavyiron | 939 | cmp al,1 |
940 | je test_mem_reg_8bit |
||
941 | call operand_autodetect |
||
942 | inc [base_code] |
||
943 | test_mem_reg_8bit: |
||
31 | halyavin | 944 | jmp instruction_ready |
1053 | heavyiron | 945 | test_mem_imm: |
31 | halyavin | 946 | mov al,[operand_size] |
157 | heavyiron | 947 | cmp al,1 |
948 | jb test_mem_imm_nosize |
||
1053 | heavyiron | 949 | je test_mem_imm_8bit |
157 | heavyiron | 950 | cmp al,2 |
951 | je test_mem_imm_16bit |
||
952 | cmp al,4 |
||
953 | je test_mem_imm_32bit |
||
954 | cmp al,8 |
||
955 | jne invalid_operand_size |
||
1053 | heavyiron | 956 | test_mem_imm_64bit: |
957 | cmp [size_declared],0 |
||
958 | jne long_immediate_not_encodable |
||
959 | call operand_64bit |
||
960 | call get_simm32 |
||
961 | cmp [value_type],4 |
||
962 | jae long_immediate_not_encodable |
||
963 | jmp test_mem_imm_32bit_store |
||
964 | test_mem_imm_nosize: |
||
6467 | dunkaist | 965 | call recoverable_unknown_size |
966 | test_mem_imm_8bit: |
||
31 | halyavin | 967 | call get_byte_value |
157 | heavyiron | 968 | mov byte [value],al |
969 | mov [postbyte_register],0 |
||
970 | mov [base_code],0F6h |
||
971 | pop ecx ebx edx |
||
174 | heavyiron | 972 | call store_instruction_with_imm8 |
157 | heavyiron | 973 | jmp instruction_assembled |
974 | test_mem_imm_16bit: |
||
31 | halyavin | 975 | call operand_16bit |
157 | heavyiron | 976 | call get_word_value |
977 | mov word [value],ax |
||
978 | mov [postbyte_register],0 |
||
979 | mov [base_code],0F7h |
||
980 | pop ecx ebx edx |
||
174 | heavyiron | 981 | call store_instruction_with_imm16 |
157 | heavyiron | 982 | jmp instruction_assembled |
983 | test_mem_imm_32bit: |
||
31 | halyavin | 984 | call operand_32bit |
157 | heavyiron | 985 | call get_dword_value |
986 | test_mem_imm_32bit_store: |
||
31 | halyavin | 987 | mov dword [value],eax |
157 | heavyiron | 988 | mov [postbyte_register],0 |
989 | mov [base_code],0F7h |
||
990 | pop ecx ebx edx |
||
174 | heavyiron | 991 | call store_instruction_with_imm32 |
157 | heavyiron | 992 | jmp instruction_assembled |
993 | test_reg: |
||
31 | halyavin | 994 | lods byte [esi] |
157 | heavyiron | 995 | call convert_register |
996 | mov [postbyte_register],al |
||
997 | lods byte [esi] |
||
998 | cmp al,',' |
||
999 | jne invalid_operand |
||
1000 | lods byte [esi] |
||
1001 | call get_size_operator |
||
1002 | cmp al,'[' |
||
1003 | je test_reg_mem |
||
1004 | cmp al,'(' |
||
1005 | je test_reg_imm |
||
1006 | cmp al,10h |
||
1007 | jne invalid_operand |
||
1008 | test_reg_reg: |
||
31 | halyavin | 1009 | lods byte [esi] |
157 | heavyiron | 1010 | call convert_register |
1011 | mov bl,[postbyte_register] |
||
1012 | mov [postbyte_register],al |
||
1013 | mov al,ah |
||
1014 | cmp al,1 |
||
1015 | je test_reg_reg_8bit |
||
1016 | call operand_autodetect |
||
1017 | inc [base_code] |
||
1018 | test_reg_reg_8bit: |
||
31 | halyavin | 1019 | jmp nomem_instruction_ready |
1053 | heavyiron | 1020 | test_reg_imm: |
31 | halyavin | 1021 | mov al,[operand_size] |
157 | heavyiron | 1022 | cmp al,1 |
1023 | je test_reg_imm_8bit |
||
1024 | cmp al,2 |
||
1025 | je test_reg_imm_16bit |
||
1026 | cmp al,4 |
||
1027 | je test_reg_imm_32bit |
||
1028 | cmp al,8 |
||
1029 | jne invalid_operand_size |
||
1053 | heavyiron | 1030 | test_reg_imm_64bit: |
1031 | cmp [size_declared],0 |
||
1032 | jne long_immediate_not_encodable |
||
1033 | call operand_64bit |
||
1034 | call get_simm32 |
||
1035 | cmp [value_type],4 |
||
1036 | jae long_immediate_not_encodable |
||
1037 | jmp test_reg_imm_32bit_store |
||
1038 | test_reg_imm_8bit: |
||
31 | halyavin | 1039 | call get_byte_value |
157 | heavyiron | 1040 | mov dl,al |
1041 | mov bl,[postbyte_register] |
||
1042 | mov [postbyte_register],0 |
||
1043 | mov [base_code],0F6h |
||
1044 | or bl,bl |
||
1045 | jz test_al_imm |
||
1046 | call store_nomem_instruction |
||
1047 | mov al,dl |
||
1048 | stos byte [edi] |
||
1049 | jmp instruction_assembled |
||
1050 | test_al_imm: |
||
31 | halyavin | 1051 | mov [base_code],0A8h |
157 | heavyiron | 1052 | call store_classic_instruction_code |
6467 | dunkaist | 1053 | mov al,dl |
157 | heavyiron | 1054 | stos byte [edi] |
1055 | jmp instruction_assembled |
||
1056 | test_reg_imm_16bit: |
||
31 | halyavin | 1057 | call operand_16bit |
157 | heavyiron | 1058 | call get_word_value |
1059 | mov dx,ax |
||
1060 | mov bl,[postbyte_register] |
||
1061 | mov [postbyte_register],0 |
||
1062 | mov [base_code],0F7h |
||
1063 | or bl,bl |
||
1064 | jz test_ax_imm |
||
1065 | call store_nomem_instruction |
||
1066 | mov ax,dx |
||
1067 | call mark_relocation |
||
1068 | stos word [edi] |
||
1069 | jmp instruction_assembled |
||
1070 | test_ax_imm: |
||
31 | halyavin | 1071 | mov [base_code],0A9h |
157 | heavyiron | 1072 | call store_classic_instruction_code |
6467 | dunkaist | 1073 | mov ax,dx |
157 | heavyiron | 1074 | stos word [edi] |
1075 | jmp instruction_assembled |
||
1076 | test_reg_imm_32bit: |
||
31 | halyavin | 1077 | call operand_32bit |
157 | heavyiron | 1078 | call get_dword_value |
1079 | test_reg_imm_32bit_store: |
||
31 | halyavin | 1080 | mov edx,eax |
157 | heavyiron | 1081 | mov bl,[postbyte_register] |
1082 | mov [postbyte_register],0 |
||
1083 | mov [base_code],0F7h |
||
1084 | or bl,bl |
||
1085 | jz test_eax_imm |
||
1086 | call store_nomem_instruction |
||
1087 | mov eax,edx |
||
1088 | call mark_relocation |
||
1089 | stos dword [edi] |
||
1090 | jmp instruction_assembled |
||
1091 | test_eax_imm: |
||
31 | halyavin | 1092 | mov [base_code],0A9h |
157 | heavyiron | 1093 | call store_classic_instruction_code |
6467 | dunkaist | 1094 | mov eax,edx |
157 | heavyiron | 1095 | stos dword [edi] |
1096 | jmp instruction_assembled |
||
1097 | test_reg_mem: |
||
31 | halyavin | 1098 | call get_address |
157 | heavyiron | 1099 | mov al,[operand_size] |
1100 | cmp al,1 |
||
1101 | je test_reg_mem_8bit |
||
1102 | call operand_autodetect |
||
1103 | inc [base_code] |
||
1104 | test_reg_mem_8bit: |
||
31 | halyavin | 1105 | jmp instruction_ready |
1053 | heavyiron | 1106 | xchg_instruction: |
31 | halyavin | 1107 | mov [base_code],86h |
157 | heavyiron | 1108 | lods byte [esi] |
1109 | call get_size_operator |
||
1110 | cmp al,10h |
||
1111 | je xchg_reg |
||
1112 | cmp al,'[' |
||
1113 | jne invalid_operand |
||
1114 | xchg_mem: |
||
31 | halyavin | 1115 | call get_address |
157 | heavyiron | 1116 | push edx ebx ecx |
174 | heavyiron | 1117 | lods byte [esi] |
157 | heavyiron | 1118 | cmp al,',' |
1119 | jne invalid_operand |
||
1120 | lods byte [esi] |
||
1121 | call get_size_operator |
||
1122 | cmp al,10h |
||
1123 | je test_mem_reg |
||
1124 | jmp invalid_operand |
||
1125 | xchg_reg: |
||
31 | halyavin | 1126 | lods byte [esi] |
157 | heavyiron | 1127 | call convert_register |
1128 | mov [postbyte_register],al |
||
1129 | lods byte [esi] |
||
1130 | cmp al,',' |
||
1131 | jne invalid_operand |
||
1132 | lods byte [esi] |
||
1133 | call get_size_operator |
||
1134 | cmp al,'[' |
||
1135 | je test_reg_mem |
||
1136 | cmp al,10h |
||
1137 | jne invalid_operand |
||
1138 | xchg_reg_reg: |
||
31 | halyavin | 1139 | lods byte [esi] |
157 | heavyiron | 1140 | call convert_register |
1141 | mov bl,al |
||
1142 | mov al,ah |
||
1143 | cmp al,1 |
||
1144 | je xchg_reg_reg_8bit |
||
1145 | call operand_autodetect |
||
1146 | cmp [postbyte_register],0 |
||
1147 | je xchg_ax_reg |
||
1148 | or bl,bl |
||
1149 | jnz xchg_reg_reg_store |
||
1150 | mov bl,[postbyte_register] |
||
1151 | xchg_ax_reg: |
||
31 | halyavin | 1152 | cmp [code_type],64 |
157 | heavyiron | 1153 | jne xchg_ax_reg_ok |
1154 | cmp ah,4 |
||
1155 | jne xchg_ax_reg_ok |
||
1156 | or bl,bl |
||
1157 | jz xchg_reg_reg_store |
||
1158 | xchg_ax_reg_ok: |
||
31 | halyavin | 1159 | test bl,1000b |
157 | heavyiron | 1160 | jz xchg_ax_reg_store |
1161 | or [rex_prefix],41h |
||
1162 | and bl,111b |
||
1163 | xchg_ax_reg_store: |
||
31 | halyavin | 1164 | add bl,90h |
157 | heavyiron | 1165 | mov [base_code],bl |
1166 | call store_classic_instruction_code |
||
6467 | dunkaist | 1167 | jmp instruction_assembled |
157 | heavyiron | 1168 | xchg_reg_reg_store: |
31 | halyavin | 1169 | inc [base_code] |
157 | heavyiron | 1170 | xchg_reg_reg_8bit: |
31 | halyavin | 1171 | jmp nomem_instruction_ready |
1053 | heavyiron | 1172 | push_instruction: |
31 | halyavin | 1173 | mov [push_size],al |
157 | heavyiron | 1174 | push_next: |
31 | halyavin | 1175 | lods byte [esi] |
157 | heavyiron | 1176 | call get_size_operator |
1177 | cmp al,10h |
||
1178 | je push_reg |
||
1179 | cmp al,'(' |
||
1180 | je push_imm |
||
1181 | cmp al,'[' |
||
1182 | jne invalid_operand |
||
1183 | push_mem: |
||
31 | halyavin | 1184 | call get_address |
157 | heavyiron | 1185 | mov al,[operand_size] |
1186 | mov ah,[push_size] |
||
1187 | cmp al,2 |
||
1188 | je push_mem_16bit |
||
1189 | cmp al,4 |
||
1190 | je push_mem_32bit |
||
1191 | cmp al,8 |
||
1192 | je push_mem_64bit |
||
1193 | or al,al |
||
1194 | jnz invalid_operand_size |
||
1195 | cmp ah,2 |
||
1196 | je push_mem_16bit |
||
1197 | cmp ah,4 |
||
1198 | je push_mem_32bit |
||
1199 | cmp ah,8 |
||
1200 | je push_mem_64bit |
||
1201 | call recoverable_unknown_size |
||
2665 | dunkaist | 1202 | jmp push_mem_store |
157 | heavyiron | 1203 | push_mem_16bit: |
31 | halyavin | 1204 | test ah,not 2 |
157 | heavyiron | 1205 | jnz invalid_operand_size |
1206 | call operand_16bit |
||
1207 | jmp push_mem_store |
||
1208 | push_mem_32bit: |
||
31 | halyavin | 1209 | test ah,not 4 |
157 | heavyiron | 1210 | jnz invalid_operand_size |
1211 | cmp [code_type],64 |
||
1212 | je illegal_instruction |
||
1213 | call operand_32bit |
||
1214 | jmp push_mem_store |
||
1215 | push_mem_64bit: |
||
31 | halyavin | 1216 | test ah,not 8 |
157 | heavyiron | 1217 | jnz invalid_operand_size |
1218 | cmp [code_type],64 |
||
1219 | jne illegal_instruction |
||
1220 | push_mem_store: |
||
31 | halyavin | 1221 | mov [base_code],0FFh |
157 | heavyiron | 1222 | mov [postbyte_register],110b |
1223 | call store_instruction |
||
1224 | jmp push_done |
||
1225 | push_reg: |
||
31 | halyavin | 1226 | lods byte [esi] |
157 | heavyiron | 1227 | mov ah,al |
1228 | sub ah,10h |
||
1229 | and ah,al |
||
1230 | test ah,0F0h |
||
1231 | jnz push_sreg |
||
1232 | call convert_register |
||
1233 | test al,1000b |
||
1234 | jz push_reg_ok |
||
1235 | or [rex_prefix],41h |
||
1236 | and al,111b |
||
1237 | push_reg_ok: |
||
31 | halyavin | 1238 | add al,50h |
157 | heavyiron | 1239 | mov [base_code],al |
1240 | mov al,ah |
||
1241 | mov ah,[push_size] |
||
1242 | cmp al,2 |
||
1243 | je push_reg_16bit |
||
1244 | cmp al,4 |
||
1245 | je push_reg_32bit |
||
1246 | cmp al,8 |
||
1247 | jne invalid_operand_size |
||
1248 | push_reg_64bit: |
||
31 | halyavin | 1249 | test ah,not 8 |
157 | heavyiron | 1250 | jnz invalid_operand_size |
1251 | cmp [code_type],64 |
||
1252 | jne illegal_instruction |
||
1253 | jmp push_reg_store |
||
1254 | push_reg_32bit: |
||
31 | halyavin | 1255 | test ah,not 4 |
157 | heavyiron | 1256 | jnz invalid_operand_size |
1257 | cmp [code_type],64 |
||
1258 | je illegal_instruction |
||
1259 | call operand_32bit |
||
1260 | jmp push_reg_store |
||
1261 | push_reg_16bit: |
||
31 | halyavin | 1262 | test ah,not 2 |
157 | heavyiron | 1263 | jnz invalid_operand_size |
1264 | call operand_16bit |
||
1265 | push_reg_store: |
||
31 | halyavin | 1266 | call store_classic_instruction_code |
6467 | dunkaist | 1267 | jmp push_done |
157 | heavyiron | 1268 | push_sreg: |
31 | halyavin | 1269 | mov bl,al |
157 | heavyiron | 1270 | mov dl,[operand_size] |
1271 | mov dh,[push_size] |
||
1272 | cmp dl,2 |
||
1273 | je push_sreg16 |
||
1274 | cmp dl,4 |
||
1275 | je push_sreg32 |
||
1276 | cmp dl,8 |
||
1277 | je push_sreg64 |
||
1278 | or dl,dl |
||
1279 | jnz invalid_operand_size |
||
1280 | cmp dh,2 |
||
1281 | je push_sreg16 |
||
1282 | cmp dh,4 |
||
1283 | je push_sreg32 |
||
1284 | cmp dh,8 |
||
1285 | je push_sreg64 |
||
1286 | jmp push_sreg_store |
||
1287 | push_sreg16: |
||
31 | halyavin | 1288 | test dh,not 2 |
157 | heavyiron | 1289 | jnz invalid_operand_size |
1290 | call operand_16bit |
||
1291 | jmp push_sreg_store |
||
1292 | push_sreg32: |
||
31 | halyavin | 1293 | test dh,not 4 |
157 | heavyiron | 1294 | jnz invalid_operand_size |
1295 | cmp [code_type],64 |
||
1296 | je illegal_instruction |
||
1297 | call operand_32bit |
||
1298 | jmp push_sreg_store |
||
1299 | push_sreg64: |
||
31 | halyavin | 1300 | test dh,not 8 |
157 | heavyiron | 1301 | jnz invalid_operand_size |
1302 | cmp [code_type],64 |
||
1303 | jne illegal_instruction |
||
1304 | push_sreg_store: |
||
31 | halyavin | 1305 | mov al,bl |
157 | heavyiron | 1306 | cmp al,40h |
6467 | dunkaist | 1307 | jae invalid_operand |
157 | heavyiron | 1308 | sub al,31h |
6467 | dunkaist | 1309 | jc invalid_operand |
370 | heavyiron | 1310 | cmp al,4 |
157 | heavyiron | 1311 | jae push_sreg_386 |
1312 | shl al,3 |
||
1313 | add al,6 |
||
1314 | mov [base_code],al |
||
1315 | cmp [code_type],64 |
||
1316 | je illegal_instruction |
||
1317 | jmp push_reg_store |
||
1318 | push_sreg_386: |
||
31 | halyavin | 1319 | sub al,4 |
157 | heavyiron | 1320 | shl al,3 |
1321 | add al,0A0h |
||
1322 | mov [extended_code],al |
||
1323 | mov [base_code],0Fh |
||
1324 | jmp push_reg_store |
||
1325 | push_imm: |
||
31 | halyavin | 1326 | mov al,[operand_size] |
157 | heavyiron | 1327 | mov ah,[push_size] |
1328 | or al,al |
||
1329 | je push_imm_size_ok |
||
1330 | or ah,ah |
||
1331 | je push_imm_size_ok |
||
1332 | cmp al,ah |
||
1333 | jne invalid_operand_size |
||
1334 | push_imm_size_ok: |
||
31 | halyavin | 1335 | cmp al,2 |
157 | heavyiron | 1336 | je push_imm_16bit |
1337 | cmp al,4 |
||
1338 | je push_imm_32bit |
||
1339 | cmp al,8 |
||
1340 | je push_imm_64bit |
||
1341 | cmp ah,2 |
||
1342 | je push_imm_optimized_16bit |
||
1343 | cmp ah,4 |
||
1344 | je push_imm_optimized_32bit |
||
1345 | cmp ah,8 |
||
1346 | je push_imm_optimized_64bit |
||
1347 | or al,al |
||
1348 | jnz invalid_operand_size |
||
1349 | cmp [code_type],16 |
||
1350 | je push_imm_optimized_16bit |
||
1351 | cmp [code_type],32 |
||
1352 | je push_imm_optimized_32bit |
||
1353 | push_imm_optimized_64bit: |
||
31 | halyavin | 1354 | cmp [code_type],64 |
157 | heavyiron | 1355 | jne illegal_instruction |
1356 | call get_simm32 |
||
1357 | mov edx,eax |
||
1358 | cmp [value_type],0 |
||
1359 | jne push_imm_32bit_store |
||
1360 | cmp eax,-80h |
||
1361 | jl push_imm_32bit_store |
||
1362 | cmp eax,80h |
||
1363 | jge push_imm_32bit_store |
||
1364 | jmp push_imm_8bit |
||
1365 | push_imm_optimized_32bit: |
||
31 | halyavin | 1366 | cmp [code_type],64 |
157 | heavyiron | 1367 | je illegal_instruction |
1368 | call get_dword_value |
||
1369 | mov edx,eax |
||
1370 | call operand_32bit |
||
1371 | cmp [value_type],0 |
||
1372 | jne push_imm_32bit_store |
||
1373 | cmp eax,-80h |
||
1374 | jl push_imm_32bit_store |
||
1375 | cmp eax,80h |
||
1376 | jge push_imm_32bit_store |
||
1377 | jmp push_imm_8bit |
||
1378 | push_imm_optimized_16bit: |
||
31 | halyavin | 1379 | call get_word_value |
157 | heavyiron | 1380 | mov dx,ax |
1381 | call operand_16bit |
||
1382 | cmp [value_type],0 |
||
1383 | jne push_imm_16bit_store |
||
1384 | cmp ax,-80h |
||
1385 | jl push_imm_16bit_store |
||
1386 | cmp ax,80h |
||
1387 | jge push_imm_16bit_store |
||
1388 | push_imm_8bit: |
||
31 | halyavin | 1389 | mov ah,al |
157 | heavyiron | 1390 | mov [base_code],6Ah |
1391 | call store_classic_instruction_code |
||
6467 | dunkaist | 1392 | mov al,ah |
157 | heavyiron | 1393 | stos byte [edi] |
1394 | jmp push_done |
||
1395 | push_imm_16bit: |
||
31 | halyavin | 1396 | call get_word_value |
157 | heavyiron | 1397 | mov dx,ax |
1398 | call operand_16bit |
||
1399 | push_imm_16bit_store: |
||
31 | halyavin | 1400 | mov [base_code],68h |
157 | heavyiron | 1401 | call store_classic_instruction_code |
6467 | dunkaist | 1402 | mov ax,dx |
157 | heavyiron | 1403 | call mark_relocation |
1404 | stos word [edi] |
||
1405 | jmp push_done |
||
1406 | push_imm_64bit: |
||
31 | halyavin | 1407 | cmp [code_type],64 |
157 | heavyiron | 1408 | jne illegal_instruction |
1409 | call get_simm32 |
||
1410 | mov edx,eax |
||
1411 | jmp push_imm_32bit_store |
||
1412 | push_imm_32bit: |
||
31 | halyavin | 1413 | cmp [code_type],64 |
157 | heavyiron | 1414 | je illegal_instruction |
1415 | call get_dword_value |
||
1416 | mov edx,eax |
||
1417 | call operand_32bit |
||
1418 | push_imm_32bit_store: |
||
31 | halyavin | 1419 | mov [base_code],68h |
157 | heavyiron | 1420 | call store_classic_instruction_code |
6467 | dunkaist | 1421 | mov eax,edx |
157 | heavyiron | 1422 | call mark_relocation |
1423 | stos dword [edi] |
||
1424 | push_done: |
||
31 | halyavin | 1425 | lods byte [esi] |
157 | heavyiron | 1426 | dec esi |
1427 | cmp al,0Fh |
||
1428 | je instruction_assembled |
||
1429 | or al,al |
||
1430 | jz instruction_assembled |
||
1431 | ; mov [operand_size],0 |
||
6467 | dunkaist | 1432 | ; mov [operand_flags],0 |
1433 | ; mov [operand_prefix],0 |
||
1434 | ; mov [rex_prefix],0 |
||
1435 | and dword [operand_size],0 |
||
1436 | jmp push_next |
||
157 | heavyiron | 1437 | pop_instruction: |
31 | halyavin | 1438 | mov [push_size],al |
157 | heavyiron | 1439 | pop_next: |
31 | halyavin | 1440 | lods byte [esi] |
157 | heavyiron | 1441 | call get_size_operator |
1442 | cmp al,10h |
||
1443 | je pop_reg |
||
1444 | cmp al,'[' |
||
1445 | jne invalid_operand |
||
1446 | pop_mem: |
||
31 | halyavin | 1447 | call get_address |
157 | heavyiron | 1448 | mov al,[operand_size] |
1449 | mov ah,[push_size] |
||
1450 | cmp al,2 |
||
1451 | je pop_mem_16bit |
||
1452 | cmp al,4 |
||
1453 | je pop_mem_32bit |
||
1454 | cmp al,8 |
||
1455 | je pop_mem_64bit |
||
1456 | or al,al |
||
1457 | jnz invalid_operand_size |
||
1458 | cmp ah,2 |
||
1459 | je pop_mem_16bit |
||
1460 | cmp ah,4 |
||
1461 | je pop_mem_32bit |
||
1462 | cmp ah,8 |
||
1463 | je pop_mem_64bit |
||
1464 | call recoverable_unknown_size |
||
2665 | dunkaist | 1465 | jmp pop_mem_store |
157 | heavyiron | 1466 | pop_mem_16bit: |
31 | halyavin | 1467 | test ah,not 2 |
157 | heavyiron | 1468 | jnz invalid_operand_size |
1469 | call operand_16bit |
||
1470 | jmp pop_mem_store |
||
1471 | pop_mem_32bit: |
||
31 | halyavin | 1472 | test ah,not 4 |
157 | heavyiron | 1473 | jnz invalid_operand_size |
1474 | cmp [code_type],64 |
||
1475 | je illegal_instruction |
||
1476 | call operand_32bit |
||
1477 | jmp pop_mem_store |
||
1478 | pop_mem_64bit: |
||
31 | halyavin | 1479 | test ah,not 8 |
157 | heavyiron | 1480 | jnz invalid_operand_size |
1481 | cmp [code_type],64 |
||
1482 | jne illegal_instruction |
||
1483 | pop_mem_store: |
||
31 | halyavin | 1484 | mov [base_code],08Fh |
157 | heavyiron | 1485 | mov [postbyte_register],0 |
1486 | call store_instruction |
||
1487 | jmp pop_done |
||
1488 | pop_reg: |
||
31 | halyavin | 1489 | lods byte [esi] |
157 | heavyiron | 1490 | mov ah,al |
1491 | sub ah,10h |
||
1492 | and ah,al |
||
1493 | test ah,0F0h |
||
1494 | jnz pop_sreg |
||
1495 | call convert_register |
||
1496 | test al,1000b |
||
1497 | jz pop_reg_ok |
||
1498 | or [rex_prefix],41h |
||
1499 | and al,111b |
||
1500 | pop_reg_ok: |
||
31 | halyavin | 1501 | add al,58h |
157 | heavyiron | 1502 | mov [base_code],al |
1503 | mov al,ah |
||
1504 | mov ah,[push_size] |
||
1505 | cmp al,2 |
||
1506 | je pop_reg_16bit |
||
1507 | cmp al,4 |
||
1508 | je pop_reg_32bit |
||
1509 | cmp al,8 |
||
1510 | je pop_reg_64bit |
||
1511 | jmp invalid_operand_size |
||
1512 | pop_reg_64bit: |
||
31 | halyavin | 1513 | test ah,not 8 |
157 | heavyiron | 1514 | jnz invalid_operand_size |
1515 | cmp [code_type],64 |
||
1516 | jne illegal_instruction |
||
1517 | jmp pop_reg_store |
||
1518 | pop_reg_32bit: |
||
31 | halyavin | 1519 | test ah,not 4 |
157 | heavyiron | 1520 | jnz invalid_operand_size |
1521 | cmp [code_type],64 |
||
1522 | je illegal_instruction |
||
1523 | call operand_32bit |
||
1524 | jmp pop_reg_store |
||
1525 | pop_reg_16bit: |
||
31 | halyavin | 1526 | test ah,not 2 |
157 | heavyiron | 1527 | jnz invalid_operand_size |
1528 | call operand_16bit |
||
1529 | pop_reg_store: |
||
31 | halyavin | 1530 | call store_classic_instruction_code |
6467 | dunkaist | 1531 | pop_done: |
31 | halyavin | 1532 | lods byte [esi] |
157 | heavyiron | 1533 | dec esi |
1534 | cmp al,0Fh |
||
1535 | je instruction_assembled |
||
1536 | or al,al |
||
1537 | jz instruction_assembled |
||
1538 | ; mov [operand_size],0 |
||
6467 | dunkaist | 1539 | ; mov [operand_flags],0 |
1540 | ; mov [operand_prefix],0 |
||
1541 | ; mov [rex_prefix],0 |
||
1542 | and dword [operand_size],0 |
||
1543 | jmp pop_next |
||
157 | heavyiron | 1544 | pop_sreg: |
31 | halyavin | 1545 | mov dl,[operand_size] |
157 | heavyiron | 1546 | mov dh,[push_size] |
1547 | cmp al,32h |
||
6467 | dunkaist | 1548 | je pop_cs |
157 | heavyiron | 1549 | mov bl,al |
1550 | cmp dl,2 |
||
1551 | je pop_sreg16 |
||
1552 | cmp dl,4 |
||
1553 | je pop_sreg32 |
||
1554 | cmp dl,8 |
||
1555 | je pop_sreg64 |
||
1556 | or dl,dl |
||
1557 | jnz invalid_operand_size |
||
1558 | cmp dh,2 |
||
1559 | je pop_sreg16 |
||
1560 | cmp dh,4 |
||
1561 | je pop_sreg32 |
||
1562 | cmp dh,8 |
||
1563 | je pop_sreg64 |
||
1564 | jmp pop_sreg_store |
||
1565 | pop_sreg16: |
||
31 | halyavin | 1566 | test dh,not 2 |
157 | heavyiron | 1567 | jnz invalid_operand_size |
1568 | call operand_16bit |
||
1569 | jmp pop_sreg_store |
||
1570 | pop_sreg32: |
||
31 | halyavin | 1571 | test dh,not 4 |
157 | heavyiron | 1572 | jnz invalid_operand_size |
1573 | cmp [code_type],64 |
||
1574 | je illegal_instruction |
||
1575 | call operand_32bit |
||
1576 | jmp pop_sreg_store |
||
1577 | pop_sreg64: |
||
31 | halyavin | 1578 | test dh,not 8 |
157 | heavyiron | 1579 | jnz invalid_operand_size |
1580 | cmp [code_type],64 |
||
1581 | jne illegal_instruction |
||
1582 | pop_sreg_store: |
||
31 | halyavin | 1583 | mov al,bl |
157 | heavyiron | 1584 | cmp al,40h |
6467 | dunkaist | 1585 | jae invalid_operand |
157 | heavyiron | 1586 | sub al,31h |
6467 | dunkaist | 1587 | jc invalid_operand |
370 | heavyiron | 1588 | cmp al,4 |
157 | heavyiron | 1589 | jae pop_sreg_386 |
1590 | shl al,3 |
||
1591 | add al,7 |
||
1592 | mov [base_code],al |
||
1593 | cmp [code_type],64 |
||
1594 | je illegal_instruction |
||
1595 | jmp pop_reg_store |
||
1596 | pop_cs: |
||
109 | heavyiron | 1597 | cmp [code_type],16 |
157 | heavyiron | 1598 | jne illegal_instruction |
1599 | cmp dl,2 |
||
1600 | je pop_cs_store |
||
1601 | or dl,dl |
||
1602 | jnz invalid_operand_size |
||
1603 | cmp dh,2 |
||
1604 | je pop_cs_store |
||
1605 | or dh,dh |
||
1606 | jnz illegal_instruction |
||
1607 | pop_cs_store: |
||
109 | heavyiron | 1608 | test dh,not 2 |
157 | heavyiron | 1609 | jnz invalid_operand_size |
1610 | mov al,0Fh |
||
1611 | stos byte [edi] |
||
1612 | jmp pop_done |
||
1613 | pop_sreg_386: |
||
31 | halyavin | 1614 | sub al,4 |
157 | heavyiron | 1615 | shl al,3 |
1616 | add al,0A1h |
||
1617 | mov [extended_code],al |
||
1618 | mov [base_code],0Fh |
||
1619 | jmp pop_reg_store |
||
1620 | inc_instruction: |
||
31 | halyavin | 1621 | mov [base_code],al |
157 | heavyiron | 1622 | lods byte [esi] |
1623 | call get_size_operator |
||
1624 | cmp al,10h |
||
1625 | je inc_reg |
||
1626 | cmp al,'[' |
||
1627 | je inc_mem |
||
1628 | jne invalid_operand |
||
1629 | inc_mem: |
||
31 | halyavin | 1630 | call get_address |
157 | heavyiron | 1631 | mov al,[operand_size] |
1632 | cmp al,1 |
||
1633 | je inc_mem_8bit |
||
1634 | jb inc_mem_nosize |
||
1635 | call operand_autodetect |
||
1636 | mov al,0FFh |
||
1637 | xchg al,[base_code] |
||
1638 | mov [postbyte_register],al |
||
1639 | jmp instruction_ready |
||
1053 | heavyiron | 1640 | inc_mem_nosize: |
31 | halyavin | 1641 | call recoverable_unknown_size |
2665 | dunkaist | 1642 | inc_mem_8bit: |
31 | halyavin | 1643 | mov al,0FEh |
157 | heavyiron | 1644 | xchg al,[base_code] |
1645 | mov [postbyte_register],al |
||
1646 | jmp instruction_ready |
||
1053 | heavyiron | 1647 | inc_reg: |
31 | halyavin | 1648 | lods byte [esi] |
157 | heavyiron | 1649 | call convert_register |
1650 | mov bl,al |
||
1651 | mov al,0FEh |
||
1652 | xchg al,[base_code] |
||
1653 | mov [postbyte_register],al |
||
1654 | mov al,ah |
||
1655 | cmp al,1 |
||
1656 | je inc_reg_8bit |
||
1657 | call operand_autodetect |
||
1658 | cmp [code_type],64 |
||
1659 | je inc_reg_long_form |
||
1660 | mov al,[postbyte_register] |
||
1661 | shl al,3 |
||
1662 | add al,bl |
||
1663 | add al,40h |
||
1664 | mov [base_code],al |
||
1665 | call store_classic_instruction_code |
||
6467 | dunkaist | 1666 | jmp instruction_assembled |
157 | heavyiron | 1667 | inc_reg_long_form: |
31 | halyavin | 1668 | inc [base_code] |
157 | heavyiron | 1669 | inc_reg_8bit: |
31 | halyavin | 1670 | jmp nomem_instruction_ready |
1053 | heavyiron | 1671 | set_instruction: |
31 | halyavin | 1672 | mov [base_code],0Fh |
157 | heavyiron | 1673 | mov [extended_code],al |
1674 | lods byte [esi] |
||
1675 | call get_size_operator |
||
1676 | cmp al,10h |
||
1677 | je set_reg |
||
1678 | cmp al,'[' |
||
1679 | jne invalid_operand |
||
1680 | set_mem: |
||
31 | halyavin | 1681 | call get_address |
157 | heavyiron | 1682 | cmp [operand_size],1 |
1683 | ja invalid_operand_size |
||
1684 | mov [postbyte_register],0 |
||
1685 | jmp instruction_ready |
||
1053 | heavyiron | 1686 | set_reg: |
31 | halyavin | 1687 | lods byte [esi] |
157 | heavyiron | 1688 | call convert_register |
1689 | cmp ah,1 |
||
1690 | jne invalid_operand_size |
||
1691 | mov bl,al |
||
1692 | mov [postbyte_register],0 |
||
1693 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 1694 | arpl_instruction: |
31 | halyavin | 1695 | cmp [code_type],64 |
157 | heavyiron | 1696 | je illegal_instruction |
1697 | mov [base_code],63h |
||
1698 | lods byte [esi] |
||
1699 | call get_size_operator |
||
1700 | cmp al,10h |
||
1701 | je arpl_reg |
||
1702 | cmp al,'[' |
||
1703 | jne invalid_operand |
||
1704 | call get_address |
||
1705 | lods byte [esi] |
||
1706 | cmp al,',' |
||
1707 | jne invalid_operand |
||
1708 | call take_register |
||
6467 | dunkaist | 1709 | mov [postbyte_register],al |
157 | heavyiron | 1710 | cmp ah,2 |
1711 | jne invalid_operand_size |
||
1712 | jmp instruction_ready |
||
1053 | heavyiron | 1713 | arpl_reg: |
31 | halyavin | 1714 | lods byte [esi] |
157 | heavyiron | 1715 | call convert_register |
1716 | cmp ah,2 |
||
1717 | jne invalid_operand_size |
||
1718 | mov bl,al |
||
1719 | lods byte [esi] |
||
1720 | cmp al,',' |
||
1721 | jne invalid_operand |
||
1722 | call take_register |
||
6467 | dunkaist | 1723 | mov [postbyte_register],al |
157 | heavyiron | 1724 | jmp nomem_instruction_ready |
1053 | heavyiron | 1725 | bound_instruction: |
31 | halyavin | 1726 | cmp [code_type],64 |
157 | heavyiron | 1727 | je illegal_instruction |
1728 | call take_register |
||
6467 | dunkaist | 1729 | mov [postbyte_register],al |
157 | heavyiron | 1730 | lods byte [esi] |
1731 | cmp al,',' |
||
1732 | jne invalid_operand |
||
1733 | lods byte [esi] |
||
1734 | call get_size_operator |
||
1735 | cmp al,'[' |
||
1736 | jne invalid_operand |
||
1737 | call get_address |
||
1738 | mov al,[operand_size] |
||
1739 | cmp al,2 |
||
1740 | je bound_store |
||
1053 | heavyiron | 1741 | cmp al,4 |
157 | heavyiron | 1742 | jne invalid_operand_size |
1053 | heavyiron | 1743 | bound_store: |
1744 | call operand_autodetect |
||
1745 | mov [base_code],62h |
||
157 | heavyiron | 1746 | jmp instruction_ready |
1053 | heavyiron | 1747 | enter_instruction: |
31 | halyavin | 1748 | lods byte [esi] |
157 | heavyiron | 1749 | call get_size_operator |
1750 | cmp ah,2 |
||
1751 | je enter_imm16_size_ok |
||
1752 | or ah,ah |
||
1753 | jnz invalid_operand_size |
||
1754 | enter_imm16_size_ok: |
||
31 | halyavin | 1755 | cmp al,'(' |
157 | heavyiron | 1756 | jne invalid_operand |
1757 | call get_word_value |
||
1758 | cmp [next_pass_needed],0 |
||
1759 | jne enter_imm16_ok |
||
1760 | cmp [value_type],0 |
||
1761 | jne invalid_use_of_symbol |
||
1762 | test eax,eax |
||
2287 | heavyiron | 1763 | js value_out_of_range |
1764 | enter_imm16_ok: |
||
31 | halyavin | 1765 | push eax |
157 | heavyiron | 1766 | mov [operand_size],0 |
1767 | lods byte [esi] |
||
1768 | cmp al,',' |
||
1769 | jne invalid_operand |
||
1770 | lods byte [esi] |
||
1771 | call get_size_operator |
||
1772 | cmp ah,1 |
||
1773 | je enter_imm8_size_ok |
||
1774 | or ah,ah |
||
1775 | jnz invalid_operand_size |
||
1776 | enter_imm8_size_ok: |
||
31 | halyavin | 1777 | cmp al,'(' |
157 | heavyiron | 1778 | jne invalid_operand |
1779 | call get_byte_value |
||
1780 | cmp [next_pass_needed],0 |
||
2287 | heavyiron | 1781 | jne enter_imm8_ok |
1782 | test eax,eax |
||
1783 | js value_out_of_range |
||
1784 | enter_imm8_ok: |
||
1785 | mov dl,al |
||
157 | heavyiron | 1786 | pop ebx |
1787 | mov al,0C8h |
||
1788 | stos byte [edi] |
||
1789 | mov ax,bx |
||
1790 | stos word [edi] |
||
1791 | mov al,dl |
||
1792 | stos byte [edi] |
||
1793 | jmp instruction_assembled |
||
1794 | ret_instruction_only64: |
||
31 | halyavin | 1795 | cmp [code_type],64 |
157 | heavyiron | 1796 | jne illegal_instruction |
1797 | jmp ret_instruction |
||
1798 | ret_instruction_32bit_except64: |
||
31 | halyavin | 1799 | cmp [code_type],64 |
157 | heavyiron | 1800 | je illegal_instruction |
1801 | ret_instruction_32bit: |
||
31 | halyavin | 1802 | call operand_32bit |
157 | heavyiron | 1803 | jmp ret_instruction |
1804 | ret_instruction_16bit: |
||
31 | halyavin | 1805 | call operand_16bit |
157 | heavyiron | 1806 | jmp ret_instruction |
1807 | ret_instruction_64bit: |
||
31 | halyavin | 1808 | call operand_64bit |
157 | heavyiron | 1809 | ret_instruction: |
31 | halyavin | 1810 | and [prefix_flags],not 10h |
6467 | dunkaist | 1811 | ret_common: |
1812 | mov [base_code],al |
||
157 | heavyiron | 1813 | lods byte [esi] |
1814 | dec esi |
||
1815 | or al,al |
||
1816 | jz simple_ret |
||
1817 | cmp al,0Fh |
||
1818 | je simple_ret |
||
1819 | lods byte [esi] |
||
1820 | call get_size_operator |
||
1821 | or ah,ah |
||
1822 | jz ret_imm |
||
1823 | cmp ah,2 |
||
1824 | je ret_imm |
||
1825 | jmp invalid_operand_size |
||
1826 | ret_imm: |
||
31 | halyavin | 1827 | cmp al,'(' |
157 | heavyiron | 1828 | jne invalid_operand |
1829 | call get_word_value |
||
1830 | cmp [next_pass_needed],0 |
||
1831 | jne ret_imm_ok |
||
1832 | cmp [value_type],0 |
||
1833 | jne invalid_use_of_symbol |
||
1834 | test eax,eax |
||
2287 | heavyiron | 1835 | js value_out_of_range |
1836 | ret_imm_ok: |
||
31 | halyavin | 1837 | cmp [size_declared],0 |
157 | heavyiron | 1838 | jne ret_imm_store |
1839 | or ax,ax |
||
1840 | jz simple_ret |
||
1841 | ret_imm_store: |
||
109 | heavyiron | 1842 | mov dx,ax |
157 | heavyiron | 1843 | call store_classic_instruction_code |
6467 | dunkaist | 1844 | mov ax,dx |
157 | heavyiron | 1845 | stos word [edi] |
1846 | jmp instruction_assembled |
||
1847 | simple_ret: |
||
31 | halyavin | 1848 | inc [base_code] |
157 | heavyiron | 1849 | call store_classic_instruction_code |
6467 | dunkaist | 1850 | jmp instruction_assembled |
157 | heavyiron | 1851 | retf_instruction: |
6467 | dunkaist | 1852 | cmp [code_type],64 |
1853 | jne ret_common |
||
1854 | retf_instruction_64bit: |
||
1855 | call operand_64bit |
||
1856 | jmp ret_common |
||
1857 | retf_instruction_32bit: |
||
1858 | call operand_32bit |
||
1859 | jmp ret_common |
||
1860 | retf_instruction_16bit: |
||
1861 | call operand_16bit |
||
1862 | jmp ret_common |
||
1863 | lea_instruction: |
||
31 | halyavin | 1864 | mov [base_code],8Dh |
157 | heavyiron | 1865 | call take_register |
6467 | dunkaist | 1866 | mov [postbyte_register],al |
157 | heavyiron | 1867 | lods byte [esi] |
1868 | cmp al,',' |
||
1869 | jne invalid_operand |
||
1870 | xor al,al |
||
1871 | xchg al,[operand_size] |
||
1872 | push eax |
||
1873 | lods byte [esi] |
||
1874 | call get_size_operator |
||
1875 | cmp al,'[' |
||
1876 | jne invalid_operand |
||
1877 | or [operand_flags],1 |
||
6467 | dunkaist | 1878 | call get_address |
157 | heavyiron | 1879 | pop eax |
1880 | mov [operand_size],al |
||
1881 | call operand_autodetect |
||
1882 | jmp instruction_ready |
||
1053 | heavyiron | 1883 | ls_instruction: |
31 | halyavin | 1884 | or al,al |
157 | heavyiron | 1885 | jz les_instruction |
1886 | cmp al,3 |
||
1887 | jz lds_instruction |
||
1888 | add al,0B0h |
||
1889 | mov [extended_code],al |
||
1890 | mov [base_code],0Fh |
||
1891 | jmp ls_code_ok |
||
1892 | les_instruction: |
||
31 | halyavin | 1893 | mov [base_code],0C4h |
157 | heavyiron | 1894 | jmp ls_short_code |
1895 | lds_instruction: |
||
31 | halyavin | 1896 | mov [base_code],0C5h |
157 | heavyiron | 1897 | ls_short_code: |
31 | halyavin | 1898 | cmp [code_type],64 |
157 | heavyiron | 1899 | je illegal_instruction |
1900 | ls_code_ok: |
||
31 | halyavin | 1901 | call take_register |
6467 | dunkaist | 1902 | mov [postbyte_register],al |
157 | heavyiron | 1903 | lods byte [esi] |
1904 | cmp al,',' |
||
1905 | jne invalid_operand |
||
1906 | add [operand_size],2 |
||
1907 | lods byte [esi] |
||
1908 | call get_size_operator |
||
1909 | cmp al,'[' |
||
1910 | jne invalid_operand |
||
1911 | call get_address |
||
1912 | mov al,[operand_size] |
||
1913 | cmp al,4 |
||
1914 | je ls_16bit |
||
1915 | cmp al,6 |
||
1916 | je ls_32bit |
||
1917 | cmp al,10 |
||
1918 | je ls_64bit |
||
1919 | jmp invalid_operand_size |
||
1920 | ls_16bit: |
||
31 | halyavin | 1921 | call operand_16bit |
157 | heavyiron | 1922 | jmp instruction_ready |
1053 | heavyiron | 1923 | ls_32bit: |
31 | halyavin | 1924 | call operand_32bit |
157 | heavyiron | 1925 | jmp instruction_ready |
1053 | heavyiron | 1926 | ls_64bit: |
31 | halyavin | 1927 | call operand_64bit |
157 | heavyiron | 1928 | jmp instruction_ready |
1053 | heavyiron | 1929 | sh_instruction: |
31 | halyavin | 1930 | mov [postbyte_register],al |
157 | heavyiron | 1931 | lods byte [esi] |
1932 | call get_size_operator |
||
1933 | cmp al,10h |
||
1934 | je sh_reg |
||
1935 | cmp al,'[' |
||
1936 | jne invalid_operand |
||
1937 | sh_mem: |
||
31 | halyavin | 1938 | call get_address |
157 | heavyiron | 1939 | push edx ebx ecx |
174 | heavyiron | 1940 | mov al,[operand_size] |
157 | heavyiron | 1941 | push eax |
1942 | mov [operand_size],0 |
||
1943 | lods byte [esi] |
||
1944 | cmp al,',' |
||
1945 | jne invalid_operand |
||
1946 | lods byte [esi] |
||
1947 | call get_size_operator |
||
1948 | cmp al,'(' |
||
1949 | je sh_mem_imm |
||
1950 | cmp al,10h |
||
1951 | jne invalid_operand |
||
1952 | sh_mem_reg: |
||
31 | halyavin | 1953 | lods byte [esi] |
157 | heavyiron | 1954 | cmp al,11h |
1955 | jne invalid_operand |
||
1956 | pop eax ecx ebx edx |
||
174 | heavyiron | 1957 | cmp al,1 |
157 | heavyiron | 1958 | je sh_mem_cl_8bit |
1959 | jb sh_mem_cl_nosize |
||
1960 | call operand_autodetect |
||
1961 | mov [base_code],0D3h |
||
1962 | jmp instruction_ready |
||
1053 | heavyiron | 1963 | sh_mem_cl_nosize: |
31 | halyavin | 1964 | call recoverable_unknown_size |
2665 | dunkaist | 1965 | sh_mem_cl_8bit: |
31 | halyavin | 1966 | mov [base_code],0D2h |
157 | heavyiron | 1967 | jmp instruction_ready |
1053 | heavyiron | 1968 | sh_mem_imm: |
31 | halyavin | 1969 | mov al,[operand_size] |
157 | heavyiron | 1970 | or al,al |
1971 | jz sh_mem_imm_size_ok |
||
1972 | cmp al,1 |
||
1973 | jne invalid_operand_size |
||
1974 | sh_mem_imm_size_ok: |
||
31 | halyavin | 1975 | call get_byte_value |
157 | heavyiron | 1976 | mov byte [value],al |
1977 | pop eax ecx ebx edx |
||
174 | heavyiron | 1978 | cmp al,1 |
157 | heavyiron | 1979 | je sh_mem_imm_8bit |
1980 | jb sh_mem_imm_nosize |
||
1981 | call operand_autodetect |
||
1982 | cmp byte [value],1 |
||
1983 | je sh_mem_1 |
||
1984 | mov [base_code],0C1h |
||
1985 | call store_instruction_with_imm8 |
||
1986 | jmp instruction_assembled |
||
1987 | sh_mem_1: |
||
31 | halyavin | 1988 | mov [base_code],0D1h |
157 | heavyiron | 1989 | jmp instruction_ready |
1053 | heavyiron | 1990 | sh_mem_imm_nosize: |
31 | halyavin | 1991 | call recoverable_unknown_size |
2665 | dunkaist | 1992 | sh_mem_imm_8bit: |
31 | halyavin | 1993 | cmp byte [value],1 |
157 | heavyiron | 1994 | je sh_mem_1_8bit |
1995 | mov [base_code],0C0h |
||
1996 | call store_instruction_with_imm8 |
||
1997 | jmp instruction_assembled |
||
1998 | sh_mem_1_8bit: |
||
31 | halyavin | 1999 | mov [base_code],0D0h |
157 | heavyiron | 2000 | jmp instruction_ready |
1053 | heavyiron | 2001 | sh_reg: |
31 | halyavin | 2002 | lods byte [esi] |
157 | heavyiron | 2003 | call convert_register |
2004 | mov bx,ax |
||
2005 | mov [operand_size],0 |
||
2006 | lods byte [esi] |
||
2007 | cmp al,',' |
||
2008 | jne invalid_operand |
||
2009 | lods byte [esi] |
||
2010 | call get_size_operator |
||
2011 | cmp al,'(' |
||
2012 | je sh_reg_imm |
||
2013 | cmp al,10h |
||
2014 | jne invalid_operand |
||
2015 | sh_reg_reg: |
||
31 | halyavin | 2016 | lods byte [esi] |
157 | heavyiron | 2017 | cmp al,11h |
2018 | jne invalid_operand |
||
2019 | mov al,bh |
||
2020 | cmp al,1 |
||
2021 | je sh_reg_cl_8bit |
||
2022 | call operand_autodetect |
||
2023 | mov [base_code],0D3h |
||
2024 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 2025 | sh_reg_cl_8bit: |
31 | halyavin | 2026 | mov [base_code],0D2h |
157 | heavyiron | 2027 | jmp nomem_instruction_ready |
1053 | heavyiron | 2028 | sh_reg_imm: |
31 | halyavin | 2029 | mov al,[operand_size] |
157 | heavyiron | 2030 | or al,al |
2031 | jz sh_reg_imm_size_ok |
||
2032 | cmp al,1 |
||
2033 | jne invalid_operand_size |
||
2034 | sh_reg_imm_size_ok: |
||
31 | halyavin | 2035 | push ebx |
157 | heavyiron | 2036 | call get_byte_value |
2037 | mov dl,al |
||
2038 | pop ebx |
||
2039 | mov al,bh |
||
2040 | cmp al,1 |
||
2041 | je sh_reg_imm_8bit |
||
2042 | call operand_autodetect |
||
2043 | cmp dl,1 |
||
2044 | je sh_reg_1 |
||
2045 | mov [base_code],0C1h |
||
2046 | call store_nomem_instruction |
||
2047 | mov al,dl |
||
2048 | stos byte [edi] |
||
2049 | jmp instruction_assembled |
||
2050 | sh_reg_1: |
||
31 | halyavin | 2051 | mov [base_code],0D1h |
157 | heavyiron | 2052 | jmp nomem_instruction_ready |
1053 | heavyiron | 2053 | sh_reg_imm_8bit: |
31 | halyavin | 2054 | cmp dl,1 |
157 | heavyiron | 2055 | je sh_reg_1_8bit |
2056 | mov [base_code],0C0h |
||
2057 | call store_nomem_instruction |
||
2058 | mov al,dl |
||
2059 | stos byte [edi] |
||
2060 | jmp instruction_assembled |
||
2061 | sh_reg_1_8bit: |
||
31 | halyavin | 2062 | mov [base_code],0D0h |
157 | heavyiron | 2063 | jmp nomem_instruction_ready |
1053 | heavyiron | 2064 | shd_instruction: |
31 | halyavin | 2065 | mov [base_code],0Fh |
157 | heavyiron | 2066 | mov [extended_code],al |
2067 | lods byte [esi] |
||
2068 | call get_size_operator |
||
2069 | cmp al,10h |
||
2070 | je shd_reg |
||
2071 | cmp al,'[' |
||
2072 | jne invalid_operand |
||
2073 | shd_mem: |
||
31 | halyavin | 2074 | call get_address |
157 | heavyiron | 2075 | push edx ebx ecx |
174 | heavyiron | 2076 | lods byte [esi] |
157 | heavyiron | 2077 | cmp al,',' |
2078 | jne invalid_operand |
||
2079 | call take_register |
||
6467 | dunkaist | 2080 | mov [postbyte_register],al |
157 | heavyiron | 2081 | lods byte [esi] |
2082 | cmp al,',' |
||
2083 | jne invalid_operand |
||
2084 | mov al,ah |
||
2085 | mov [operand_size],0 |
||
2086 | push eax |
||
2087 | lods byte [esi] |
||
2088 | call get_size_operator |
||
2089 | cmp al,'(' |
||
2090 | je shd_mem_reg_imm |
||
2091 | cmp al,10h |
||
2092 | jne invalid_operand |
||
2093 | lods byte [esi] |
||
2094 | cmp al,11h |
||
2095 | jne invalid_operand |
||
2096 | pop eax ecx ebx edx |
||
174 | heavyiron | 2097 | call operand_autodetect |
157 | heavyiron | 2098 | inc [extended_code] |
2099 | jmp instruction_ready |
||
1053 | heavyiron | 2100 | shd_mem_reg_imm: |
31 | halyavin | 2101 | mov al,[operand_size] |
157 | heavyiron | 2102 | or al,al |
2103 | jz shd_mem_reg_imm_size_ok |
||
2104 | cmp al,1 |
||
2105 | jne invalid_operand_size |
||
2106 | shd_mem_reg_imm_size_ok: |
||
31 | halyavin | 2107 | call get_byte_value |
157 | heavyiron | 2108 | mov byte [value],al |
2109 | pop eax ecx ebx edx |
||
174 | heavyiron | 2110 | call operand_autodetect |
157 | heavyiron | 2111 | call store_instruction_with_imm8 |
2112 | jmp instruction_assembled |
||
2113 | shd_reg: |
||
31 | halyavin | 2114 | lods byte [esi] |
157 | heavyiron | 2115 | call convert_register |
2116 | mov [postbyte_register],al |
||
2117 | lods byte [esi] |
||
2118 | cmp al,',' |
||
2119 | jne invalid_operand |
||
2120 | call take_register |
||
6467 | dunkaist | 2121 | mov bl,[postbyte_register] |
157 | heavyiron | 2122 | mov [postbyte_register],al |
2123 | mov al,ah |
||
2124 | push eax ebx |
||
2125 | lods byte [esi] |
||
2126 | cmp al,',' |
||
2127 | jne invalid_operand |
||
2128 | mov [operand_size],0 |
||
2129 | lods byte [esi] |
||
2130 | call get_size_operator |
||
2131 | cmp al,'(' |
||
2132 | je shd_reg_reg_imm |
||
2133 | cmp al,10h |
||
2134 | jne invalid_operand |
||
2135 | lods byte [esi] |
||
2136 | cmp al,11h |
||
2137 | jne invalid_operand |
||
2138 | pop ebx eax |
||
2139 | call operand_autodetect |
||
2140 | inc [extended_code] |
||
2141 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 2142 | shd_reg_reg_imm: |
31 | halyavin | 2143 | mov al,[operand_size] |
157 | heavyiron | 2144 | or al,al |
2145 | jz shd_reg_reg_imm_size_ok |
||
2146 | cmp al,1 |
||
2147 | jne invalid_operand_size |
||
2148 | shd_reg_reg_imm_size_ok: |
||
31 | halyavin | 2149 | call get_byte_value |
157 | heavyiron | 2150 | mov dl,al |
2151 | pop ebx eax |
||
2152 | call operand_autodetect |
||
2153 | call store_nomem_instruction |
||
2154 | mov al,dl |
||
2155 | stos byte [edi] |
||
2156 | jmp instruction_assembled |
||
2157 | movx_instruction: |
||
31 | halyavin | 2158 | mov [base_code],0Fh |
157 | heavyiron | 2159 | mov [extended_code],al |
2160 | call take_register |
||
6467 | dunkaist | 2161 | mov [postbyte_register],al |
157 | heavyiron | 2162 | mov al,ah |
2163 | push eax |
||
2164 | lods byte [esi] |
||
2165 | cmp al,',' |
||
2166 | jne invalid_operand |
||
2167 | mov [operand_size],0 |
||
2168 | lods byte [esi] |
||
2169 | call get_size_operator |
||
2170 | cmp al,10h |
||
2171 | je movx_reg |
||
2172 | cmp al,'[' |
||
2173 | jne invalid_operand |
||
2174 | call get_address |
||
2175 | pop eax |
||
2176 | mov ah,[operand_size] |
||
2177 | or ah,ah |
||
2178 | jz movx_unknown_size |
||
2179 | cmp ah,al |
||
2180 | jae invalid_operand_size |
||
2181 | cmp ah,1 |
||
2182 | je movx_mem_store |
||
1039 | heavyiron | 2183 | cmp ah,2 |
157 | heavyiron | 2184 | jne invalid_operand_size |
2185 | inc [extended_code] |
||
2186 | movx_mem_store: |
||
1039 | heavyiron | 2187 | call operand_autodetect |
157 | heavyiron | 2188 | jmp instruction_ready |
1053 | heavyiron | 2189 | movx_unknown_size: |
109 | heavyiron | 2190 | call recoverable_unknown_size |
2665 | dunkaist | 2191 | jmp movx_mem_store |
1039 | heavyiron | 2192 | movx_reg: |
31 | halyavin | 2193 | lods byte [esi] |
157 | heavyiron | 2194 | call convert_register |
2195 | pop ebx |
||
2196 | xchg bl,al |
||
2197 | cmp ah,al |
||
2198 | jae invalid_operand_size |
||
2199 | cmp ah,1 |
||
2200 | je movx_reg_8bit |
||
2201 | cmp ah,2 |
||
2202 | je movx_reg_16bit |
||
2203 | jmp invalid_operand_size |
||
2204 | movx_reg_8bit: |
||
31 | halyavin | 2205 | call operand_autodetect |
157 | heavyiron | 2206 | jmp nomem_instruction_ready |
1053 | heavyiron | 2207 | movx_reg_16bit: |
31 | halyavin | 2208 | call operand_autodetect |
157 | heavyiron | 2209 | inc [extended_code] |
2210 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 2211 | movsxd_instruction: |
31 | halyavin | 2212 | mov [base_code],al |
157 | heavyiron | 2213 | call take_register |
6467 | dunkaist | 2214 | mov [postbyte_register],al |
157 | heavyiron | 2215 | cmp ah,8 |
2216 | jne invalid_operand_size |
||
2217 | lods byte [esi] |
||
2218 | cmp al,',' |
||
2219 | jne invalid_operand |
||
2220 | mov [operand_size],0 |
||
2221 | lods byte [esi] |
||
2222 | call get_size_operator |
||
2223 | cmp al,10h |
||
2224 | je movsxd_reg |
||
2225 | cmp al,'[' |
||
2226 | jne invalid_operand |
||
2227 | call get_address |
||
2228 | cmp [operand_size],4 |
||
2229 | je movsxd_mem_store |
||
2230 | cmp [operand_size],0 |
||
2231 | jne invalid_operand_size |
||
2232 | movsxd_mem_store: |
||
31 | halyavin | 2233 | call operand_64bit |
157 | heavyiron | 2234 | jmp instruction_ready |
1053 | heavyiron | 2235 | movsxd_reg: |
31 | halyavin | 2236 | lods byte [esi] |
157 | heavyiron | 2237 | call convert_register |
2238 | cmp ah,4 |
||
2239 | jne invalid_operand_size |
||
2240 | mov bl,al |
||
2241 | call operand_64bit |
||
2242 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 2243 | bt_instruction: |
31 | halyavin | 2244 | mov [postbyte_register],al |
157 | heavyiron | 2245 | shl al,3 |
2246 | add al,83h |
||
2247 | mov [extended_code],al |
||
2248 | mov [base_code],0Fh |
||
2249 | lods byte [esi] |
||
2250 | call get_size_operator |
||
2251 | cmp al,10h |
||
2252 | je bt_reg |
||
2253 | cmp al,'[' |
||
2254 | jne invalid_operand |
||
2255 | call get_address |
||
2256 | push eax ebx ecx |
||
174 | heavyiron | 2257 | lods byte [esi] |
157 | heavyiron | 2258 | cmp al,',' |
2259 | jne invalid_operand |
||
2260 | cmp byte [esi],'(' |
||
2261 | je bt_mem_imm |
||
2262 | cmp byte [esi],11h |
||
2263 | jne bt_mem_reg |
||
2264 | cmp byte [esi+2],'(' |
||
2265 | je bt_mem_imm |
||
2266 | bt_mem_reg: |
||
31 | halyavin | 2267 | call take_register |
6467 | dunkaist | 2268 | mov [postbyte_register],al |
157 | heavyiron | 2269 | pop ecx ebx edx |
174 | heavyiron | 2270 | mov al,ah |
157 | heavyiron | 2271 | call operand_autodetect |
2272 | jmp instruction_ready |
||
1053 | heavyiron | 2273 | bt_mem_imm: |
31 | halyavin | 2274 | xor al,al |
157 | heavyiron | 2275 | xchg al,[operand_size] |
2276 | push eax |
||
2277 | lods byte [esi] |
||
2278 | call get_size_operator |
||
2279 | cmp al,'(' |
||
2280 | jne invalid_operand |
||
2281 | mov al,[operand_size] |
||
2282 | or al,al |
||
2283 | jz bt_mem_imm_size_ok |
||
2284 | cmp al,1 |
||
2285 | jne invalid_operand_size |
||
2286 | bt_mem_imm_size_ok: |
||
31 | halyavin | 2287 | call get_byte_value |
157 | heavyiron | 2288 | mov byte [value],al |
2289 | pop eax |
||
2290 | or al,al |
||
2291 | jz bt_mem_imm_nosize |
||
2292 | call operand_autodetect |
||
2293 | bt_mem_imm_store: |
||
31 | halyavin | 2294 | pop ecx ebx edx |
174 | heavyiron | 2295 | mov [extended_code],0BAh |
157 | heavyiron | 2296 | call store_instruction_with_imm8 |
2297 | jmp instruction_assembled |
||
2298 | bt_mem_imm_nosize: |
||
31 | halyavin | 2299 | call recoverable_unknown_size |
2665 | dunkaist | 2300 | jmp bt_mem_imm_store |
157 | heavyiron | 2301 | bt_reg: |
31 | halyavin | 2302 | lods byte [esi] |
157 | heavyiron | 2303 | call convert_register |
2304 | mov bl,al |
||
2305 | lods byte [esi] |
||
2306 | cmp al,',' |
||
2307 | jne invalid_operand |
||
2308 | cmp byte [esi],'(' |
||
2309 | je bt_reg_imm |
||
2310 | cmp byte [esi],11h |
||
2311 | jne bt_reg_reg |
||
2312 | cmp byte [esi+2],'(' |
||
2313 | je bt_reg_imm |
||
2314 | bt_reg_reg: |
||
31 | halyavin | 2315 | call take_register |
6467 | dunkaist | 2316 | mov [postbyte_register],al |
157 | heavyiron | 2317 | mov al,ah |
2318 | call operand_autodetect |
||
2319 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 2320 | bt_reg_imm: |
31 | halyavin | 2321 | xor al,al |
157 | heavyiron | 2322 | xchg al,[operand_size] |
2323 | push eax ebx |
||
2324 | lods byte [esi] |
||
2325 | call get_size_operator |
||
2326 | cmp al,'(' |
||
2327 | jne invalid_operand |
||
2328 | mov al,[operand_size] |
||
2329 | or al,al |
||
2330 | jz bt_reg_imm_size_ok |
||
2331 | cmp al,1 |
||
2332 | jne invalid_operand_size |
||
2333 | bt_reg_imm_size_ok: |
||
31 | halyavin | 2334 | call get_byte_value |
157 | heavyiron | 2335 | mov byte [value],al |
2336 | pop ebx eax |
||
2337 | call operand_autodetect |
||
2338 | bt_reg_imm_store: |
||
31 | halyavin | 2339 | mov [extended_code],0BAh |
157 | heavyiron | 2340 | call store_nomem_instruction |
2341 | mov al,byte [value] |
||
2342 | stos byte [edi] |
||
2343 | jmp instruction_assembled |
||
2344 | bs_instruction: |
||
31 | halyavin | 2345 | mov [extended_code],al |
157 | heavyiron | 2346 | mov [base_code],0Fh |
2347 | call get_reg_mem |
||
2665 | dunkaist | 2348 | jc bs_reg_reg |
2349 | mov al,[operand_size] |
||
2350 | call operand_autodetect |
||
2351 | jmp instruction_ready |
||
2352 | bs_reg_reg: |
||
2353 | mov al,ah |
||
2354 | call operand_autodetect |
||
2355 | jmp nomem_instruction_ready |
||
2356 | get_reg_mem: |
||
2357 | call take_register |
||
6467 | dunkaist | 2358 | mov [postbyte_register],al |
157 | heavyiron | 2359 | lods byte [esi] |
2360 | cmp al,',' |
||
2361 | jne invalid_operand |
||
2362 | lods byte [esi] |
||
2363 | call get_size_operator |
||
2364 | cmp al,10h |
||
2365 | je get_reg_reg |
||
2665 | dunkaist | 2366 | cmp al,'[' |
157 | heavyiron | 2367 | jne invalid_argument |
2368 | call get_address |
||
2369 | clc |
||
2665 | dunkaist | 2370 | ret |
2371 | get_reg_reg: |
||
2372 | lods byte [esi] |
||
157 | heavyiron | 2373 | call convert_register |
2374 | mov bl,al |
||
2375 | stc |
||
2665 | dunkaist | 2376 | ret |
2377 | |||
2378 | |||
31 | halyavin | 2379 | mov [base_code],0F6h |
157 | heavyiron | 2380 | mov [postbyte_register],5 |
2381 | lods byte [esi] |
||
2382 | call get_size_operator |
||
2383 | cmp al,10h |
||
2384 | je imul_reg |
||
2385 | cmp al,'[' |
||
2386 | jne invalid_operand |
||
2387 | imul_mem: |
||
31 | halyavin | 2388 | call get_address |
157 | heavyiron | 2389 | mov al,[operand_size] |
2390 | cmp al,1 |
||
2391 | je imul_mem_8bit |
||
2392 | jb imul_mem_nosize |
||
2393 | call operand_autodetect |
||
2394 | inc [base_code] |
||
2395 | jmp instruction_ready |
||
1053 | heavyiron | 2396 | imul_mem_nosize: |
31 | halyavin | 2397 | call recoverable_unknown_size |
2665 | dunkaist | 2398 | imul_mem_8bit: |
31 | halyavin | 2399 | jmp instruction_ready |
1053 | heavyiron | 2400 | imul_reg: |
31 | halyavin | 2401 | lods byte [esi] |
157 | heavyiron | 2402 | call convert_register |
2403 | cmp byte [esi],',' |
||
2404 | je imul_reg_ |
||
2405 | mov bl,al |
||
2406 | mov al,ah |
||
2407 | cmp al,1 |
||
2408 | je imul_reg_8bit |
||
2409 | call operand_autodetect |
||
2410 | inc [base_code] |
||
2411 | imul_reg_8bit: |
||
31 | halyavin | 2412 | jmp nomem_instruction_ready |
1053 | heavyiron | 2413 | imul_reg_: |
31 | halyavin | 2414 | mov [postbyte_register],al |
157 | heavyiron | 2415 | inc esi |
2416 | cmp byte [esi],'(' |
||
2417 | je imul_reg_imm |
||
2418 | cmp byte [esi],11h |
||
2419 | jne imul_reg_noimm |
||
2420 | cmp byte [esi+2],'(' |
||
2421 | je imul_reg_imm |
||
2422 | imul_reg_noimm: |
||
31 | halyavin | 2423 | lods byte [esi] |
157 | heavyiron | 2424 | call get_size_operator |
2425 | cmp al,10h |
||
2426 | je imul_reg_reg |
||
2427 | cmp al,'[' |
||
2428 | jne invalid_operand |
||
2429 | imul_reg_mem: |
||
31 | halyavin | 2430 | call get_address |
157 | heavyiron | 2431 | push edx ebx ecx |
174 | heavyiron | 2432 | cmp byte [esi],',' |
157 | heavyiron | 2433 | je imul_reg_mem_imm |
2434 | mov al,[operand_size] |
||
2435 | call operand_autodetect |
||
2436 | pop ecx ebx edx |
||
174 | heavyiron | 2437 | mov [base_code],0Fh |
157 | heavyiron | 2438 | mov [extended_code],0AFh |
2439 | jmp instruction_ready |
||
1053 | heavyiron | 2440 | imul_reg_mem_imm: |
31 | halyavin | 2441 | inc esi |
157 | heavyiron | 2442 | lods byte [esi] |
2443 | call get_size_operator |
||
2444 | cmp al,'(' |
||
2445 | jne invalid_operand |
||
2446 | mov al,[operand_size] |
||
2447 | cmp al,2 |
||
2448 | je imul_reg_mem_imm_16bit |
||
2449 | cmp al,4 |
||
2450 | je imul_reg_mem_imm_32bit |
||
2451 | cmp al,8 |
||
2452 | jne invalid_operand_size |
||
1053 | heavyiron | 2453 | imul_reg_mem_imm_64bit: |
2454 | cmp [size_declared],0 |
||
2455 | jne long_immediate_not_encodable |
||
2456 | call operand_64bit |
||
2457 | call get_simm32 |
||
2458 | cmp [value_type],4 |
||
2459 | jae long_immediate_not_encodable |
||
2460 | jmp imul_reg_mem_imm_32bit_ok |
||
2461 | imul_reg_mem_imm_16bit: |
||
31 | halyavin | 2462 | call operand_16bit |
157 | heavyiron | 2463 | call get_word_value |
2464 | mov word [value],ax |
||
2465 | cmp [value_type],0 |
||
2466 | jne imul_reg_mem_imm_16bit_store |
||
2467 | cmp [size_declared],0 |
||
2468 | jne imul_reg_mem_imm_16bit_store |
||
2469 | cmp ax,-80h |
||
2470 | jl imul_reg_mem_imm_16bit_store |
||
2471 | cmp ax,80h |
||
2472 | jl imul_reg_mem_imm_8bit_store |
||
2473 | imul_reg_mem_imm_16bit_store: |
||
31 | halyavin | 2474 | pop ecx ebx edx |
174 | heavyiron | 2475 | mov [base_code],69h |
157 | heavyiron | 2476 | call store_instruction_with_imm16 |
2477 | jmp instruction_assembled |
||
2478 | imul_reg_mem_imm_32bit: |
||
31 | halyavin | 2479 | call operand_32bit |
157 | heavyiron | 2480 | call get_dword_value |
2481 | imul_reg_mem_imm_32bit_ok: |
||
31 | halyavin | 2482 | mov dword [value],eax |
157 | heavyiron | 2483 | cmp [value_type],0 |
2484 | jne imul_reg_mem_imm_32bit_store |
||
2485 | cmp [size_declared],0 |
||
2486 | jne imul_reg_mem_imm_32bit_store |
||
2487 | cmp eax,-80h |
||
2488 | jl imul_reg_mem_imm_32bit_store |
||
2489 | cmp eax,80h |
||
2490 | jl imul_reg_mem_imm_8bit_store |
||
2491 | imul_reg_mem_imm_32bit_store: |
||
31 | halyavin | 2492 | pop ecx ebx edx |
174 | heavyiron | 2493 | mov [base_code],69h |
157 | heavyiron | 2494 | call store_instruction_with_imm32 |
2495 | jmp instruction_assembled |
||
2496 | imul_reg_mem_imm_8bit_store: |
||
31 | halyavin | 2497 | pop ecx ebx edx |
174 | heavyiron | 2498 | mov [base_code],6Bh |
157 | heavyiron | 2499 | call store_instruction_with_imm8 |
2500 | jmp instruction_assembled |
||
2501 | imul_reg_imm: |
||
31 | halyavin | 2502 | mov bl,[postbyte_register] |
157 | heavyiron | 2503 | dec esi |
2504 | jmp imul_reg_reg_imm |
||
2505 | imul_reg_reg: |
||
31 | halyavin | 2506 | lods byte [esi] |
157 | heavyiron | 2507 | call convert_register |
2508 | mov bl,al |
||
2509 | cmp byte [esi],',' |
||
2510 | je imul_reg_reg_imm |
||
2511 | mov al,ah |
||
2512 | call operand_autodetect |
||
2513 | mov [base_code],0Fh |
||
2514 | mov [extended_code],0AFh |
||
2515 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 2516 | imul_reg_reg_imm: |
31 | halyavin | 2517 | inc esi |
157 | heavyiron | 2518 | lods byte [esi] |
2519 | call get_size_operator |
||
2520 | cmp al,'(' |
||
2521 | jne invalid_operand |
||
2522 | mov al,[operand_size] |
||
2523 | cmp al,2 |
||
2524 | je imul_reg_reg_imm_16bit |
||
2525 | cmp al,4 |
||
2526 | je imul_reg_reg_imm_32bit |
||
2527 | cmp al,8 |
||
2528 | jne invalid_operand_size |
||
1053 | heavyiron | 2529 | imul_reg_reg_imm_64bit: |
2530 | cmp [size_declared],0 |
||
2531 | jne long_immediate_not_encodable |
||
2532 | call operand_64bit |
||
2533 | push ebx |
||
2534 | call get_simm32 |
||
2535 | cmp [value_type],4 |
||
2536 | jae long_immediate_not_encodable |
||
2537 | jmp imul_reg_reg_imm_32bit_ok |
||
2538 | imul_reg_reg_imm_16bit: |
||
31 | halyavin | 2539 | call operand_16bit |
157 | heavyiron | 2540 | push ebx |
2541 | call get_word_value |
||
2542 | pop ebx |
||
2543 | mov dx,ax |
||
2544 | cmp [value_type],0 |
||
2545 | jne imul_reg_reg_imm_16bit_store |
||
2546 | cmp [size_declared],0 |
||
2547 | jne imul_reg_reg_imm_16bit_store |
||
2548 | cmp ax,-80h |
||
2549 | jl imul_reg_reg_imm_16bit_store |
||
2550 | cmp ax,80h |
||
2551 | jl imul_reg_reg_imm_8bit_store |
||
2552 | imul_reg_reg_imm_16bit_store: |
||
31 | halyavin | 2553 | mov [base_code],69h |
157 | heavyiron | 2554 | call store_nomem_instruction |
2555 | mov ax,dx |
||
2556 | call mark_relocation |
||
2557 | stos word [edi] |
||
2558 | jmp instruction_assembled |
||
2559 | imul_reg_reg_imm_32bit: |
||
31 | halyavin | 2560 | call operand_32bit |
157 | heavyiron | 2561 | push ebx |
2562 | call get_dword_value |
||
2563 | imul_reg_reg_imm_32bit_ok: |
||
31 | halyavin | 2564 | pop ebx |
157 | heavyiron | 2565 | mov edx,eax |
2566 | cmp [value_type],0 |
||
2567 | jne imul_reg_reg_imm_32bit_store |
||
2568 | cmp [size_declared],0 |
||
2569 | jne imul_reg_reg_imm_32bit_store |
||
2570 | cmp eax,-80h |
||
2571 | jl imul_reg_reg_imm_32bit_store |
||
2572 | cmp eax,80h |
||
2573 | jl imul_reg_reg_imm_8bit_store |
||
2574 | imul_reg_reg_imm_32bit_store: |
||
31 | halyavin | 2575 | mov [base_code],69h |
157 | heavyiron | 2576 | call store_nomem_instruction |
2577 | mov eax,edx |
||
2578 | call mark_relocation |
||
2579 | stos dword [edi] |
||
2580 | jmp instruction_assembled |
||
2581 | imul_reg_reg_imm_8bit_store: |
||
31 | halyavin | 2582 | mov [base_code],6Bh |
157 | heavyiron | 2583 | call store_nomem_instruction |
2584 | mov al,dl |
||
2585 | stos byte [edi] |
||
2586 | jmp instruction_assembled |
||
2587 | in_instruction: |
||
31 | halyavin | 2588 | call take_register |
6467 | dunkaist | 2589 | or al,al |
157 | heavyiron | 2590 | jnz invalid_operand |
2591 | lods byte [esi] |
||
2592 | cmp al,',' |
||
2593 | jne invalid_operand |
||
2594 | mov al,ah |
||
2595 | push eax |
||
2596 | mov [operand_size],0 |
||
2597 | lods byte [esi] |
||
2598 | call get_size_operator |
||
2599 | cmp al,'(' |
||
2600 | je in_imm |
||
2601 | cmp al,10h |
||
2602 | je in_reg |
||
2603 | jmp invalid_operand |
||
2604 | in_reg: |
||
31 | halyavin | 2605 | lods byte [esi] |
157 | heavyiron | 2606 | cmp al,22h |
2607 | jne invalid_operand |
||
2608 | pop eax |
||
2609 | cmp al,1 |
||
2610 | je in_al_dx |
||
2611 | cmp al,2 |
||
2612 | je in_ax_dx |
||
2613 | cmp al,4 |
||
2614 | jne invalid_operand_size |
||
1053 | heavyiron | 2615 | in_ax_dx: |
31 | halyavin | 2616 | call operand_autodetect |
1053 | heavyiron | 2617 | mov [base_code],0EDh |
157 | heavyiron | 2618 | call store_classic_instruction_code |
6467 | dunkaist | 2619 | jmp instruction_assembled |
157 | heavyiron | 2620 | in_al_dx: |
1053 | heavyiron | 2621 | mov al,0ECh |
2622 | stos byte [edi] |
||
2623 | jmp instruction_assembled |
||
157 | heavyiron | 2624 | in_imm: |
31 | halyavin | 2625 | mov al,[operand_size] |
157 | heavyiron | 2626 | or al,al |
2627 | jz in_imm_size_ok |
||
2628 | cmp al,1 |
||
2629 | jne invalid_operand_size |
||
2630 | in_imm_size_ok: |
||
31 | halyavin | 2631 | call get_byte_value |
157 | heavyiron | 2632 | mov dl,al |
2633 | pop eax |
||
2634 | cmp al,1 |
||
2635 | je in_al_imm |
||
2636 | cmp al,2 |
||
2637 | je in_ax_imm |
||
2638 | cmp al,4 |
||
2639 | jne invalid_operand_size |
||
1053 | heavyiron | 2640 | in_ax_imm: |
31 | halyavin | 2641 | call operand_autodetect |
1053 | heavyiron | 2642 | mov [base_code],0E5h |
157 | heavyiron | 2643 | call store_classic_instruction_code |
6467 | dunkaist | 2644 | mov al,dl |
157 | heavyiron | 2645 | stos byte [edi] |
2646 | jmp instruction_assembled |
||
2647 | in_al_imm: |
||
1053 | heavyiron | 2648 | mov al,0E4h |
2649 | stos byte [edi] |
||
2650 | mov al,dl |
||
157 | heavyiron | 2651 | stos byte [edi] |
2652 | jmp instruction_assembled |
||
2653 | out_instruction: |
||
31 | halyavin | 2654 | lods byte [esi] |
157 | heavyiron | 2655 | call get_size_operator |
2656 | cmp al,'(' |
||
2657 | je out_imm |
||
2658 | cmp al,10h |
||
2659 | jne invalid_operand |
||
2660 | lods byte [esi] |
||
2661 | cmp al,22h |
||
2662 | jne invalid_operand |
||
2663 | lods byte [esi] |
||
2664 | cmp al,',' |
||
2665 | jne invalid_operand |
||
2666 | mov [operand_size],0 |
||
2667 | call take_register |
||
6467 | dunkaist | 2668 | or al,al |
157 | heavyiron | 2669 | jnz invalid_operand |
2670 | mov al,ah |
||
2671 | cmp al,1 |
||
2672 | je out_dx_al |
||
2673 | cmp al,2 |
||
2674 | je out_dx_ax |
||
2675 | cmp al,4 |
||
2676 | jne invalid_operand_size |
||
1053 | heavyiron | 2677 | out_dx_ax: |
31 | halyavin | 2678 | call operand_autodetect |
1053 | heavyiron | 2679 | mov [base_code],0EFh |
157 | heavyiron | 2680 | call store_classic_instruction_code |
6467 | dunkaist | 2681 | jmp instruction_assembled |
157 | heavyiron | 2682 | out_dx_al: |
1053 | heavyiron | 2683 | mov al,0EEh |
2684 | stos byte [edi] |
||
2685 | jmp instruction_assembled |
||
157 | heavyiron | 2686 | out_imm: |
31 | halyavin | 2687 | mov al,[operand_size] |
157 | heavyiron | 2688 | or al,al |
2689 | jz out_imm_size_ok |
||
2690 | cmp al,1 |
||
2691 | jne invalid_operand_size |
||
2692 | out_imm_size_ok: |
||
31 | halyavin | 2693 | call get_byte_value |
157 | heavyiron | 2694 | mov dl,al |
2695 | lods byte [esi] |
||
2696 | cmp al,',' |
||
2697 | jne invalid_operand |
||
2698 | mov [operand_size],0 |
||
2699 | call take_register |
||
6467 | dunkaist | 2700 | or al,al |
157 | heavyiron | 2701 | jnz invalid_operand |
2702 | mov al,ah |
||
2703 | cmp al,1 |
||
2704 | je out_imm_al |
||
2705 | cmp al,2 |
||
2706 | je out_imm_ax |
||
2707 | cmp al,4 |
||
2708 | jne invalid_operand_size |
||
1053 | heavyiron | 2709 | out_imm_ax: |
31 | halyavin | 2710 | call operand_autodetect |
1053 | heavyiron | 2711 | mov [base_code],0E7h |
157 | heavyiron | 2712 | call store_classic_instruction_code |
6467 | dunkaist | 2713 | mov al,dl |
157 | heavyiron | 2714 | stos byte [edi] |
2715 | jmp instruction_assembled |
||
2716 | out_imm_al: |
||
1053 | heavyiron | 2717 | mov al,0E6h |
2718 | stos byte [edi] |
||
2719 | mov al,dl |
||
157 | heavyiron | 2720 | stos byte [edi] |
2721 | jmp instruction_assembled |
||
2722 | |||
31 | halyavin | 2723 | |
2724 | mov [postbyte_register],10b |
||
157 | heavyiron | 2725 | mov [base_code],0E8h |
2726 | mov [extended_code],9Ah |
||
2727 | jmp process_jmp |
||
2728 | jmp_instruction: |
||
31 | halyavin | 2729 | mov [postbyte_register],100b |
157 | heavyiron | 2730 | mov [base_code],0E9h |
2731 | mov [extended_code],0EAh |
||
2732 | process_jmp: |
||
31 | halyavin | 2733 | lods byte [esi] |
157 | heavyiron | 2734 | call get_jump_operator |
2735 | test [prefix_flags],10h |
||
6467 | dunkaist | 2736 | jz jmp_type_ok |
2737 | test [jump_type],not 2 |
||
2738 | jnz illegal_instruction |
||
2739 | mov [jump_type],2 |
||
2740 | and [prefix_flags],not 10h |
||
2741 | jmp_type_ok: |
||
2742 | call get_size_operator |
||
157 | heavyiron | 2743 | cmp al,'(' |
2744 | je jmp_imm |
||
2745 | mov [base_code],0FFh |
||
2746 | cmp al,10h |
||
2747 | je jmp_reg |
||
2748 | cmp al,'[' |
||
2749 | jne invalid_operand |
||
2750 | jmp_mem: |
||
31 | halyavin | 2751 | cmp [jump_type],1 |
157 | heavyiron | 2752 | je illegal_instruction |
2753 | call get_address |
||
2754 | mov edx,eax |
||
2755 | mov al,[operand_size] |
||
2756 | or al,al |
||
2757 | jz jmp_mem_size_not_specified |
||
2758 | cmp al,2 |
||
2759 | je jmp_mem_16bit |
||
2760 | cmp al,4 |
||
2761 | je jmp_mem_32bit |
||
2762 | cmp al,6 |
||
2763 | je jmp_mem_48bit |
||
2764 | cmp al,8 |
||
2765 | je jmp_mem_64bit |
||
2766 | cmp al,10 |
||
2767 | je jmp_mem_80bit |
||
2768 | jmp invalid_operand_size |
||
2769 | jmp_mem_size_not_specified: |
||
31 | halyavin | 2770 | cmp [jump_type],3 |
157 | heavyiron | 2771 | je jmp_mem_far |
2772 | cmp [jump_type],2 |
||
2773 | je jmp_mem_near |
||
2774 | call recoverable_unknown_size |
||
2665 | dunkaist | 2775 | jmp_mem_near: |
31 | halyavin | 2776 | cmp [code_type],16 |
157 | heavyiron | 2777 | je jmp_mem_16bit |
2778 | cmp [code_type],32 |
||
2779 | je jmp_mem_near_32bit |
||
2780 | jmp_mem_64bit: |
||
31 | halyavin | 2781 | cmp [jump_type],3 |
157 | heavyiron | 2782 | je invalid_operand_size |
2783 | cmp [code_type],64 |
||
2784 | jne illegal_instruction |
||
2785 | jmp instruction_ready |
||
1053 | heavyiron | 2786 | jmp_mem_far: |
31 | halyavin | 2787 | cmp [code_type],16 |
157 | heavyiron | 2788 | je jmp_mem_far_32bit |
2789 | jmp_mem_48bit: |
||
31 | halyavin | 2790 | call operand_32bit |
157 | heavyiron | 2791 | jmp_mem_far_store: |
31 | halyavin | 2792 | cmp [jump_type],2 |
157 | heavyiron | 2793 | je invalid_operand_size |
2794 | inc [postbyte_register] |
||
2795 | jmp instruction_ready |
||
1053 | heavyiron | 2796 | jmp_mem_80bit: |
31 | halyavin | 2797 | call operand_64bit |
157 | heavyiron | 2798 | jmp jmp_mem_far_store |
2799 | jmp_mem_far_32bit: |
||
31 | halyavin | 2800 | call operand_16bit |
157 | heavyiron | 2801 | jmp jmp_mem_far_store |
2802 | jmp_mem_32bit: |
||
31 | halyavin | 2803 | cmp [jump_type],3 |
157 | heavyiron | 2804 | je jmp_mem_far_32bit |
2805 | cmp [jump_type],2 |
||
2806 | je jmp_mem_near_32bit |
||
2807 | cmp [code_type],16 |
||
2808 | je jmp_mem_far_32bit |
||
2809 | jmp_mem_near_32bit: |
||
31 | halyavin | 2810 | cmp [code_type],64 |
157 | heavyiron | 2811 | je illegal_instruction |
2812 | call operand_32bit |
||
2813 | jmp instruction_ready |
||
1053 | heavyiron | 2814 | jmp_mem_16bit: |
31 | halyavin | 2815 | cmp [jump_type],3 |
157 | heavyiron | 2816 | je invalid_operand_size |
2817 | call operand_16bit |
||
2818 | jmp instruction_ready |
||
1053 | heavyiron | 2819 | jmp_reg: |
31 | halyavin | 2820 | test [jump_type],1 |
157 | heavyiron | 2821 | jnz invalid_operand |
2822 | lods byte [esi] |
||
2823 | call convert_register |
||
2824 | mov bl,al |
||
2825 | mov al,ah |
||
2826 | cmp al,2 |
||
2827 | je jmp_reg_16bit |
||
2828 | cmp al,4 |
||
2829 | je jmp_reg_32bit |
||
2830 | cmp al,8 |
||
2831 | jne invalid_operand_size |
||
2832 | jmp_reg_64bit: |
||
31 | halyavin | 2833 | cmp [code_type],64 |
157 | heavyiron | 2834 | jne illegal_instruction |
2835 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 2836 | jmp_reg_32bit: |
31 | halyavin | 2837 | cmp [code_type],64 |
157 | heavyiron | 2838 | je illegal_instruction |
2839 | call operand_32bit |
||
1342 | heavyiron | 2840 | jmp nomem_instruction_ready |
1053 | heavyiron | 2841 | jmp_reg_16bit: |
31 | halyavin | 2842 | call operand_16bit |
157 | heavyiron | 2843 | jmp nomem_instruction_ready |
1053 | heavyiron | 2844 | jmp_imm: |
31 | halyavin | 2845 | cmp byte [esi],'.' |
157 | heavyiron | 2846 | je invalid_value |
2847 | mov ebx,esi |
||
2848 | dec esi |
||
2849 | call skip_symbol |
||
2850 | xchg esi,ebx |
||
2851 | cmp byte [ebx],':' |
||
2852 | je jmp_far |
||
2853 | cmp [jump_type],3 |
||
2854 | je invalid_operand |
||
2855 | jmp_near: |
||
109 | heavyiron | 2856 | mov al,[operand_size] |
157 | heavyiron | 2857 | cmp al,2 |
2858 | je jmp_imm_16bit |
||
2859 | cmp al,4 |
||
2860 | je jmp_imm_32bit |
||
2861 | cmp al,8 |
||
2862 | je jmp_imm_64bit |
||
2863 | or al,al |
||
2864 | jnz invalid_operand_size |
||
2865 | cmp [code_type],16 |
||
2866 | je jmp_imm_16bit |
||
2867 | cmp [code_type],64 |
||
2868 | je jmp_imm_64bit |
||
2869 | jmp_imm_32bit: |
||
109 | heavyiron | 2870 | cmp [code_type],64 |
157 | heavyiron | 2871 | je invalid_operand_size |
2872 | call get_address_dword_value |
||
220 | heavyiron | 2873 | cmp [code_type],16 |
157 | heavyiron | 2874 | jne jmp_imm_32bit_prefix_ok |
2875 | mov byte [edi],66h |
||
2876 | inc edi |
||
2877 | jmp_imm_32bit_prefix_ok: |
||
109 | heavyiron | 2878 | call calculate_jump_offset |
157 | heavyiron | 2879 | cdq |
2880 | call check_for_short_jump |
||
2881 | jc jmp_short |
||
2882 | jmp_imm_32bit_store: |
||
109 | heavyiron | 2883 | mov edx,eax |
157 | heavyiron | 2884 | sub edx,3 |
2885 | jno jmp_imm_32bit_ok |
||
2665 | dunkaist | 2886 | cmp [code_type],64 |
2887 | je jump_out_of_range |
||
6467 | dunkaist | 2888 | jmp_imm_32bit_ok: |
2665 | dunkaist | 2889 | mov al,[base_code] |
157 | heavyiron | 2890 | stos byte [edi] |
2891 | mov eax,edx |
||
2892 | call mark_relocation |
||
2893 | stos dword [edi] |
||
2894 | jmp instruction_assembled |
||
2895 | jmp_imm_64bit: |
||
109 | heavyiron | 2896 | cmp [code_type],64 |
157 | heavyiron | 2897 | jne invalid_operand_size |
2898 | call get_address_qword_value |
||
220 | heavyiron | 2899 | call calculate_jump_offset |
157 | heavyiron | 2900 | mov ecx,edx |
2901 | cdq |
||
2902 | cmp edx,ecx |
||
2903 | jne jump_out_of_range |
||
6467 | dunkaist | 2904 | call check_for_short_jump |
157 | heavyiron | 2905 | jnc jmp_imm_32bit_store |
2906 | jmp_short: |
||
109 | heavyiron | 2907 | mov ah,al |
157 | heavyiron | 2908 | mov al,0EBh |
2909 | stos word [edi] |
||
2910 | jmp instruction_assembled |
||
2911 | jmp_imm_16bit: |
||
109 | heavyiron | 2912 | call get_address_word_value |
220 | heavyiron | 2913 | cmp [code_type],16 |
157 | heavyiron | 2914 | je jmp_imm_16bit_prefix_ok |
2915 | mov byte [edi],66h |
||
2916 | inc edi |
||
2917 | jmp_imm_16bit_prefix_ok: |
||
109 | heavyiron | 2918 | call calculate_jump_offset |
157 | heavyiron | 2919 | cwde |
2920 | cdq |
||
2921 | call check_for_short_jump |
||
2922 | jc jmp_short |
||
2923 | cmp [value_type],0 |
||
2924 | jne invalid_use_of_symbol |
||
2925 | mov edx,eax |
||
2926 | dec edx |
||
2927 | mov al,[base_code] |
||
2928 | stos byte [edi] |
||
2929 | mov eax,edx |
||
2930 | stos word [edi] |
||
2931 | jmp instruction_assembled |
||
2932 | calculate_jump_offset: |
||
109 | heavyiron | 2933 | add edi,2 |
174 | heavyiron | 2934 | mov ebp,[addressing_space] |
4039 | heavyiron | 2935 | call calculate_relative_offset |
174 | heavyiron | 2936 | sub edi,2 |
2937 | ret |
||
157 | heavyiron | 2938 | check_for_short_jump: |
109 | heavyiron | 2939 | cmp [jump_type],1 |
157 | heavyiron | 2940 | je forced_short |
2941 | ja no_short_jump |
||
2942 | cmp [base_code],0E8h |
||
2943 | je no_short_jump |
||
2944 | cmp [value_type],0 |
||
2945 | jne no_short_jump |
||
2946 | cmp eax,80h |
||
2947 | jb short_jump |
||
2948 | cmp eax,-80h |
||
2949 | jae short_jump |
||
2950 | no_short_jump: |
||
109 | heavyiron | 2951 | clc |
157 | heavyiron | 2952 | ret |
2953 | forced_short: |
||
109 | heavyiron | 2954 | cmp [base_code],0E8h |
157 | heavyiron | 2955 | je illegal_instruction |
2956 | cmp [next_pass_needed],0 |
||
2957 | jne jmp_short_value_type_ok |
||
2958 | cmp [value_type],0 |
||
2959 | jne invalid_use_of_symbol |
||
2960 | jmp_short_value_type_ok: |
||
109 | heavyiron | 2961 | cmp eax,-80h |
157 | heavyiron | 2962 | jae short_jump |
2963 | cmp eax,80h |
||
2964 | jae jump_out_of_range |
||
2965 | short_jump: |
||
109 | heavyiron | 2966 | stc |
157 | heavyiron | 2967 | ret |
2968 | jump_out_of_range: |
||
109 | heavyiron | 2969 | cmp [error_line],0 |
157 | heavyiron | 2970 | jne instruction_assembled |
2971 | mov eax,[current_line] |
||
2972 | mov [error_line],eax |
||
2973 | mov [error],relative_jump_out_of_range |
||
2974 | jmp instruction_assembled |
||
2975 | jmp_far: |
||
31 | halyavin | 2976 | cmp [jump_type],2 |
157 | heavyiron | 2977 | je invalid_operand |
2978 | cmp [code_type],64 |
||
2979 | je illegal_instruction |
||
2980 | mov al,[extended_code] |
||
2981 | mov [base_code],al |
||
2982 | call get_word_value |
||
2983 | push eax |
||
2984 | inc esi |
||
2985 | lods byte [esi] |
||
2986 | cmp al,'(' |
||
2987 | jne invalid_operand |
||
2988 | mov al,[value_type] |
||
2989 | push eax [symbol_identifier] |
||
2990 | cmp byte [esi],'.' |
||
2991 | je invalid_value |
||
2992 | mov al,[operand_size] |
||
2993 | cmp al,4 |
||
2994 | je jmp_far_16bit |
||
2995 | cmp al,6 |
||
2996 | je jmp_far_32bit |
||
2997 | or al,al |
||
2998 | jnz invalid_operand_size |
||
2999 | cmp [code_type],16 |
||
3000 | jne jmp_far_32bit |
||
3001 | jmp_far_16bit: |
||
31 | halyavin | 3002 | call get_word_value |
157 | heavyiron | 3003 | mov ebx,eax |
3004 | call operand_16bit |
||
3005 | call store_classic_instruction_code |
||
6467 | dunkaist | 3006 | mov ax,bx |
157 | heavyiron | 3007 | call mark_relocation |
3008 | stos word [edi] |
||
3009 | jmp_far_segment: |
||
31 | halyavin | 3010 | pop [symbol_identifier] eax |
157 | heavyiron | 3011 | mov [value_type],al |
3012 | pop eax |
||
3013 | call mark_relocation |
||
3014 | stos word [edi] |
||
3015 | jmp instruction_assembled |
||
3016 | jmp_far_32bit: |
||
31 | halyavin | 3017 | call get_dword_value |
157 | heavyiron | 3018 | mov ebx,eax |
3019 | call operand_32bit |
||
3020 | call store_classic_instruction_code |
||
6467 | dunkaist | 3021 | mov eax,ebx |
157 | heavyiron | 3022 | call mark_relocation |
3023 | stos dword [edi] |
||
3024 | jmp jmp_far_segment |
||
3025 | conditional_jump: |
||
109 | heavyiron | 3026 | mov [base_code],al |
157 | heavyiron | 3027 | and [prefix_flags],not 10h |
6467 | dunkaist | 3028 | lods byte [esi] |
157 | heavyiron | 3029 | call get_jump_operator |
3030 | cmp [jump_type],3 |
||
3031 | je invalid_operand |
||
3032 | call get_size_operator |
||
3033 | cmp al,'(' |
||
3034 | jne invalid_operand |
||
3035 | cmp byte [esi],'.' |
||
3036 | je invalid_value |
||
3037 | mov al,[operand_size] |
||
3038 | cmp al,2 |
||
3039 | je conditional_jump_16bit |
||
3040 | cmp al,4 |
||
3041 | je conditional_jump_32bit |
||
3042 | cmp al,8 |
||
3043 | je conditional_jump_64bit |
||
3044 | or al,al |
||
3045 | jnz invalid_operand_size |
||
3046 | cmp [code_type],16 |
||
3047 | je conditional_jump_16bit |
||
3048 | cmp [code_type],64 |
||
3049 | je conditional_jump_64bit |
||
3050 | conditional_jump_32bit: |
||
109 | heavyiron | 3051 | cmp [code_type],64 |
157 | heavyiron | 3052 | je invalid_operand_size |
3053 | call get_address_dword_value |
||
220 | heavyiron | 3054 | cmp [code_type],16 |
157 | heavyiron | 3055 | jne conditional_jump_32bit_prefix_ok |
3056 | mov byte [edi],66h |
||
3057 | inc edi |
||
3058 | conditional_jump_32bit_prefix_ok: |
||
109 | heavyiron | 3059 | call calculate_jump_offset |
157 | heavyiron | 3060 | cdq |
3061 | call check_for_short_jump |
||
3062 | jc conditional_jump_short |
||
3063 | conditional_jump_32bit_store: |
||
109 | heavyiron | 3064 | mov edx,eax |
157 | heavyiron | 3065 | sub edx,4 |
3066 | jno conditional_jump_32bit_range_ok |
||
2287 | heavyiron | 3067 | cmp [code_type],64 |
3068 | je jump_out_of_range |
||
6467 | dunkaist | 3069 | conditional_jump_32bit_range_ok: |
2287 | heavyiron | 3070 | mov ah,[base_code] |
157 | heavyiron | 3071 | add ah,10h |
3072 | mov al,0Fh |
||
3073 | stos word [edi] |
||
3074 | mov eax,edx |
||
3075 | call mark_relocation |
||
3076 | stos dword [edi] |
||
3077 | jmp instruction_assembled |
||
3078 | conditional_jump_64bit: |
||
109 | heavyiron | 3079 | cmp [code_type],64 |
157 | heavyiron | 3080 | jne invalid_operand_size |
3081 | call get_address_qword_value |
||
220 | heavyiron | 3082 | call calculate_jump_offset |
157 | heavyiron | 3083 | mov ecx,edx |
3084 | cdq |
||
3085 | cmp edx,ecx |
||
3086 | jne jump_out_of_range |
||
6467 | dunkaist | 3087 | call check_for_short_jump |
157 | heavyiron | 3088 | jnc conditional_jump_32bit_store |
3089 | conditional_jump_short: |
||
109 | heavyiron | 3090 | mov ah,al |
157 | heavyiron | 3091 | mov al,[base_code] |
3092 | stos word [edi] |
||
3093 | jmp instruction_assembled |
||
3094 | conditional_jump_16bit: |
||
109 | heavyiron | 3095 | call get_address_word_value |
220 | heavyiron | 3096 | cmp [code_type],16 |
157 | heavyiron | 3097 | je conditional_jump_16bit_prefix_ok |
3098 | mov byte [edi],66h |
||
3099 | inc edi |
||
3100 | conditional_jump_16bit_prefix_ok: |
||
109 | heavyiron | 3101 | call calculate_jump_offset |
157 | heavyiron | 3102 | cwde |
3103 | cdq |
||
3104 | call check_for_short_jump |
||
3105 | jc conditional_jump_short |
||
3106 | cmp [value_type],0 |
||
3107 | jne invalid_use_of_symbol |
||
3108 | mov edx,eax |
||
3109 | sub dx,2 |
||
2287 | heavyiron | 3110 | mov ah,[base_code] |
157 | heavyiron | 3111 | add ah,10h |
3112 | mov al,0Fh |
||
3113 | stos word [edi] |
||
3114 | mov eax,edx |
||
3115 | stos word [edi] |
||
3116 | jmp instruction_assembled |
||
3117 | loop_instruction_16bit: |
||
109 | heavyiron | 3118 | cmp [code_type],64 |
157 | heavyiron | 3119 | je illegal_instruction |
3120 | cmp [code_type],16 |
||
872 | heavyiron | 3121 | je loop_instruction |
3122 | mov [operand_prefix],67h |
||
3123 | jmp loop_instruction |
||
157 | heavyiron | 3124 | loop_instruction_32bit: |
109 | heavyiron | 3125 | cmp [code_type],32 |
872 | heavyiron | 3126 | je loop_instruction |
3127 | mov [operand_prefix],67h |
||
3128 | jmp loop_instruction |
||
3129 | loop_instruction_64bit: |
||
109 | heavyiron | 3130 | cmp [code_type],64 |
157 | heavyiron | 3131 | jne illegal_instruction |
3132 | loop_instruction: |
||
109 | heavyiron | 3133 | mov [base_code],al |
157 | heavyiron | 3134 | lods byte [esi] |
3135 | call get_jump_operator |
||
3136 | cmp [jump_type],1 |
||
3137 | ja invalid_operand |
||
3138 | call get_size_operator |
||
3139 | cmp al,'(' |
||
3140 | jne invalid_operand |
||
3141 | cmp byte [esi],'.' |
||
3142 | je invalid_value |
||
3143 | mov al,[operand_size] |
||
3144 | cmp al,2 |
||
3145 | je loop_jump_16bit |
||
3146 | cmp al,4 |
||
3147 | je loop_jump_32bit |
||
3148 | cmp al,8 |
||
3149 | je loop_jump_64bit |
||
3150 | or al,al |
||
3151 | jnz invalid_operand_size |
||
3152 | cmp [code_type],16 |
||
3153 | je loop_jump_16bit |
||
3154 | cmp [code_type],64 |
||
3155 | je loop_jump_64bit |
||
3156 | loop_jump_32bit: |
||
109 | heavyiron | 3157 | cmp [code_type],64 |
157 | heavyiron | 3158 | je invalid_operand_size |
3159 | call get_address_dword_value |
||
220 | heavyiron | 3160 | cmp [code_type],16 |
157 | heavyiron | 3161 | jne loop_jump_32bit_prefix_ok |
3162 | mov byte [edi],66h |
||
3163 | inc edi |
||
3164 | loop_jump_32bit_prefix_ok: |
||
109 | heavyiron | 3165 | call loop_counter_size |
872 | heavyiron | 3166 | call calculate_jump_offset |
157 | heavyiron | 3167 | cdq |
3168 | make_loop_jump: |
||
109 | heavyiron | 3169 | call check_for_short_jump |
157 | heavyiron | 3170 | jc conditional_jump_short |
3171 | scas word [edi] |
||
2287 | heavyiron | 3172 | jmp jump_out_of_range |
157 | heavyiron | 3173 | loop_counter_size: |
872 | heavyiron | 3174 | cmp [operand_prefix],0 |
3175 | je loop_counter_size_ok |
||
3176 | push eax |
||
3177 | mov al,[operand_prefix] |
||
3178 | stos byte [edi] |
||
3179 | pop eax |
||
3180 | loop_counter_size_ok: |
||
3181 | ret |
||
3182 | loop_jump_64bit: |
||
109 | heavyiron | 3183 | cmp [code_type],64 |
157 | heavyiron | 3184 | jne invalid_operand_size |
3185 | call get_address_qword_value |
||
220 | heavyiron | 3186 | call loop_counter_size |
1189 | heavyiron | 3187 | call calculate_jump_offset |
157 | heavyiron | 3188 | mov ecx,edx |
3189 | cdq |
||
3190 | cmp edx,ecx |
||
3191 | jne jump_out_of_range |
||
6467 | dunkaist | 3192 | jmp make_loop_jump |
157 | heavyiron | 3193 | loop_jump_16bit: |
109 | heavyiron | 3194 | call get_address_word_value |
220 | heavyiron | 3195 | cmp [code_type],16 |
157 | heavyiron | 3196 | je loop_jump_16bit_prefix_ok |
3197 | mov byte [edi],66h |
||
3198 | inc edi |
||
3199 | loop_jump_16bit_prefix_ok: |
||
109 | heavyiron | 3200 | call loop_counter_size |
872 | heavyiron | 3201 | call calculate_jump_offset |
157 | heavyiron | 3202 | cwde |
3203 | cdq |
||
3204 | jmp make_loop_jump |
||
3205 | |||
31 | halyavin | 3206 | |
3207 | lods byte [esi] |
||
157 | heavyiron | 3208 | call get_size_operator |
3209 | cmp al,'[' |
||
3210 | jne invalid_operand |
||
3211 | call get_address |
||
3212 | or eax,eax |
||
3213 | jnz invalid_address |
||
3214 | or bl,ch |
||
3215 | jnz invalid_address |
||
3216 | cmp [segment_register],1 |
||
3217 | ja invalid_address |
||
3218 | push ebx |
||
3219 | lods byte [esi] |
||
3220 | cmp al,',' |
||
3221 | jne invalid_operand |
||
3222 | lods byte [esi] |
||
3223 | call get_size_operator |
||
3224 | cmp al,'[' |
||
3225 | jne invalid_operand |
||
3226 | call get_address |
||
3227 | pop edx |
||
3228 | or eax,eax |
||
3229 | jnz invalid_address |
||
3230 | or bl,ch |
||
3231 | jnz invalid_address |
||
3232 | mov al,dh |
||
3233 | mov ah,bh |
||
3234 | shr al,4 |
||
3235 | shr ah,4 |
||
3236 | cmp al,ah |
||
3237 | jne address_sizes_do_not_agree |
||
3238 | and bh,111b |
||
3239 | and dh,111b |
||
3240 | cmp bh,6 |
||
3241 | jne invalid_address |
||
3242 | cmp dh,7 |
||
3243 | jne invalid_address |
||
3244 | cmp al,2 |
||
3245 | je movs_address_16bit |
||
3246 | cmp al,4 |
||
3247 | je movs_address_32bit |
||
3248 | cmp [code_type],64 |
||
3249 | jne invalid_address_size |
||
3250 | jmp movs_store |
||
3251 | movs_address_32bit: |
||
31 | halyavin | 3252 | call address_32bit_prefix |
157 | heavyiron | 3253 | jmp movs_store |
3254 | movs_address_16bit: |
||
31 | halyavin | 3255 | cmp [code_type],64 |
157 | heavyiron | 3256 | je invalid_address_size |
3257 | call address_16bit_prefix |
||
3258 | movs_store: |
||
31 | halyavin | 3259 | xor ebx,ebx |
3010 | dunkaist | 3260 | call store_segment_prefix_if_necessary |
3261 | mov al,0A4h |
||
157 | heavyiron | 3262 | movs_check_size: |
1053 | heavyiron | 3263 | mov bl,[operand_size] |
157 | heavyiron | 3264 | cmp bl,1 |
3265 | je simple_instruction |
||
3266 | inc al |
||
3267 | cmp bl,2 |
||
3268 | je simple_instruction_16bit |
||
3269 | cmp bl,4 |
||
3270 | je simple_instruction_32bit |
||
3271 | cmp bl,8 |
||
3272 | je simple_instruction_64bit |
||
3273 | or bl,bl |
||
3274 | jnz invalid_operand_size |
||
1053 | heavyiron | 3275 | call recoverable_unknown_size |
2665 | dunkaist | 3276 | jmp simple_instruction |
1053 | heavyiron | 3277 | lods_instruction: |
31 | halyavin | 3278 | lods byte [esi] |
157 | heavyiron | 3279 | call get_size_operator |
3280 | cmp al,'[' |
||
3281 | jne invalid_operand |
||
3282 | call get_address |
||
3283 | or eax,eax |
||
3284 | jnz invalid_address |
||
3285 | or bl,ch |
||
3286 | jnz invalid_address |
||
3287 | cmp bh,26h |
||
3288 | je lods_address_16bit |
||
3289 | cmp bh,46h |
||
3290 | je lods_address_32bit |
||
3291 | cmp bh,86h |
||
3292 | jne invalid_address |
||
3293 | cmp [code_type],64 |
||
3294 | jne invalid_address_size |
||
3295 | jmp lods_store |
||
3296 | lods_address_32bit: |
||
31 | halyavin | 3297 | call address_32bit_prefix |
157 | heavyiron | 3298 | jmp lods_store |
3299 | lods_address_16bit: |
||
31 | halyavin | 3300 | cmp [code_type],64 |
157 | heavyiron | 3301 | je invalid_address_size |
3302 | call address_16bit_prefix |
||
3303 | lods_store: |
||
31 | halyavin | 3304 | xor ebx,ebx |
3010 | dunkaist | 3305 | call store_segment_prefix_if_necessary |
3306 | mov al,0ACh |
||
157 | heavyiron | 3307 | jmp movs_check_size |
1053 | heavyiron | 3308 | stos_instruction: |
31 | halyavin | 3309 | mov [base_code],al |
157 | heavyiron | 3310 | lods byte [esi] |
3311 | call get_size_operator |
||
3312 | cmp al,'[' |
||
3313 | jne invalid_operand |
||
3314 | call get_address |
||
3315 | or eax,eax |
||
3316 | jnz invalid_address |
||
3317 | or bl,ch |
||
3318 | jnz invalid_address |
||
3319 | cmp bh,27h |
||
3320 | je stos_address_16bit |
||
3321 | cmp bh,47h |
||
3322 | je stos_address_32bit |
||
3323 | cmp bh,87h |
||
3324 | jne invalid_address |
||
3325 | cmp [code_type],64 |
||
3326 | jne invalid_address_size |
||
3327 | jmp stos_store |
||
3328 | stos_address_32bit: |
||
31 | halyavin | 3329 | call address_32bit_prefix |
157 | heavyiron | 3330 | jmp stos_store |
3331 | stos_address_16bit: |
||
31 | halyavin | 3332 | cmp [code_type],64 |
157 | heavyiron | 3333 | je invalid_address_size |
3334 | call address_16bit_prefix |
||
3335 | stos_store: |
||
31 | halyavin | 3336 | cmp [segment_register],1 |
157 | heavyiron | 3337 | ja invalid_address |
3338 | mov al,[base_code] |
||
3339 | jmp movs_check_size |
||
1053 | heavyiron | 3340 | cmps_instruction: |
31 | halyavin | 3341 | lods byte [esi] |
157 | heavyiron | 3342 | call get_size_operator |
3343 | cmp al,'[' |
||
3344 | jne invalid_operand |
||
3345 | call get_address |
||
3346 | or eax,eax |
||
3347 | jnz invalid_address |
||
3348 | or bl,ch |
||
3349 | jnz invalid_address |
||
3350 | mov al,[segment_register] |
||
3351 | push eax ebx |
||
174 | heavyiron | 3352 | lods byte [esi] |
157 | heavyiron | 3353 | cmp al,',' |
3354 | jne invalid_operand |
||
3355 | lods byte [esi] |
||
3356 | call get_size_operator |
||
3357 | cmp al,'[' |
||
3358 | jne invalid_operand |
||
3359 | call get_address |
||
3360 | or eax,eax |
||
3361 | jnz invalid_address |
||
3362 | or bl,ch |
||
3363 | jnz invalid_address |
||
3364 | pop edx eax |
||
174 | heavyiron | 3365 | cmp [segment_register],1 |
157 | heavyiron | 3366 | ja invalid_address |
3367 | mov [segment_register],al |
||
3368 | mov al,dh |
||
3369 | mov ah,bh |
||
3370 | shr al,4 |
||
3371 | shr ah,4 |
||
3372 | cmp al,ah |
||
3373 | jne address_sizes_do_not_agree |
||
3374 | and bh,111b |
||
3375 | and dh,111b |
||
3376 | cmp bh,7 |
||
3377 | jne invalid_address |
||
3378 | cmp dh,6 |
||
3379 | jne invalid_address |
||
3380 | cmp al,2 |
||
3381 | je cmps_address_16bit |
||
3382 | cmp al,4 |
||
3383 | je cmps_address_32bit |
||
3384 | cmp [code_type],64 |
||
3385 | jne invalid_address_size |
||
3386 | jmp cmps_store |
||
3387 | cmps_address_32bit: |
||
31 | halyavin | 3388 | call address_32bit_prefix |
157 | heavyiron | 3389 | jmp cmps_store |
3390 | cmps_address_16bit: |
||
31 | halyavin | 3391 | cmp [code_type],64 |
157 | heavyiron | 3392 | je invalid_address_size |
3393 | call address_16bit_prefix |
||
3394 | cmps_store: |
||
31 | halyavin | 3395 | xor ebx,ebx |
3010 | dunkaist | 3396 | call store_segment_prefix_if_necessary |
3397 | mov al,0A6h |
||
157 | heavyiron | 3398 | jmp movs_check_size |
1053 | heavyiron | 3399 | ins_instruction: |
31 | halyavin | 3400 | lods byte [esi] |
157 | heavyiron | 3401 | call get_size_operator |
3402 | cmp al,'[' |
||
3403 | jne invalid_operand |
||
3404 | call get_address |
||
3405 | or eax,eax |
||
3406 | jnz invalid_address |
||
3407 | or bl,ch |
||
3408 | jnz invalid_address |
||
3409 | cmp bh,27h |
||
3410 | je ins_address_16bit |
||
3411 | cmp bh,47h |
||
3412 | je ins_address_32bit |
||
3413 | cmp bh,87h |
||
3414 | jne invalid_address |
||
3415 | cmp [code_type],64 |
||
3416 | jne invalid_address_size |
||
3417 | jmp ins_store |
||
3418 | ins_address_32bit: |
||
31 | halyavin | 3419 | call address_32bit_prefix |
157 | heavyiron | 3420 | jmp ins_store |
3421 | ins_address_16bit: |
||
31 | halyavin | 3422 | cmp [code_type],64 |
157 | heavyiron | 3423 | je invalid_address_size |
3424 | call address_16bit_prefix |
||
3425 | ins_store: |
||
31 | halyavin | 3426 | cmp [segment_register],1 |
157 | heavyiron | 3427 | ja invalid_address |
3428 | lods byte [esi] |
||
3429 | cmp al,',' |
||
3430 | jne invalid_operand |
||
3431 | lods byte [esi] |
||
3432 | cmp al,10h |
||
3433 | jne invalid_operand |
||
3434 | lods byte [esi] |
||
3435 | cmp al,22h |
||
3436 | jne invalid_operand |
||
3437 | mov al,6Ch |
||
3438 | ins_check_size: |
||
1053 | heavyiron | 3439 | cmp [operand_size],8 |
3440 | jne movs_check_size |
||
3441 | jmp invalid_operand_size |
||
157 | heavyiron | 3442 | outs_instruction: |
31 | halyavin | 3443 | lods byte [esi] |
157 | heavyiron | 3444 | cmp al,10h |
3445 | jne invalid_operand |
||
3446 | lods byte [esi] |
||
3447 | cmp al,22h |
||
3448 | jne invalid_operand |
||
3449 | lods byte [esi] |
||
3450 | cmp al,',' |
||
3451 | jne invalid_operand |
||
3452 | lods byte [esi] |
||
3453 | call get_size_operator |
||
3454 | cmp al,'[' |
||
3455 | jne invalid_operand |
||
3456 | call get_address |
||
3457 | or eax,eax |
||
3458 | jnz invalid_address |
||
3459 | or bl,ch |
||
3460 | jnz invalid_address |
||
3461 | cmp bh,26h |
||
3462 | je outs_address_16bit |
||
3463 | cmp bh,46h |
||
3464 | je outs_address_32bit |
||
3465 | cmp bh,86h |
||
3466 | jne invalid_address |
||
3467 | cmp [code_type],64 |
||
3468 | jne invalid_address_size |
||
3469 | jmp outs_store |
||
3470 | outs_address_32bit: |
||
31 | halyavin | 3471 | call address_32bit_prefix |
157 | heavyiron | 3472 | jmp outs_store |
3473 | outs_address_16bit: |
||
31 | halyavin | 3474 | cmp [code_type],64 |
157 | heavyiron | 3475 | je invalid_address_size |
3476 | call address_16bit_prefix |
||
3477 | outs_store: |
||
31 | halyavin | 3478 | xor ebx,ebx |
3010 | dunkaist | 3479 | call store_segment_prefix_if_necessary |
3480 | mov al,6Eh |
||
157 | heavyiron | 3481 | jmp ins_check_size |
1053 | heavyiron | 3482 | xlat_instruction: |
31 | halyavin | 3483 | lods byte [esi] |
157 | heavyiron | 3484 | call get_size_operator |
3485 | cmp al,'[' |
||
3486 | jne invalid_operand |
||
3487 | call get_address |
||
3488 | or eax,eax |
||
3489 | jnz invalid_address |
||
3490 | or bl,ch |
||
3491 | jnz invalid_address |
||
3492 | cmp bh,23h |
||
3493 | je xlat_address_16bit |
||
3494 | cmp bh,43h |
||
3495 | je xlat_address_32bit |
||
3496 | cmp bh,83h |
||
3497 | jne invalid_address |
||
3498 | cmp [code_type],64 |
||
3499 | jne invalid_address_size |
||
3500 | jmp xlat_store |
||
3501 | xlat_address_32bit: |
||
31 | halyavin | 3502 | call address_32bit_prefix |
157 | heavyiron | 3503 | jmp xlat_store |
3504 | xlat_address_16bit: |
||
31 | halyavin | 3505 | cmp [code_type],64 |
157 | heavyiron | 3506 | je invalid_address_size |
3507 | call address_16bit_prefix |
||
3508 | xlat_store: |
||
31 | halyavin | 3509 | call store_segment_prefix_if_necessary |
157 | heavyiron | 3510 | mov al,0D7h |
3511 | cmp [operand_size],1 |
||
3512 | jbe simple_instruction |
||
3513 | jmp invalid_operand_size |
||
3514 | |||
31 | halyavin | 3515 | |
3516 | mov ah,al |
||
157 | heavyiron | 3517 | shr ah,4 |
3518 | and al,111b |
||
3519 | mov [base_code],0Fh |
||
3520 | mov [extended_code],ah |
||
3521 | mov [postbyte_register],al |
||
3522 | lods byte [esi] |
||
3523 | call get_size_operator |
||
3524 | cmp al,10h |
||
3525 | je pm_reg |
||
3526 | pm_mem: |
||
31 | halyavin | 3527 | cmp al,'[' |
157 | heavyiron | 3528 | jne invalid_operand |
3529 | call get_address |
||
3530 | mov al,[operand_size] |
||
3531 | cmp al,2 |
||
3532 | je pm_mem_store |
||
3533 | or al,al |
||
3534 | jnz invalid_operand_size |
||
3535 | pm_mem_store: |
||
31 | halyavin | 3536 | jmp instruction_ready |
1053 | heavyiron | 3537 | pm_reg: |
31 | halyavin | 3538 | lods byte [esi] |
157 | heavyiron | 3539 | call convert_register |
3540 | mov bl,al |
||
3541 | cmp ah,2 |
||
3542 | jne invalid_operand_size |
||
3543 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 3544 | pm_store_word_instruction: |
31 | halyavin | 3545 | mov ah,al |
157 | heavyiron | 3546 | shr ah,4 |
3547 | and al,111b |
||
3548 | mov [base_code],0Fh |
||
3549 | mov [extended_code],ah |
||
3550 | mov [postbyte_register],al |
||
3551 | lods byte [esi] |
||
3552 | call get_size_operator |
||
3553 | cmp al,10h |
||
3554 | jne pm_mem |
||
3555 | lods byte [esi] |
||
3556 | call convert_register |
||
3557 | mov bl,al |
||
3558 | mov al,ah |
||
3559 | call operand_autodetect |
||
3560 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 3561 | lgdt_instruction: |
31 | halyavin | 3562 | mov [base_code],0Fh |
157 | heavyiron | 3563 | mov [extended_code],1 |
3564 | mov [postbyte_register],al |
||
3565 | lods byte [esi] |
||
3566 | call get_size_operator |
||
3567 | cmp al,'[' |
||
3568 | jne invalid_operand |
||
3569 | call get_address |
||
3570 | mov al,[operand_size] |
||
3571 | cmp al,6 |
||
3572 | je lgdt_mem_48bit |
||
3573 | cmp al,10 |
||
3574 | je lgdt_mem_80bit |
||
3575 | or al,al |
||
3576 | jnz invalid_operand_size |
||
3577 | jmp lgdt_mem_store |
||
3578 | lgdt_mem_80bit: |
||
109 | heavyiron | 3579 | cmp [code_type],64 |
157 | heavyiron | 3580 | jne illegal_instruction |
3581 | jmp lgdt_mem_store |
||
3582 | lgdt_mem_48bit: |
||
31 | halyavin | 3583 | cmp [code_type],64 |
157 | heavyiron | 3584 | je illegal_instruction |
3585 | cmp [postbyte_register],2 |
||
3586 | jb lgdt_mem_store |
||
3587 | call operand_32bit |
||
3588 | lgdt_mem_store: |
||
109 | heavyiron | 3589 | jmp instruction_ready |
1053 | heavyiron | 3590 | lar_instruction: |
31 | halyavin | 3591 | mov [extended_code],al |
157 | heavyiron | 3592 | mov [base_code],0Fh |
3593 | call take_register |
||
6467 | dunkaist | 3594 | mov [postbyte_register],al |
157 | heavyiron | 3595 | lods byte [esi] |
3596 | cmp al,',' |
||
3597 | jne invalid_operand |
||
3598 | xor al,al |
||
3599 | xchg al,[operand_size] |
||
3600 | call operand_autodetect |
||
3601 | lods byte [esi] |
||
3602 | call get_size_operator |
||
3603 | cmp al,10h |
||
3604 | je lar_reg_reg |
||
3605 | cmp al,'[' |
||
3606 | jne invalid_operand |
||
3607 | call get_address |
||
3608 | mov al,[operand_size] |
||
3609 | or al,al |
||
3610 | jz lar_reg_mem |
||
3611 | cmp al,2 |
||
3612 | jne invalid_operand_size |
||
3613 | lar_reg_mem: |
||
31 | halyavin | 3614 | jmp instruction_ready |
1053 | heavyiron | 3615 | lar_reg_reg: |
31 | halyavin | 3616 | lods byte [esi] |
157 | heavyiron | 3617 | call convert_register |
3618 | cmp ah,2 |
||
3619 | jne invalid_operand_size |
||
3620 | mov bl,al |
||
3621 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 3622 | invlpg_instruction: |
31 | halyavin | 3623 | mov [base_code],0Fh |
157 | heavyiron | 3624 | mov [extended_code],1 |
3625 | mov [postbyte_register],7 |
||
3626 | lods byte [esi] |
||
3627 | call get_size_operator |
||
3628 | cmp al,'[' |
||
3629 | jne invalid_operand |
||
3630 | call get_address |
||
3631 | jmp instruction_ready |
||
1053 | heavyiron | 3632 | swapgs_instruction: |
31 | halyavin | 3633 | cmp [code_type],64 |
2287 | heavyiron | 3634 | jne illegal_instruction |
3635 | simple_instruction_0f_01: |
||
6467 | dunkaist | 3636 | mov ah,al |
3637 | mov al,0Fh |
||
3638 | stos byte [edi] |
||
3639 | mov al,1 |
||
3640 | stos word [edi] |
||
3641 | jmp instruction_assembled |
||
3642 | |||
31 | halyavin | 3643 | |
3644 | mov [base_code],0Fh |
||
157 | heavyiron | 3645 | mov [extended_code],al |
3646 | lods byte [esi] |
||
3647 | call get_size_operator |
||
3648 | cmp al,10h |
||
3649 | je basic_486_reg |
||
3650 | cmp al,'[' |
||
3651 | jne invalid_operand |
||
3652 | call get_address |
||
3653 | push edx ebx ecx |
||
174 | heavyiron | 3654 | lods byte [esi] |
157 | heavyiron | 3655 | cmp al,',' |
3656 | jne invalid_operand |
||
3657 | call take_register |
||
6467 | dunkaist | 3658 | mov [postbyte_register],al |
157 | heavyiron | 3659 | pop ecx ebx edx |
174 | heavyiron | 3660 | mov al,ah |
157 | heavyiron | 3661 | cmp al,1 |
3662 | je basic_486_mem_reg_8bit |
||
3663 | call operand_autodetect |
||
3664 | inc [extended_code] |
||
3665 | basic_486_mem_reg_8bit: |
||
31 | halyavin | 3666 | jmp instruction_ready |
1053 | heavyiron | 3667 | basic_486_reg: |
31 | halyavin | 3668 | lods byte [esi] |
157 | heavyiron | 3669 | call convert_register |
3670 | mov [postbyte_register],al |
||
3671 | lods byte [esi] |
||
3672 | cmp al,',' |
||
3673 | jne invalid_operand |
||
3674 | call take_register |
||
6467 | dunkaist | 3675 | mov bl,[postbyte_register] |
157 | heavyiron | 3676 | mov [postbyte_register],al |
3677 | mov al,ah |
||
3678 | cmp al,1 |
||
3679 | je basic_486_reg_reg_8bit |
||
3680 | call operand_autodetect |
||
3681 | inc [extended_code] |
||
3682 | basic_486_reg_reg_8bit: |
||
31 | halyavin | 3683 | jmp nomem_instruction_ready |
1053 | heavyiron | 3684 | bswap_instruction: |
31 | halyavin | 3685 | call take_register |
6467 | dunkaist | 3686 | test al,1000b |
157 | heavyiron | 3687 | jz bswap_reg_code_ok |
3688 | or [rex_prefix],41h |
||
3689 | and al,111b |
||
3690 | bswap_reg_code_ok: |
||
109 | heavyiron | 3691 | add al,0C8h |
157 | heavyiron | 3692 | mov [extended_code],al |
3693 | mov [base_code],0Fh |
||
3694 | cmp ah,8 |
||
3695 | je bswap_reg64 |
||
3696 | cmp ah,4 |
||
3697 | jne invalid_operand_size |
||
3698 | call operand_32bit |
||
3699 | call store_classic_instruction_code |
||
6467 | dunkaist | 3700 | jmp instruction_assembled |
157 | heavyiron | 3701 | bswap_reg64: |
31 | halyavin | 3702 | call operand_64bit |
157 | heavyiron | 3703 | call store_classic_instruction_code |
6467 | dunkaist | 3704 | jmp instruction_assembled |
157 | heavyiron | 3705 | cmpxchgx_instruction: |
31 | halyavin | 3706 | mov [base_code],0Fh |
157 | heavyiron | 3707 | mov [extended_code],0C7h |
3708 | mov [postbyte_register],al |
||
3709 | lods byte [esi] |
||
3710 | call get_size_operator |
||
3711 | cmp al,'[' |
||
3712 | jne invalid_operand |
||
3713 | call get_address |
||
3714 | mov ah,1 |
||
3715 | xchg [postbyte_register],ah |
||
3716 | mov al,[operand_size] |
||
3717 | or al,al |
||
3718 | jz cmpxchgx_size_ok |
||
3719 | cmp al,ah |
||
3720 | jne invalid_operand_size |
||
3721 | cmpxchgx_size_ok: |
||
31 | halyavin | 3722 | cmp ah,16 |
157 | heavyiron | 3723 | jne cmpxchgx_store |
3724 | call operand_64bit |
||
3725 | cmpxchgx_store: |
||
31 | halyavin | 3726 | jmp instruction_ready |
1053 | heavyiron | 3727 | nop_instruction: |
174 | heavyiron | 3728 | mov ah,[esi] |
3729 | cmp ah,10h |
||
3730 | je extended_nop |
||
3731 | cmp ah,11h |
||
3732 | je extended_nop |
||
3733 | cmp ah,'[' |
||
3734 | je extended_nop |
||
3735 | stos byte [edi] |
||
3736 | jmp instruction_assembled |
||
3737 | extended_nop: |
||
3738 | mov [base_code],0Fh |
||
3739 | mov [extended_code],1Fh |
||
3740 | mov [postbyte_register],0 |
||
3741 | lods byte [esi] |
||
3742 | call get_size_operator |
||
3743 | cmp al,10h |
||
3744 | je extended_nop_reg |
||
3745 | cmp al,'[' |
||
3746 | jne invalid_operand |
||
3747 | call get_address |
||
3748 | mov al,[operand_size] |
||
3749 | or al,al |
||
3750 | jz extended_nop_store |
||
1039 | heavyiron | 3751 | call operand_autodetect |
174 | heavyiron | 3752 | extended_nop_store: |
3753 | jmp instruction_ready |
||
1053 | heavyiron | 3754 | extended_nop_reg: |
174 | heavyiron | 3755 | lods byte [esi] |
3756 | call convert_register |
||
3757 | mov bl,al |
||
3758 | mov al,ah |
||
3759 | call operand_autodetect |
||
3760 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 3761 | |
31 | halyavin | 3762 | |
3763 | mov [postbyte_register],al |
||
157 | heavyiron | 3764 | mov [base_code],0D8h |
3765 | lods byte [esi] |
||
3766 | call get_size_operator |
||
3767 | cmp al,10h |
||
3768 | je basic_fpu_streg |
||
3769 | cmp al,'[' |
||
3770 | je basic_fpu_mem |
||
3771 | dec esi |
||
3772 | mov ah,[postbyte_register] |
||
3773 | cmp ah,2 |
||
3774 | jb invalid_operand |
||
3775 | cmp ah,3 |
||
3776 | ja invalid_operand |
||
3777 | mov bl,1 |
||
3778 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 3779 | basic_fpu_mem: |
31 | halyavin | 3780 | call get_address |
157 | heavyiron | 3781 | mov al,[operand_size] |
3782 | cmp al,4 |
||
3783 | je basic_fpu_mem_32bit |
||
3784 | cmp al,8 |
||
3785 | je basic_fpu_mem_64bit |
||
3786 | or al,al |
||
3787 | jnz invalid_operand_size |
||
3788 | call recoverable_unknown_size |
||
2665 | dunkaist | 3789 | basic_fpu_mem_32bit: |
31 | halyavin | 3790 | jmp instruction_ready |
1053 | heavyiron | 3791 | basic_fpu_mem_64bit: |
31 | halyavin | 3792 | mov [base_code],0DCh |
157 | heavyiron | 3793 | jmp instruction_ready |
1053 | heavyiron | 3794 | basic_fpu_streg: |
31 | halyavin | 3795 | lods byte [esi] |
157 | heavyiron | 3796 | call convert_fpu_register |
3797 | mov bl,al |
||
3798 | mov ah,[postbyte_register] |
||
3799 | cmp ah,2 |
||
3800 | je basic_fpu_single_streg |
||
3801 | cmp ah,3 |
||
3802 | je basic_fpu_single_streg |
||
3803 | or al,al |
||
3804 | jz basic_fpu_st0 |
||
3805 | test ah,110b |
||
3806 | jz basic_fpu_streg_st0 |
||
3807 | xor [postbyte_register],1 |
||
3808 | basic_fpu_streg_st0: |
||
31 | halyavin | 3809 | lods byte [esi] |
157 | heavyiron | 3810 | cmp al,',' |
3811 | jne invalid_operand |
||
3812 | lods byte [esi] |
||
3813 | call get_size_operator |
||
3814 | cmp al,10h |
||
3815 | jne invalid_operand |
||
3816 | lods byte [esi] |
||
3817 | call convert_fpu_register |
||
3818 | or al,al |
||
3819 | jnz invalid_operand |
||
3820 | mov [base_code],0DCh |
||
3821 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 3822 | basic_fpu_st0: |
31 | halyavin | 3823 | lods byte [esi] |
157 | heavyiron | 3824 | cmp al,',' |
3825 | jne invalid_operand |
||
3826 | lods byte [esi] |
||
3827 | call get_size_operator |
||
3828 | cmp al,10h |
||
3829 | jne invalid_operand |
||
3830 | lods byte [esi] |
||
3831 | call convert_fpu_register |
||
3832 | mov bl,al |
||
3833 | basic_fpu_single_streg: |
||
31 | halyavin | 3834 | mov [base_code],0D8h |
157 | heavyiron | 3835 | jmp nomem_instruction_ready |
1053 | heavyiron | 3836 | simple_fpu_instruction: |
31 | halyavin | 3837 | mov ah,al |
157 | heavyiron | 3838 | or ah,11000000b |
3839 | mov al,0D9h |
||
3840 | stos word [edi] |
||
3841 | jmp instruction_assembled |
||
3842 | fi_instruction: |
||
31 | halyavin | 3843 | mov [postbyte_register],al |
157 | heavyiron | 3844 | lods byte [esi] |
3845 | call get_size_operator |
||
3846 | cmp al,'[' |
||
3847 | jne invalid_operand |
||
3848 | call get_address |
||
3849 | mov al,[operand_size] |
||
3850 | cmp al,2 |
||
3851 | je fi_mem_16bit |
||
3852 | cmp al,4 |
||
3853 | je fi_mem_32bit |
||
3854 | or al,al |
||
3855 | jnz invalid_operand_size |
||
3856 | call recoverable_unknown_size |
||
2665 | dunkaist | 3857 | fi_mem_32bit: |
31 | halyavin | 3858 | mov [base_code],0DAh |
157 | heavyiron | 3859 | jmp instruction_ready |
1053 | heavyiron | 3860 | fi_mem_16bit: |
31 | halyavin | 3861 | mov [base_code],0DEh |
157 | heavyiron | 3862 | jmp instruction_ready |
1053 | heavyiron | 3863 | fld_instruction: |
31 | halyavin | 3864 | mov [postbyte_register],al |
157 | heavyiron | 3865 | lods byte [esi] |
3866 | call get_size_operator |
||
3867 | cmp al,10h |
||
3868 | je fld_streg |
||
3869 | cmp al,'[' |
||
3870 | jne invalid_operand |
||
3871 | call get_address |
||
3872 | mov al,[operand_size] |
||
3873 | cmp al,4 |
||
3874 | je fld_mem_32bit |
||
3875 | cmp al,8 |
||
3876 | je fld_mem_64bit |
||
3877 | cmp al,10 |
||
3878 | je fld_mem_80bit |
||
3879 | or al,al |
||
3880 | jnz invalid_operand_size |
||
3881 | call recoverable_unknown_size |
||
2665 | dunkaist | 3882 | fld_mem_32bit: |
31 | halyavin | 3883 | mov [base_code],0D9h |
157 | heavyiron | 3884 | jmp instruction_ready |
1053 | heavyiron | 3885 | fld_mem_64bit: |
31 | halyavin | 3886 | mov [base_code],0DDh |
157 | heavyiron | 3887 | jmp instruction_ready |
1053 | heavyiron | 3888 | fld_mem_80bit: |
31 | halyavin | 3889 | mov al,[postbyte_register] |
157 | heavyiron | 3890 | cmp al,0 |
3891 | je fld_mem_80bit_store |
||
3892 | dec [postbyte_register] |
||
3893 | cmp al,3 |
||
3894 | je fld_mem_80bit_store |
||
3895 | jmp invalid_operand_size |
||
3896 | fld_mem_80bit_store: |
||
31 | halyavin | 3897 | add [postbyte_register],5 |
157 | heavyiron | 3898 | mov [base_code],0DBh |
3899 | jmp instruction_ready |
||
1053 | heavyiron | 3900 | fld_streg: |
31 | halyavin | 3901 | lods byte [esi] |
157 | heavyiron | 3902 | call convert_fpu_register |
3903 | mov bl,al |
||
3904 | cmp [postbyte_register],2 |
||
3905 | jae fst_streg |
||
3906 | mov [base_code],0D9h |
||
3907 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 3908 | fst_streg: |
31 | halyavin | 3909 | mov [base_code],0DDh |
157 | heavyiron | 3910 | jmp nomem_instruction_ready |
1053 | heavyiron | 3911 | fild_instruction: |
31 | halyavin | 3912 | mov [postbyte_register],al |
157 | heavyiron | 3913 | lods byte [esi] |
3914 | call get_size_operator |
||
3915 | cmp al,'[' |
||
3916 | jne invalid_operand |
||
3917 | call get_address |
||
3918 | mov al,[operand_size] |
||
3919 | cmp al,2 |
||
3920 | je fild_mem_16bit |
||
3921 | cmp al,4 |
||
3922 | je fild_mem_32bit |
||
3923 | cmp al,8 |
||
3924 | je fild_mem_64bit |
||
3925 | or al,al |
||
3926 | jnz invalid_operand_size |
||
3927 | call recoverable_unknown_size |
||
2665 | dunkaist | 3928 | fild_mem_32bit: |
31 | halyavin | 3929 | mov [base_code],0DBh |
157 | heavyiron | 3930 | jmp instruction_ready |
1053 | heavyiron | 3931 | fild_mem_16bit: |
31 | halyavin | 3932 | mov [base_code],0DFh |
157 | heavyiron | 3933 | jmp instruction_ready |
1053 | heavyiron | 3934 | fild_mem_64bit: |
31 | halyavin | 3935 | mov al,[postbyte_register] |
157 | heavyiron | 3936 | cmp al,1 |
3937 | je fisttp_64bit_store |
||
3938 | jb fild_mem_64bit_store |
||
3939 | dec [postbyte_register] |
||
3940 | cmp al,3 |
||
3941 | je fild_mem_64bit_store |
||
3942 | jmp invalid_operand_size |
||
3943 | fild_mem_64bit_store: |
||
31 | halyavin | 3944 | add [postbyte_register],5 |
157 | heavyiron | 3945 | mov [base_code],0DFh |
3946 | jmp instruction_ready |
||
1053 | heavyiron | 3947 | fisttp_64bit_store: |
31 | halyavin | 3948 | mov [base_code],0DDh |
157 | heavyiron | 3949 | jmp instruction_ready |
1053 | heavyiron | 3950 | fbld_instruction: |
31 | halyavin | 3951 | mov [postbyte_register],al |
157 | heavyiron | 3952 | lods byte [esi] |
3953 | call get_size_operator |
||
3954 | cmp al,'[' |
||
3955 | jne invalid_operand |
||
3956 | call get_address |
||
3957 | mov al,[operand_size] |
||
3958 | or al,al |
||
3959 | jz fbld_mem_80bit |
||
3960 | cmp al,10 |
||
3961 | je fbld_mem_80bit |
||
3962 | jmp invalid_operand_size |
||
3963 | fbld_mem_80bit: |
||
31 | halyavin | 3964 | mov [base_code],0DFh |
157 | heavyiron | 3965 | jmp instruction_ready |
1053 | heavyiron | 3966 | faddp_instruction: |
31 | halyavin | 3967 | mov [postbyte_register],al |
157 | heavyiron | 3968 | mov [base_code],0DEh |
3969 | mov edx,esi |
||
3970 | lods byte [esi] |
||
3971 | call get_size_operator |
||
3972 | cmp al,10h |
||
3973 | je faddp_streg |
||
3974 | mov esi,edx |
||
3975 | mov bl,1 |
||
3976 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 3977 | faddp_streg: |
31 | halyavin | 3978 | lods byte [esi] |
157 | heavyiron | 3979 | call convert_fpu_register |
3980 | mov bl,al |
||
3981 | lods byte [esi] |
||
3982 | cmp al,',' |
||
3983 | jne invalid_operand |
||
3984 | lods byte [esi] |
||
3985 | call get_size_operator |
||
3986 | cmp al,10h |
||
3987 | jne invalid_operand |
||
3988 | lods byte [esi] |
||
3989 | call convert_fpu_register |
||
3990 | or al,al |
||
3991 | jnz invalid_operand |
||
3992 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 3993 | fcompp_instruction: |
31 | halyavin | 3994 | mov ax,0D9DEh |
157 | heavyiron | 3995 | stos word [edi] |
3996 | jmp instruction_assembled |
||
3997 | fucompp_instruction: |
||
31 | halyavin | 3998 | mov ax,0E9DAh |
157 | heavyiron | 3999 | stos word [edi] |
4000 | jmp instruction_assembled |
||
4001 | fxch_instruction: |
||
31 | halyavin | 4002 | mov dx,01D9h |
157 | heavyiron | 4003 | jmp fpu_single_operand |
4004 | ffreep_instruction: |
||
31 | halyavin | 4005 | mov dx,00DFh |
157 | heavyiron | 4006 | jmp fpu_single_operand |
4007 | ffree_instruction: |
||
31 | halyavin | 4008 | mov dl,0DDh |
157 | heavyiron | 4009 | mov dh,al |
4010 | fpu_single_operand: |
||
31 | halyavin | 4011 | mov ebx,esi |
157 | heavyiron | 4012 | lods byte [esi] |
4013 | call get_size_operator |
||
4014 | cmp al,10h |
||
4015 | je fpu_streg |
||
4016 | or dh,dh |
||
4017 | jz invalid_operand |
||
4018 | mov esi,ebx |
||
4019 | shl dh,3 |
||
4020 | or dh,11000001b |
||
4021 | mov ax,dx |
||
4022 | stos word [edi] |
||
4023 | jmp instruction_assembled |
||
4024 | fpu_streg: |
||
31 | halyavin | 4025 | lods byte [esi] |
157 | heavyiron | 4026 | call convert_fpu_register |
4027 | shl dh,3 |
||
4028 | or dh,al |
||
4029 | or dh,11000000b |
||
4030 | mov ax,dx |
||
4031 | stos word [edi] |
||
4032 | jmp instruction_assembled |
||
4033 | |||
1039 | heavyiron | 4034 | |
31 | halyavin | 4035 | mov byte [edi],9Bh |
157 | heavyiron | 4036 | inc edi |
4037 | fldenv_instruction: |
||
31 | halyavin | 4038 | mov [base_code],0D9h |
157 | heavyiron | 4039 | jmp fpu_mem |
4040 | fstenv_instruction_16bit: |
||
1039 | heavyiron | 4041 | mov byte [edi],9Bh |
4042 | inc edi |
||
4043 | fldenv_instruction_16bit: |
||
4044 | call operand_16bit |
||
4045 | jmp fldenv_instruction |
||
4046 | fstenv_instruction_32bit: |
||
4047 | mov byte [edi],9Bh |
||
4048 | inc edi |
||
4049 | fldenv_instruction_32bit: |
||
4050 | call operand_32bit |
||
4051 | jmp fldenv_instruction |
||
4052 | fsave_instruction_32bit: |
||
4053 | mov byte [edi],9Bh |
||
4054 | inc edi |
||
4055 | fnsave_instruction_32bit: |
||
4056 | call operand_32bit |
||
4057 | jmp fnsave_instruction |
||
4058 | fsave_instruction_16bit: |
||
4059 | mov byte [edi],9Bh |
||
4060 | inc edi |
||
4061 | fnsave_instruction_16bit: |
||
4062 | call operand_16bit |
||
4063 | jmp fnsave_instruction |
||
4064 | fsave_instruction: |
||
31 | halyavin | 4065 | mov byte [edi],9Bh |
157 | heavyiron | 4066 | inc edi |
4067 | fnsave_instruction: |
||
31 | halyavin | 4068 | mov [base_code],0DDh |
157 | heavyiron | 4069 | fpu_mem: |
31 | halyavin | 4070 | mov [postbyte_register],al |
157 | heavyiron | 4071 | lods byte [esi] |
4072 | call get_size_operator |
||
4073 | cmp al,'[' |
||
4074 | jne invalid_operand |
||
4075 | call get_address |
||
4076 | cmp [operand_size],0 |
||
4077 | jne invalid_operand_size |
||
4078 | jmp instruction_ready |
||
1053 | heavyiron | 4079 | fstcw_instruction: |
31 | halyavin | 4080 | mov byte [edi],9Bh |
157 | heavyiron | 4081 | inc edi |
4082 | fldcw_instruction: |
||
31 | halyavin | 4083 | mov [postbyte_register],al |
157 | heavyiron | 4084 | mov [base_code],0D9h |
4085 | lods byte [esi] |
||
4086 | call get_size_operator |
||
4087 | cmp al,'[' |
||
4088 | jne invalid_operand |
||
4089 | call get_address |
||
4090 | mov al,[operand_size] |
||
4091 | or al,al |
||
4092 | jz fldcw_mem_16bit |
||
4093 | cmp al,2 |
||
4094 | je fldcw_mem_16bit |
||
4095 | jmp invalid_operand_size |
||
4096 | fldcw_mem_16bit: |
||
31 | halyavin | 4097 | jmp instruction_ready |
1053 | heavyiron | 4098 | fstsw_instruction: |
31 | halyavin | 4099 | mov al,9Bh |
157 | heavyiron | 4100 | stos byte [edi] |
4101 | fnstsw_instruction: |
||
31 | halyavin | 4102 | mov [base_code],0DDh |
157 | heavyiron | 4103 | mov [postbyte_register],7 |
4104 | lods byte [esi] |
||
4105 | call get_size_operator |
||
4106 | cmp al,10h |
||
4107 | je fstsw_reg |
||
4108 | cmp al,'[' |
||
4109 | jne invalid_operand |
||
4110 | call get_address |
||
4111 | mov al,[operand_size] |
||
4112 | or al,al |
||
4113 | jz fstsw_mem_16bit |
||
4114 | cmp al,2 |
||
4115 | je fstsw_mem_16bit |
||
4116 | jmp invalid_operand_size |
||
4117 | fstsw_mem_16bit: |
||
31 | halyavin | 4118 | jmp instruction_ready |
1053 | heavyiron | 4119 | fstsw_reg: |
31 | halyavin | 4120 | lods byte [esi] |
157 | heavyiron | 4121 | call convert_register |
4122 | cmp ax,0200h |
||
4123 | jne invalid_operand |
||
4124 | mov ax,0E0DFh |
||
4125 | stos word [edi] |
||
4126 | jmp instruction_assembled |
||
4127 | finit_instruction: |
||
31 | halyavin | 4128 | mov byte [edi],9Bh |
157 | heavyiron | 4129 | inc edi |
4130 | fninit_instruction: |
||
31 | halyavin | 4131 | mov ah,al |
157 | heavyiron | 4132 | mov al,0DBh |
4133 | stos word [edi] |
||
4134 | jmp instruction_assembled |
||
4135 | fcmov_instruction: |
||
31 | halyavin | 4136 | mov dh,0DAh |
157 | heavyiron | 4137 | jmp fcomi_streg |
4138 | fcomi_instruction: |
||
31 | halyavin | 4139 | mov dh,0DBh |
157 | heavyiron | 4140 | jmp fcomi_streg |
4141 | fcomip_instruction: |
||
31 | halyavin | 4142 | mov dh,0DFh |
157 | heavyiron | 4143 | fcomi_streg: |
31 | halyavin | 4144 | mov dl,al |
157 | heavyiron | 4145 | lods byte [esi] |
4146 | call get_size_operator |
||
4147 | cmp al,10h |
||
4148 | jne invalid_operand |
||
4149 | lods byte [esi] |
||
4150 | call convert_fpu_register |
||
4151 | mov ah,al |
||
4152 | cmp byte [esi],',' |
||
4153 | je fcomi_st0_streg |
||
4154 | add ah,dl |
||
4155 | mov al,dh |
||
4156 | stos word [edi] |
||
4157 | jmp instruction_assembled |
||
4158 | fcomi_st0_streg: |
||
31 | halyavin | 4159 | or ah,ah |
157 | heavyiron | 4160 | jnz invalid_operand |
4161 | inc esi |
||
4162 | lods byte [esi] |
||
4163 | call get_size_operator |
||
4164 | cmp al,10h |
||
4165 | jne invalid_operand |
||
4166 | lods byte [esi] |
||
4167 | call convert_fpu_register |
||
4168 | mov ah,al |
||
4169 | add ah,dl |
||
4170 | mov al,dh |
||
4171 | stos word [edi] |
||
4172 | jmp instruction_assembled |
||
4173 | |||
31 | halyavin | 4174 | |
174 | heavyiron | 4175 | mov [base_code],0Fh |
157 | heavyiron | 4176 | mov [extended_code],al |
4177 | mmx_instruction: |
||
174 | heavyiron | 4178 | lods byte [esi] |
157 | heavyiron | 4179 | call get_size_operator |
4180 | cmp al,10h |
||
4181 | jne invalid_operand |
||
4182 | lods byte [esi] |
||
4183 | call convert_mmx_register |
||
4184 | call make_mmx_prefix |
||
4185 | mov [postbyte_register],al |
||
4186 | lods byte [esi] |
||
4187 | cmp al,',' |
||
4188 | jne invalid_operand |
||
4189 | lods byte [esi] |
||
4190 | call get_size_operator |
||
4191 | cmp al,10h |
||
4192 | je mmx_mmreg_mmreg |
||
4193 | cmp al,'[' |
||
4194 | jne invalid_operand |
||
4195 | mmx_mmreg_mem: |
||
31 | halyavin | 4196 | call get_address |
157 | heavyiron | 4197 | jmp instruction_ready |
1053 | heavyiron | 4198 | mmx_mmreg_mmreg: |
31 | halyavin | 4199 | lods byte [esi] |
157 | heavyiron | 4200 | call convert_mmx_register |
4201 | mov bl,al |
||
4202 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 4203 | mmx_bit_shift_instruction: |
2287 | heavyiron | 4204 | mov [base_code],0Fh |
157 | heavyiron | 4205 | mov [extended_code],al |
4206 | lods byte [esi] |
||
4207 | call get_size_operator |
||
4208 | cmp al,10h |
||
4209 | jne invalid_operand |
||
4210 | lods byte [esi] |
||
4211 | call convert_mmx_register |
||
4212 | call make_mmx_prefix |
||
4213 | mov [postbyte_register],al |
||
4214 | lods byte [esi] |
||
4215 | cmp al,',' |
||
4216 | jne invalid_operand |
||
4217 | mov [operand_size],0 |
||
4218 | lods byte [esi] |
||
4219 | call get_size_operator |
||
4220 | cmp al,10h |
||
4221 | je mmx_mmreg_mmreg |
||
4222 | cmp al,'(' |
||
4223 | je mmx_ps_mmreg_imm8 |
||
4224 | cmp al,'[' |
||
4225 | je mmx_mmreg_mem |
||
4226 | jmp invalid_operand |
||
4227 | mmx_ps_mmreg_imm8: |
||
31 | halyavin | 4228 | call get_byte_value |
157 | heavyiron | 4229 | mov byte [value],al |
4230 | test [operand_size],not 1 |
||
4231 | jnz invalid_value |
||
4232 | mov bl,[extended_code] |
||
4233 | mov al,bl |
||
4234 | shr bl,4 |
||
4235 | and al,1111b |
||
4236 | add al,70h |
||
4237 | mov [extended_code],al |
||
4238 | sub bl,0Ch |
||
4239 | shl bl,1 |
||
4240 | xchg bl,[postbyte_register] |
||
4241 | call store_nomem_instruction |
||
4242 | mov al,byte [value] |
||
4243 | stos byte [edi] |
||
4244 | jmp instruction_assembled |
||
4245 | pmovmskb_instruction: |
||
1039 | heavyiron | 4246 | mov [base_code],0Fh |
157 | heavyiron | 4247 | mov [extended_code],al |
4248 | call take_register |
||
6467 | dunkaist | 4249 | cmp ah,4 |
157 | heavyiron | 4250 | je pmovmskb_reg_size_ok |
1342 | heavyiron | 4251 | cmp [code_type],64 |
4252 | jne invalid_operand_size |
||
4253 | cmp ah,8 |
||
4254 | jnz invalid_operand_size |
||
157 | heavyiron | 4255 | pmovmskb_reg_size_ok: |
1342 | heavyiron | 4256 | mov [postbyte_register],al |
157 | heavyiron | 4257 | mov [operand_size],0 |
4258 | lods byte [esi] |
||
4259 | cmp al,',' |
||
4260 | jne invalid_operand |
||
4261 | lods byte [esi] |
||
4262 | call get_size_operator |
||
4263 | cmp al,10h |
||
4264 | jne invalid_operand |
||
4265 | lods byte [esi] |
||
4266 | call convert_mmx_register |
||
4267 | mov bl,al |
||
4268 | call make_mmx_prefix |
||
4269 | cmp [extended_code],0C5h |
||
4270 | je mmx_nomem_imm8 |
||
4271 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 4272 | mmx_imm8: |
31 | halyavin | 4273 | push ebx ecx edx |
174 | heavyiron | 4274 | xor cl,cl |
2287 | heavyiron | 4275 | xchg cl,[operand_size] |
4276 | lods byte [esi] |
||
157 | heavyiron | 4277 | cmp al,',' |
4278 | jne invalid_operand |
||
4279 | lods byte [esi] |
||
4280 | call get_size_operator |
||
4281 | test ah,not 1 |
||
4282 | jnz invalid_operand_size |
||
4283 | mov [operand_size],cl |
||
2287 | heavyiron | 4284 | cmp al,'(' |
157 | heavyiron | 4285 | jne invalid_operand |
4286 | call get_byte_value |
||
4287 | mov byte [value],al |
||
4288 | pop edx ecx ebx |
||
174 | heavyiron | 4289 | call store_instruction_with_imm8 |
157 | heavyiron | 4290 | jmp instruction_assembled |
4291 | mmx_nomem_imm8: |
||
31 | halyavin | 4292 | call store_nomem_instruction |
157 | heavyiron | 4293 | call append_imm8 |
1039 | heavyiron | 4294 | jmp instruction_assembled |
4295 | append_imm8: |
||
4296 | mov [operand_size],0 |
||
157 | heavyiron | 4297 | lods byte [esi] |
4298 | cmp al,',' |
||
4299 | jne invalid_operand |
||
4300 | lods byte [esi] |
||
4301 | call get_size_operator |
||
4302 | test ah,not 1 |
||
4303 | jnz invalid_operand_size |
||
4304 | cmp al,'(' |
||
4305 | jne invalid_operand |
||
4306 | call get_byte_value |
||
4307 | stosb |
||
4308 | ret |
||
1039 | heavyiron | 4309 | pinsrw_instruction: |
31 | halyavin | 4310 | mov [extended_code],al |
157 | heavyiron | 4311 | mov [base_code],0Fh |
4312 | lods byte [esi] |
||
4313 | call get_size_operator |
||
4314 | cmp al,10h |
||
4315 | jne invalid_operand |
||
4316 | lods byte [esi] |
||
4317 | call convert_mmx_register |
||
4318 | call make_mmx_prefix |
||
4319 | mov [postbyte_register],al |
||
4320 | mov [operand_size],0 |
||
4321 | lods byte [esi] |
||
4322 | cmp al,',' |
||
4323 | jne invalid_operand |
||
4324 | lods byte [esi] |
||
4325 | call get_size_operator |
||
4326 | cmp al,10h |
||
4327 | je pinsrw_mmreg_reg |
||
4328 | cmp al,'[' |
||
4329 | jne invalid_operand |
||
4330 | call get_address |
||
4331 | cmp [operand_size],0 |
||
4332 | je mmx_imm8 |
||
4333 | cmp [operand_size],2 |
||
4334 | jne invalid_operand_size |
||
4335 | jmp mmx_imm8 |
||
4336 | pinsrw_mmreg_reg: |
||
31 | halyavin | 4337 | lods byte [esi] |
157 | heavyiron | 4338 | call convert_register |
4339 | cmp ah,4 |
||
4340 | jne invalid_operand_size |
||
4341 | mov bl,al |
||
4342 | jmp mmx_nomem_imm8 |
||
4343 | pshufw_instruction: |
||
31 | halyavin | 4344 | mov [mmx_size],8 |
157 | heavyiron | 4345 | mov [opcode_prefix],al |
1039 | heavyiron | 4346 | jmp pshuf_instruction |
157 | heavyiron | 4347 | pshufd_instruction: |
31 | halyavin | 4348 | mov [mmx_size],16 |
157 | heavyiron | 4349 | mov [opcode_prefix],al |
1039 | heavyiron | 4350 | pshuf_instruction: |
31 | halyavin | 4351 | mov [base_code],0Fh |
157 | heavyiron | 4352 | mov [extended_code],70h |
4353 | lods byte [esi] |
||
4354 | call get_size_operator |
||
4355 | cmp al,10h |
||
4356 | jne invalid_operand |
||
4357 | lods byte [esi] |
||
4358 | call convert_mmx_register |
||
4359 | cmp ah,[mmx_size] |
||
4360 | jne invalid_operand_size |
||
4361 | mov [postbyte_register],al |
||
4362 | lods byte [esi] |
||
4363 | cmp al,',' |
||
4364 | jne invalid_operand |
||
4365 | lods byte [esi] |
||
4366 | call get_size_operator |
||
4367 | cmp al,10h |
||
4368 | je pshuf_mmreg_mmreg |
||
4369 | cmp al,'[' |
||
4370 | jne invalid_operand |
||
4371 | call get_address |
||
4372 | jmp mmx_imm8 |
||
4373 | pshuf_mmreg_mmreg: |
||
31 | halyavin | 4374 | lods byte [esi] |
157 | heavyiron | 4375 | call convert_mmx_register |
4376 | mov bl,al |
||
4377 | jmp mmx_nomem_imm8 |
||
4378 | movd_instruction: |
||
31 | halyavin | 4379 | mov [base_code],0Fh |
157 | heavyiron | 4380 | mov [extended_code],7Eh |
4381 | lods byte [esi] |
||
4382 | call get_size_operator |
||
4383 | cmp al,10h |
||
4384 | je movd_reg |
||
4385 | cmp al,'[' |
||
4386 | jne invalid_operand |
||
4387 | call get_address |
||
4388 | test [operand_size],not 4 |
||
4389 | jnz invalid_operand_size |
||
4390 | call get_mmx_source_register |
||
6467 | dunkaist | 4391 | jmp instruction_ready |
1053 | heavyiron | 4392 | movd_reg: |
31 | halyavin | 4393 | lods byte [esi] |
157 | heavyiron | 4394 | cmp al,0B0h |
4395 | jae movd_mmreg |
||
4396 | call convert_register |
||
4397 | cmp ah,4 |
||
4398 | jne invalid_operand_size |
||
4399 | mov bl,al |
||
4400 | call get_mmx_source_register |
||
6467 | dunkaist | 4401 | jmp nomem_instruction_ready |
1053 | heavyiron | 4402 | movd_mmreg: |
31 | halyavin | 4403 | mov [extended_code],6Eh |
157 | heavyiron | 4404 | call convert_mmx_register |
4405 | mov [postbyte_register],al |
||
6467 | dunkaist | 4406 | call make_mmx_prefix |
157 | heavyiron | 4407 | mov [operand_size],0 |
4408 | lods byte [esi] |
||
4409 | cmp al,',' |
||
4410 | jne invalid_operand |
||
4411 | lods byte [esi] |
||
4412 | call get_size_operator |
||
4413 | cmp al,10h |
||
4414 | je movd_mmreg_reg |
||
4415 | cmp al,'[' |
||
4416 | jne invalid_operand |
||
4417 | call get_address |
||
4418 | test [operand_size],not 4 |
||
4419 | jnz invalid_operand_size |
||
4420 | jmp instruction_ready |
||
1053 | heavyiron | 4421 | movd_mmreg_reg: |
31 | halyavin | 4422 | lods byte [esi] |
157 | heavyiron | 4423 | call convert_register |
4424 | cmp ah,4 |
||
4425 | jne invalid_operand_size |
||
4426 | mov bl,al |
||
4427 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 4428 | get_mmx_source_register: |
6467 | dunkaist | 4429 | mov [operand_size],0 |
4430 | lods byte [esi] |
||
4431 | cmp al,',' |
||
4432 | jne invalid_operand |
||
4433 | lods byte [esi] |
||
4434 | call get_size_operator |
||
4435 | cmp al,10h |
||
4436 | jne invalid_operand |
||
4437 | lods byte [esi] |
||
4438 | call convert_mmx_register |
||
4439 | mov [postbyte_register],al |
||
4440 | make_mmx_prefix: |
||
31 | halyavin | 4441 | cmp [operand_size],16 |
157 | heavyiron | 4442 | jne no_mmx_prefix |
4443 | mov [operand_prefix],66h |
||
4444 | no_mmx_prefix: |
||
31 | halyavin | 4445 | ret |
157 | heavyiron | 4446 | movq_instruction: |
31 | halyavin | 4447 | mov [base_code],0Fh |
157 | heavyiron | 4448 | lods byte [esi] |
4449 | call get_size_operator |
||
4450 | cmp al,10h |
||
4451 | je movq_reg |
||
4452 | cmp al,'[' |
||
4453 | jne invalid_operand |
||
4454 | call get_address |
||
4455 | test [operand_size],not 8 |
||
4456 | jnz invalid_operand_size |
||
4457 | call get_mmx_source_register |
||
6467 | dunkaist | 4458 | mov al,7Fh |
4459 | cmp ah,8 |
||
4460 | je movq_mem_ready |
||
4461 | mov al,0D6h |
||
4462 | movq_mem_ready: |
||
4463 | mov [extended_code],al |
||
4464 | jmp instruction_ready |
||
1053 | heavyiron | 4465 | movq_reg: |
31 | halyavin | 4466 | lods byte [esi] |
157 | heavyiron | 4467 | cmp al,0B0h |
4468 | jae movq_mmreg |
||
4469 | call convert_register |
||
4470 | cmp ah,8 |
||
4471 | jne invalid_operand_size |
||
4472 | mov bl,al |
||
4473 | mov [extended_code],7Eh |
||
4474 | call operand_64bit |
||
4475 | call get_mmx_source_register |
||
6467 | dunkaist | 4476 | jmp nomem_instruction_ready |
1053 | heavyiron | 4477 | movq_mmreg: |
31 | halyavin | 4478 | call convert_mmx_register |
157 | heavyiron | 4479 | mov [postbyte_register],al |
4480 | mov [extended_code],6Fh |
||
4481 | mov [mmx_size],ah |
||
4482 | cmp ah,16 |
||
4483 | jne movq_mmreg_ |
||
4484 | mov [extended_code],7Eh |
||
4485 | mov [opcode_prefix],0F3h |
||
1039 | heavyiron | 4486 | movq_mmreg_: |
31 | halyavin | 4487 | lods byte [esi] |
157 | heavyiron | 4488 | cmp al,',' |
4489 | jne invalid_operand |
||
4490 | mov [operand_size],0 |
||
4491 | lods byte [esi] |
||
4492 | call get_size_operator |
||
4493 | cmp al,10h |
||
4494 | je movq_mmreg_reg |
||
4495 | cmp al,'[' |
||
6467 | dunkaist | 4496 | jne invalid_operand |
4497 | call get_address |
||
157 | heavyiron | 4498 | test [operand_size],not 8 |
4499 | jnz invalid_operand_size |
||
4500 | jmp instruction_ready |
||
1053 | heavyiron | 4501 | movq_mmreg_reg: |
31 | halyavin | 4502 | lods byte [esi] |
157 | heavyiron | 4503 | cmp al,0B0h |
4504 | jae movq_mmreg_mmreg |
||
4505 | mov [operand_size],0 |
||
4506 | call convert_register |
||
4507 | cmp ah,8 |
||
4508 | jne invalid_operand_size |
||
4509 | mov [extended_code],6Eh |
||
4510 | mov [opcode_prefix],0 |
||
1039 | heavyiron | 4511 | mov bl,al |
157 | heavyiron | 4512 | cmp [mmx_size],16 |
4513 | jne movq_mmreg_reg_store |
||
4514 | mov [opcode_prefix],66h |
||
1039 | heavyiron | 4515 | movq_mmreg_reg_store: |
109 | heavyiron | 4516 | call operand_64bit |
157 | heavyiron | 4517 | jmp nomem_instruction_ready |
1053 | heavyiron | 4518 | movq_mmreg_mmreg: |
31 | halyavin | 4519 | call convert_mmx_register |
157 | heavyiron | 4520 | cmp ah,[mmx_size] |
872 | heavyiron | 4521 | jne invalid_operand_size |
4522 | mov bl,al |
||
157 | heavyiron | 4523 | jmp nomem_instruction_ready |
1053 | heavyiron | 4524 | movdq_instruction: |
31 | halyavin | 4525 | mov [opcode_prefix],al |
1039 | heavyiron | 4526 | mov [base_code],0Fh |
157 | heavyiron | 4527 | mov [extended_code],6Fh |
4528 | lods byte [esi] |
||
4529 | call get_size_operator |
||
4530 | cmp al,10h |
||
4531 | je movdq_mmreg |
||
4532 | cmp al,'[' |
||
4533 | jne invalid_operand |
||
4534 | call get_address |
||
4535 | lods byte [esi] |
||
4536 | cmp al,',' |
||
4537 | jne invalid_operand |
||
4538 | lods byte [esi] |
||
4539 | call get_size_operator |
||
4540 | cmp al,10h |
||
4541 | jne invalid_operand |
||
4542 | lods byte [esi] |
||
4543 | call convert_xmm_register |
||
2287 | heavyiron | 4544 | mov [postbyte_register],al |
157 | heavyiron | 4545 | mov [extended_code],7Fh |
4546 | jmp instruction_ready |
||
1053 | heavyiron | 4547 | movdq_mmreg: |
31 | halyavin | 4548 | lods byte [esi] |
157 | heavyiron | 4549 | call convert_xmm_register |
2287 | heavyiron | 4550 | mov [postbyte_register],al |
157 | heavyiron | 4551 | lods byte [esi] |
4552 | cmp al,',' |
||
4553 | jne invalid_operand |
||
4554 | lods byte [esi] |
||
4555 | call get_size_operator |
||
4556 | cmp al,10h |
||
4557 | je movdq_mmreg_mmreg |
||
4558 | cmp al,'[' |
||
4559 | jne invalid_operand |
||
4560 | call get_address |
||
4561 | jmp instruction_ready |
||
1053 | heavyiron | 4562 | movdq_mmreg_mmreg: |
31 | halyavin | 4563 | lods byte [esi] |
157 | heavyiron | 4564 | call convert_xmm_register |
2287 | heavyiron | 4565 | mov bl,al |
157 | heavyiron | 4566 | jmp nomem_instruction_ready |
1053 | heavyiron | 4567 | lddqu_instruction: |
31 | halyavin | 4568 | lods byte [esi] |
157 | heavyiron | 4569 | call get_size_operator |
4570 | cmp al,10h |
||
4571 | jne invalid_operand |
||
4572 | lods byte [esi] |
||
4573 | call convert_xmm_register |
||
2287 | heavyiron | 4574 | push eax |
157 | heavyiron | 4575 | lods byte [esi] |
4576 | cmp al,',' |
||
4577 | jne invalid_operand |
||
4578 | lods byte [esi] |
||
4579 | call get_size_operator |
||
4580 | cmp al,'[' |
||
4581 | jne invalid_operand |
||
4582 | call get_address |
||
4583 | pop eax |
||
4584 | mov [postbyte_register],al |
||
4585 | mov [opcode_prefix],0F2h |
||
1039 | heavyiron | 4586 | mov [base_code],0Fh |
157 | heavyiron | 4587 | mov [extended_code],0F0h |
4588 | jmp instruction_ready |
||
1053 | heavyiron | 4589 | |
2287 | heavyiron | 4590 | |
4591 | mov [opcode_prefix],0F2h |
||
4592 | mov [mmx_size],8 |
||
4593 | jmp movq2dq_ |
||
4594 | movq2dq_instruction: |
||
31 | halyavin | 4595 | mov [opcode_prefix],0F3h |
1039 | heavyiron | 4596 | mov [mmx_size],16 |
2287 | heavyiron | 4597 | movq2dq_: |
4598 | lods byte [esi] |
||
157 | heavyiron | 4599 | call get_size_operator |
4600 | cmp al,10h |
||
4601 | jne invalid_operand |
||
4602 | lods byte [esi] |
||
4603 | call convert_mmx_register |
||
4604 | cmp ah,[mmx_size] |
||
2287 | heavyiron | 4605 | jne invalid_operand_size |
157 | heavyiron | 4606 | mov [postbyte_register],al |
4607 | mov [operand_size],0 |
||
4608 | lods byte [esi] |
||
4609 | cmp al,',' |
||
4610 | jne invalid_operand |
||
4611 | lods byte [esi] |
||
4612 | call get_size_operator |
||
4613 | cmp al,10h |
||
4614 | jne invalid_operand |
||
4615 | lods byte [esi] |
||
4616 | call convert_mmx_register |
||
4617 | xor [mmx_size],8+16 |
||
2287 | heavyiron | 4618 | cmp ah,[mmx_size] |
4619 | jne invalid_operand_size |
||
157 | heavyiron | 4620 | mov bl,al |
4621 | mov [base_code],0Fh |
||
4622 | mov [extended_code],0D6h |
||
4623 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 4624 | |
31 | halyavin | 4625 | |
707 | heavyiron | 4626 | mov [immediate_size],1 |
1062 | heavyiron | 4627 | sse_ps_instruction: |
31 | halyavin | 4628 | mov [mmx_size],16 |
157 | heavyiron | 4629 | jmp sse_instruction |
4630 | sse_pd_instruction_imm8: |
||
707 | heavyiron | 4631 | mov [immediate_size],1 |
1062 | heavyiron | 4632 | sse_pd_instruction: |
31 | halyavin | 4633 | mov [mmx_size],16 |
157 | heavyiron | 4634 | mov [opcode_prefix],66h |
1039 | heavyiron | 4635 | jmp sse_instruction |
157 | heavyiron | 4636 | sse_ss_instruction: |
31 | halyavin | 4637 | mov [mmx_size],4 |
157 | heavyiron | 4638 | mov [opcode_prefix],0F3h |
1039 | heavyiron | 4639 | jmp sse_instruction |
157 | heavyiron | 4640 | sse_sd_instruction: |
31 | halyavin | 4641 | mov [mmx_size],8 |
157 | heavyiron | 4642 | mov [opcode_prefix],0F2h |
1039 | heavyiron | 4643 | jmp sse_instruction |
157 | heavyiron | 4644 | cmp_pd_instruction: |
2287 | heavyiron | 4645 | mov [opcode_prefix],66h |
4646 | cmp_ps_instruction: |
||
4647 | mov [mmx_size],16 |
||
4648 | mov byte [value],al |
||
4649 | mov al,0C2h |
||
4650 | jmp sse_instruction |
||
4651 | cmp_ss_instruction: |
||
4652 | mov [mmx_size],4 |
||
4653 | mov [opcode_prefix],0F3h |
||
4654 | jmp cmp_sx_instruction |
||
4655 | cmpsd_instruction: |
||
4656 | mov al,0A7h |
||
4657 | mov ah,[esi] |
||
4658 | or ah,ah |
||
4659 | jz simple_instruction_32bit |
||
4660 | cmp ah,0Fh |
||
4661 | je simple_instruction_32bit |
||
4662 | mov al,-1 |
||
4663 | cmp_sd_instruction: |
||
4664 | mov [mmx_size],8 |
||
4665 | mov [opcode_prefix],0F2h |
||
4666 | cmp_sx_instruction: |
||
4667 | mov byte [value],al |
||
4668 | mov al,0C2h |
||
4669 | jmp sse_instruction |
||
4670 | comiss_instruction: |
||
31 | halyavin | 4671 | mov [mmx_size],4 |
157 | heavyiron | 4672 | jmp sse_instruction |
4673 | comisd_instruction: |
||
31 | halyavin | 4674 | mov [mmx_size],8 |
157 | heavyiron | 4675 | mov [opcode_prefix],66h |
1039 | heavyiron | 4676 | jmp sse_instruction |
157 | heavyiron | 4677 | cvtdq2pd_instruction: |
2287 | heavyiron | 4678 | mov [opcode_prefix],0F3h |
4679 | cvtps2pd_instruction: |
||
31 | halyavin | 4680 | mov [mmx_size],8 |
157 | heavyiron | 4681 | jmp sse_instruction |
4682 | cvtpd2dq_instruction: |
||
31 | halyavin | 4683 | mov [mmx_size],16 |
157 | heavyiron | 4684 | mov [opcode_prefix],0F2h |
1039 | heavyiron | 4685 | jmp sse_instruction |
157 | heavyiron | 4686 | movshdup_instruction: |
2287 | heavyiron | 4687 | mov [mmx_size],16 |
157 | heavyiron | 4688 | mov [opcode_prefix],0F3h |
1039 | heavyiron | 4689 | sse_instruction: |
31 | halyavin | 4690 | mov [base_code],0Fh |
157 | heavyiron | 4691 | mov [extended_code],al |
4692 | lods byte [esi] |
||
4693 | call get_size_operator |
||
4694 | cmp al,10h |
||
4695 | jne invalid_operand |
||
4696 | sse_xmmreg: |
||
31 | halyavin | 4697 | lods byte [esi] |
157 | heavyiron | 4698 | call convert_xmm_register |
2287 | heavyiron | 4699 | sse_reg: |
31 | halyavin | 4700 | mov [postbyte_register],al |
157 | heavyiron | 4701 | mov [operand_size],0 |
4702 | lods byte [esi] |
||
4703 | cmp al,',' |
||
4704 | jne invalid_operand |
||
4705 | lods byte [esi] |
||
4706 | call get_size_operator |
||
4707 | cmp al,10h |
||
4708 | je sse_xmmreg_xmmreg |
||
4709 | sse_reg_mem: |
||
31 | halyavin | 4710 | cmp al,'[' |
157 | heavyiron | 4711 | jne invalid_operand |
4712 | call get_address |
||
4713 | cmp [operand_size],0 |
||
4714 | je sse_mem_size_ok |
||
4715 | mov al,[mmx_size] |
||
4716 | cmp [operand_size],al |
||
4717 | jne invalid_operand_size |
||
4718 | sse_mem_size_ok: |
||
31 | halyavin | 4719 | mov al,[extended_code] |
2287 | heavyiron | 4720 | mov ah,[supplemental_code] |
4721 | cmp al,0C2h |
||
4722 | je sse_cmp_mem_ok |
||
4723 | cmp ax,443Ah |
||
4724 | je sse_cmp_mem_ok |
||
4725 | cmp [immediate_size],1 |
||
1062 | heavyiron | 4726 | je mmx_imm8 |
157 | heavyiron | 4727 | cmp [immediate_size],-1 |
707 | heavyiron | 4728 | jne sse_ok |
4729 | call take_additional_xmm0 |
||
4730 | mov [immediate_size],0 |
||
1189 | heavyiron | 4731 | sse_ok: |
707 | heavyiron | 4732 | jmp instruction_ready |
1053 | heavyiron | 4733 | sse_cmp_mem_ok: |
2287 | heavyiron | 4734 | cmp byte [value],-1 |
4735 | je mmx_imm8 |
||
4736 | call store_instruction_with_imm8 |
||
4737 | jmp instruction_assembled |
||
4738 | sse_xmmreg_xmmreg: |
||
31 | halyavin | 4739 | cmp [operand_prefix],66h |
157 | heavyiron | 4740 | jne sse_xmmreg_xmmreg_ok |
4741 | cmp [extended_code],12h |
||
4742 | je invalid_operand |
||
4743 | cmp [extended_code],16h |
||
4744 | je invalid_operand |
||
4745 | sse_xmmreg_xmmreg_ok: |
||
31 | halyavin | 4746 | lods byte [esi] |
157 | heavyiron | 4747 | call convert_xmm_register |
2287 | heavyiron | 4748 | mov bl,al |
157 | heavyiron | 4749 | mov al,[extended_code] |
2287 | heavyiron | 4750 | mov ah,[supplemental_code] |
4751 | cmp al,0C2h |
||
4752 | je sse_cmp_nomem_ok |
||
4753 | cmp ax,443Ah |
||
4754 | je sse_cmp_nomem_ok |
||
4755 | cmp [immediate_size],1 |
||
1062 | heavyiron | 4756 | je mmx_nomem_imm8 |
157 | heavyiron | 4757 | cmp [immediate_size],-1 |
707 | heavyiron | 4758 | jne sse_nomem_ok |
4759 | call take_additional_xmm0 |
||
4760 | mov [immediate_size],0 |
||
1189 | heavyiron | 4761 | sse_nomem_ok: |
707 | heavyiron | 4762 | jmp nomem_instruction_ready |
1053 | heavyiron | 4763 | sse_cmp_nomem_ok: |
2287 | heavyiron | 4764 | cmp byte [value],-1 |
4765 | je mmx_nomem_imm8 |
||
4766 | call store_nomem_instruction |
||
4767 | mov al,byte [value] |
||
4768 | stosb |
||
4769 | jmp instruction_assembled |
||
4770 | take_additional_xmm0: |
||
707 | heavyiron | 4771 | cmp byte [esi],',' |
1189 | heavyiron | 4772 | jne additional_xmm0_ok |
4773 | inc esi |
||
4774 | lods byte [esi] |
||
707 | heavyiron | 4775 | cmp al,10h |
4776 | jne invalid_operand |
||
4777 | lods byte [esi] |
||
4778 | call convert_xmm_register |
||
2287 | heavyiron | 4779 | test al,al |
707 | heavyiron | 4780 | jnz invalid_operand |
4781 | additional_xmm0_ok: |
||
1189 | heavyiron | 4782 | ret |
707 | heavyiron | 4783 | |
4784 | |||
2287 | heavyiron | 4785 | mov [postbyte_register],al |
157 | heavyiron | 4786 | mov [opcode_prefix],66h |
1039 | heavyiron | 4787 | mov [base_code],0Fh |
157 | heavyiron | 4788 | mov [extended_code],73h |
4789 | lods byte [esi] |
||
4790 | call get_size_operator |
||
4791 | cmp al,10h |
||
4792 | jne invalid_operand |
||
4793 | lods byte [esi] |
||
4794 | call convert_xmm_register |
||
2287 | heavyiron | 4795 | mov bl,al |
157 | heavyiron | 4796 | jmp mmx_nomem_imm8 |
4797 | movpd_instruction: |
||
31 | halyavin | 4798 | mov [opcode_prefix],66h |
1039 | heavyiron | 4799 | movps_instruction: |
31 | halyavin | 4800 | mov [base_code],0Fh |
157 | heavyiron | 4801 | mov [extended_code],al |
4802 | mov [mmx_size],16 |
||
4803 | jmp sse_mov_instruction |
||
4804 | movss_instruction: |
||
31 | halyavin | 4805 | mov [mmx_size],4 |
157 | heavyiron | 4806 | mov [opcode_prefix],0F3h |
1039 | heavyiron | 4807 | jmp sse_movs |
157 | heavyiron | 4808 | movsd_instruction: |
31 | halyavin | 4809 | mov al,0A5h |
157 | heavyiron | 4810 | mov ah,[esi] |
4811 | or ah,ah |
||
4812 | jz simple_instruction_32bit |
||
4813 | cmp ah,0Fh |
||
4814 | je simple_instruction_32bit |
||
4815 | mov [mmx_size],8 |
||
4816 | mov [opcode_prefix],0F2h |
||
1039 | heavyiron | 4817 | sse_movs: |
31 | halyavin | 4818 | mov [base_code],0Fh |
157 | heavyiron | 4819 | mov [extended_code],10h |
4820 | jmp sse_mov_instruction |
||
4821 | sse_mov_instruction: |
||
31 | halyavin | 4822 | lods byte [esi] |
157 | heavyiron | 4823 | call get_size_operator |
4824 | cmp al,10h |
||
4825 | je sse_xmmreg |
||
4826 | sse_mem: |
||
31 | halyavin | 4827 | cmp al,'[' |
157 | heavyiron | 4828 | jne invalid_operand |
4829 | inc [extended_code] |
||
4830 | call get_address |
||
4831 | cmp [operand_size],0 |
||
4832 | je sse_mem_xmmreg |
||
4833 | mov al,[mmx_size] |
||
4834 | cmp [operand_size],al |
||
4835 | jne invalid_operand_size |
||
4836 | mov [operand_size],0 |
||
4837 | sse_mem_xmmreg: |
||
31 | halyavin | 4838 | lods byte [esi] |
157 | heavyiron | 4839 | cmp al,',' |
4840 | jne invalid_operand |
||
4841 | lods byte [esi] |
||
4842 | call get_size_operator |
||
4843 | cmp al,10h |
||
4844 | jne invalid_operand |
||
4845 | lods byte [esi] |
||
4846 | call convert_xmm_register |
||
2287 | heavyiron | 4847 | mov [postbyte_register],al |
157 | heavyiron | 4848 | jmp instruction_ready |
1053 | heavyiron | 4849 | movlpd_instruction: |
31 | halyavin | 4850 | mov [opcode_prefix],66h |
1039 | heavyiron | 4851 | movlps_instruction: |
31 | halyavin | 4852 | mov [base_code],0Fh |
157 | heavyiron | 4853 | mov [extended_code],al |
4854 | mov [mmx_size],8 |
||
4855 | lods byte [esi] |
||
4856 | call get_size_operator |
||
4857 | cmp al,10h |
||
4858 | jne sse_mem |
||
4859 | lods byte [esi] |
||
4860 | call convert_xmm_register |
||
2287 | heavyiron | 4861 | mov [postbyte_register],al |
157 | heavyiron | 4862 | mov [operand_size],0 |
4863 | lods byte [esi] |
||
4864 | cmp al,',' |
||
4865 | jne invalid_operand |
||
4866 | lods byte [esi] |
||
4867 | call get_size_operator |
||
4868 | jmp sse_reg_mem |
||
4869 | movhlps_instruction: |
||
31 | halyavin | 4870 | mov [base_code],0Fh |
157 | heavyiron | 4871 | mov [extended_code],al |
4872 | mov [mmx_size],0 |
||
4873 | lods byte [esi] |
||
4874 | call get_size_operator |
||
4875 | cmp al,10h |
||
4876 | jne invalid_operand |
||
4877 | lods byte [esi] |
||
4878 | call convert_xmm_register |
||
2287 | heavyiron | 4879 | mov [postbyte_register],al |
157 | heavyiron | 4880 | lods byte [esi] |
4881 | cmp al,',' |
||
4882 | jne invalid_operand |
||
4883 | lods byte [esi] |
||
4884 | call get_size_operator |
||
4885 | cmp al,10h |
||
4886 | je sse_xmmreg_xmmreg_ok |
||
4887 | jmp invalid_operand |
||
4888 | maskmovq_instruction: |
||
31 | halyavin | 4889 | mov cl,8 |
157 | heavyiron | 4890 | jmp maskmov_instruction |
4891 | maskmovdqu_instruction: |
||
31 | halyavin | 4892 | mov cl,16 |
157 | heavyiron | 4893 | mov [opcode_prefix],66h |
1039 | heavyiron | 4894 | maskmov_instruction: |
31 | halyavin | 4895 | mov [base_code],0Fh |
157 | heavyiron | 4896 | mov [extended_code],0F7h |
4897 | lods byte [esi] |
||
4898 | call get_size_operator |
||
4899 | cmp al,10h |
||
4900 | jne invalid_operand |
||
4901 | lods byte [esi] |
||
4902 | call convert_mmx_register |
||
4903 | cmp ah,cl |
||
4904 | jne invalid_operand_size |
||
4905 | mov [postbyte_register],al |
||
4906 | lods byte [esi] |
||
4907 | cmp al,',' |
||
4908 | jne invalid_operand |
||
4909 | lods byte [esi] |
||
4910 | call get_size_operator |
||
4911 | cmp al,10h |
||
4912 | jne invalid_operand |
||
4913 | lods byte [esi] |
||
4914 | call convert_mmx_register |
||
4915 | mov bl,al |
||
4916 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 4917 | movmskpd_instruction: |
31 | halyavin | 4918 | mov [opcode_prefix],66h |
1039 | heavyiron | 4919 | movmskps_instruction: |
31 | halyavin | 4920 | mov [base_code],0Fh |
157 | heavyiron | 4921 | mov [extended_code],50h |
4922 | call take_register |
||
6467 | dunkaist | 4923 | mov [postbyte_register],al |
2287 | heavyiron | 4924 | cmp ah,4 |
157 | heavyiron | 4925 | je movmskps_reg_ok |
2287 | heavyiron | 4926 | cmp ah,8 |
4927 | jne invalid_operand_size |
||
157 | heavyiron | 4928 | cmp [code_type],64 |
2287 | heavyiron | 4929 | jne invalid_operand |
4930 | movmskps_reg_ok: |
||
4931 | mov [operand_size],0 |
||
157 | heavyiron | 4932 | lods byte [esi] |
4933 | cmp al,',' |
||
4934 | jne invalid_operand |
||
4935 | lods byte [esi] |
||
4936 | call get_size_operator |
||
4937 | cmp al,10h |
||
4938 | je sse_xmmreg_xmmreg_ok |
||
2287 | heavyiron | 4939 | jmp invalid_operand |
4940 | |||
4941 | |||
31 | halyavin | 4942 | mov [opcode_prefix],66h |
1039 | heavyiron | 4943 | cvtpi2ps_instruction: |
31 | halyavin | 4944 | mov [base_code],0Fh |
157 | heavyiron | 4945 | mov [extended_code],al |
4946 | lods byte [esi] |
||
4947 | call get_size_operator |
||
4948 | cmp al,10h |
||
4949 | jne invalid_operand |
||
4950 | lods byte [esi] |
||
4951 | call convert_xmm_register |
||
2287 | heavyiron | 4952 | mov [postbyte_register],al |
157 | heavyiron | 4953 | mov [operand_size],0 |
4954 | lods byte [esi] |
||
4955 | cmp al,',' |
||
4956 | jne invalid_operand |
||
4957 | lods byte [esi] |
||
4958 | call get_size_operator |
||
4959 | cmp al,10h |
||
4960 | je cvtpi_xmmreg_xmmreg |
||
4961 | cmp al,'[' |
||
4962 | jne invalid_operand |
||
4963 | call get_address |
||
4964 | cmp [operand_size],0 |
||
4965 | je cvtpi_size_ok |
||
4966 | cmp [operand_size],8 |
||
4967 | jne invalid_operand_size |
||
4968 | cvtpi_size_ok: |
||
31 | halyavin | 4969 | jmp instruction_ready |
1053 | heavyiron | 4970 | cvtpi_xmmreg_xmmreg: |
31 | halyavin | 4971 | lods byte [esi] |
157 | heavyiron | 4972 | call convert_mmx_register |
4973 | cmp ah,8 |
||
4974 | jne invalid_operand_size |
||
4975 | mov bl,al |
||
4976 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 4977 | cvtsi2ss_instruction: |
31 | halyavin | 4978 | mov [opcode_prefix],0F3h |
1039 | heavyiron | 4979 | jmp cvtsi_instruction |
157 | heavyiron | 4980 | cvtsi2sd_instruction: |
31 | halyavin | 4981 | mov [opcode_prefix],0F2h |
1039 | heavyiron | 4982 | cvtsi_instruction: |
31 | halyavin | 4983 | mov [base_code],0Fh |
157 | heavyiron | 4984 | mov [extended_code],al |
4985 | lods byte [esi] |
||
4986 | call get_size_operator |
||
4987 | cmp al,10h |
||
4988 | jne invalid_operand |
||
4989 | lods byte [esi] |
||
4990 | call convert_xmm_register |
||
2287 | heavyiron | 4991 | mov [postbyte_register],al |
157 | heavyiron | 4992 | cvtsi_xmmreg: |
2287 | heavyiron | 4993 | mov [operand_size],0 |
157 | heavyiron | 4994 | lods byte [esi] |
4995 | cmp al,',' |
||
4996 | jne invalid_operand |
||
4997 | lods byte [esi] |
||
4998 | call get_size_operator |
||
4999 | cmp al,10h |
||
5000 | je cvtsi_xmmreg_reg |
||
5001 | cmp al,'[' |
||
5002 | jne invalid_operand |
||
5003 | call get_address |
||
5004 | cmp [operand_size],0 |
||
5005 | je cvtsi_size_ok |
||
5006 | cmp [operand_size],4 |
||
5007 | je cvtsi_size_ok |
||
2287 | heavyiron | 5008 | cmp [operand_size],8 |
5009 | jne invalid_operand_size |
||
157 | heavyiron | 5010 | call operand_64bit |
2287 | heavyiron | 5011 | cvtsi_size_ok: |
31 | halyavin | 5012 | jmp instruction_ready |
1053 | heavyiron | 5013 | cvtsi_xmmreg_reg: |
31 | halyavin | 5014 | lods byte [esi] |
157 | heavyiron | 5015 | call convert_register |
5016 | cmp ah,4 |
||
5017 | je cvtsi_xmmreg_reg_store |
||
5018 | cmp ah,8 |
||
5019 | jne invalid_operand_size |
||
5020 | call operand_64bit |
||
5021 | cvtsi_xmmreg_reg_store: |
||
31 | halyavin | 5022 | mov bl,al |
157 | heavyiron | 5023 | jmp nomem_instruction_ready |
1053 | heavyiron | 5024 | cvtps2pi_instruction: |
31 | halyavin | 5025 | mov [mmx_size],8 |
157 | heavyiron | 5026 | jmp cvtpd_instruction |
5027 | cvtpd2pi_instruction: |
||
31 | halyavin | 5028 | mov [opcode_prefix],66h |
1039 | heavyiron | 5029 | mov [mmx_size],16 |
157 | heavyiron | 5030 | cvtpd_instruction: |
31 | halyavin | 5031 | mov [base_code],0Fh |
157 | heavyiron | 5032 | mov [extended_code],al |
5033 | lods byte [esi] |
||
5034 | call get_size_operator |
||
5035 | cmp al,10h |
||
5036 | jne invalid_operand |
||
5037 | lods byte [esi] |
||
5038 | call convert_mmx_register |
||
5039 | cmp ah,8 |
||
5040 | jne invalid_operand_size |
||
5041 | mov [operand_size],0 |
||
5042 | jmp sse_reg |
||
5043 | cvtss2si_instruction: |
||
31 | halyavin | 5044 | mov [opcode_prefix],0F3h |
1039 | heavyiron | 5045 | mov [mmx_size],4 |
157 | heavyiron | 5046 | jmp cvt2si_instruction |
5047 | cvtsd2si_instruction: |
||
31 | halyavin | 5048 | mov [opcode_prefix],0F2h |
1039 | heavyiron | 5049 | mov [mmx_size],8 |
157 | heavyiron | 5050 | cvt2si_instruction: |
31 | halyavin | 5051 | mov [extended_code],al |
157 | heavyiron | 5052 | mov [base_code],0Fh |
5053 | call take_register |
||
6467 | dunkaist | 5054 | mov [operand_size],0 |
157 | heavyiron | 5055 | cmp ah,4 |
5056 | je sse_reg |
||
5057 | cmp ah,8 |
||
5058 | jne invalid_operand_size |
||
5059 | call operand_64bit |
||
5060 | jmp sse_reg |
||
5061 | |||
174 | heavyiron | 5062 | |
5063 | mov [base_code],0Fh |
||
5064 | mov [extended_code],38h |
||
5065 | mov [supplemental_code],al |
||
5066 | jmp mmx_instruction |
||
5067 | palignr_instruction: |
||
5068 | mov [base_code],0Fh |
||
5069 | mov [extended_code],3Ah |
||
5070 | mov [supplemental_code],0Fh |
||
5071 | lods byte [esi] |
||
5072 | call get_size_operator |
||
5073 | cmp al,10h |
||
5074 | jne invalid_operand |
||
5075 | lods byte [esi] |
||
5076 | call convert_mmx_register |
||
5077 | call make_mmx_prefix |
||
5078 | mov [postbyte_register],al |
||
5079 | lods byte [esi] |
||
5080 | cmp al,',' |
||
5081 | jne invalid_operand |
||
5082 | lods byte [esi] |
||
5083 | call get_size_operator |
||
5084 | cmp al,10h |
||
5085 | je palignr_mmreg_mmreg |
||
5086 | cmp al,'[' |
||
5087 | jne invalid_operand |
||
5088 | call get_address |
||
5089 | jmp mmx_imm8 |
||
5090 | palignr_mmreg_mmreg: |
||
5091 | lods byte [esi] |
||
5092 | call convert_mmx_register |
||
5093 | mov bl,al |
||
5094 | jmp mmx_nomem_imm8 |
||
5095 | amd3dnow_instruction: |
||
31 | halyavin | 5096 | mov [base_code],0Fh |
157 | heavyiron | 5097 | mov [extended_code],0Fh |
5098 | mov byte [value],al |
||
5099 | lods byte [esi] |
||
5100 | call get_size_operator |
||
5101 | cmp al,10h |
||
5102 | jne invalid_operand |
||
5103 | lods byte [esi] |
||
5104 | call convert_mmx_register |
||
5105 | cmp ah,8 |
||
5106 | jne invalid_operand_size |
||
5107 | mov [postbyte_register],al |
||
5108 | lods byte [esi] |
||
5109 | cmp al,',' |
||
5110 | jne invalid_operand |
||
5111 | lods byte [esi] |
||
5112 | call get_size_operator |
||
5113 | cmp al,10h |
||
5114 | je amd3dnow_mmreg_mmreg |
||
5115 | cmp al,'[' |
||
5116 | jne invalid_operand |
||
5117 | call get_address |
||
5118 | call store_instruction_with_imm8 |
||
5119 | jmp instruction_assembled |
||
5120 | amd3dnow_mmreg_mmreg: |
||
31 | halyavin | 5121 | lods byte [esi] |
157 | heavyiron | 5122 | call convert_mmx_register |
5123 | cmp ah,8 |
||
5124 | jne invalid_operand_size |
||
5125 | mov bl,al |
||
5126 | call store_nomem_instruction |
||
5127 | mov al,byte [value] |
||
5128 | stos byte [edi] |
||
5129 | jmp instruction_assembled |
||
5130 | |||
31 | halyavin | 5131 | |
707 | heavyiron | 5132 | mov [immediate_size],-1 |
5133 | jmp sse4_instruction_38 |
||
6467 | dunkaist | 5134 | sse4_instruction_66_38_xmm0: |
5135 | mov [immediate_size],-1 |
||
5136 | sse4_instruction_66_38: |
||
5137 | mov [opcode_prefix],66h |
||
5138 | sse4_instruction_38: |
||
707 | heavyiron | 5139 | mov [mmx_size],16 |
1062 | heavyiron | 5140 | mov [supplemental_code],al |
707 | heavyiron | 5141 | mov al,38h |
5142 | jmp sse_instruction |
||
5143 | sse4_ss_instruction_66_3a_imm8: |
||
6467 | dunkaist | 5144 | mov [immediate_size],1 |
1062 | heavyiron | 5145 | mov cl,4 |
6467 | dunkaist | 5146 | jmp sse4_instruction_66_3a_setup |
5147 | sse4_sd_instruction_66_3a_imm8: |
||
5148 | mov [immediate_size],1 |
||
1062 | heavyiron | 5149 | mov cl,8 |
6467 | dunkaist | 5150 | jmp sse4_instruction_66_3a_setup |
5151 | sse4_instruction_66_3a_imm8: |
||
5152 | mov [immediate_size],1 |
||
1062 | heavyiron | 5153 | mov cl,16 |
6467 | dunkaist | 5154 | sse4_instruction_66_3a_setup: |
5155 | mov [opcode_prefix],66h |
||
5156 | sse4_instruction_3a_setup: |
||
1062 | heavyiron | 5157 | mov [supplemental_code],al |
707 | heavyiron | 5158 | mov al,3Ah |
5159 | mov [mmx_size],cl |
||
6467 | dunkaist | 5160 | jmp sse_instruction |
707 | heavyiron | 5161 | sse4_instruction_3a_imm8: |
6467 | dunkaist | 5162 | mov [immediate_size],1 |
5163 | mov cl,16 |
||
5164 | jmp sse4_instruction_3a_setup |
||
5165 | pclmulqdq_instruction: |
||
2287 | heavyiron | 5166 | mov byte [value],al |
5167 | mov al,44h |
||
5168 | mov cl,16 |
||
6467 | dunkaist | 5169 | jmp sse4_instruction_66_3a_setup |
5170 | extractps_instruction: |
||
1039 | heavyiron | 5171 | call setup_66_0f_3a |
6467 | dunkaist | 5172 | lods byte [esi] |
1039 | heavyiron | 5173 | call get_size_operator |
5174 | cmp al,10h |
||
5175 | je extractps_reg |
||
5176 | cmp al,'[' |
||
5177 | jne invalid_operand |
||
5178 | call get_address |
||
5179 | cmp [operand_size],4 |
||
5180 | je extractps_size_ok |
||
5181 | cmp [operand_size],0 |
||
5182 | jne invalid_operand_size |
||
5183 | extractps_size_ok: |
||
5184 | push edx ebx ecx |
||
5185 | mov [operand_size],0 |
||
5186 | lods byte [esi] |
||
5187 | cmp al,',' |
||
5188 | jne invalid_operand |
||
5189 | lods byte [esi] |
||
5190 | call get_size_operator |
||
5191 | cmp al,10h |
||
5192 | jne invalid_operand |
||
5193 | lods byte [esi] |
||
5194 | call convert_xmm_register |
||
2287 | heavyiron | 5195 | mov [postbyte_register],al |
1039 | heavyiron | 5196 | pop ecx ebx edx |
5197 | jmp mmx_imm8 |
||
5198 | extractps_reg: |
||
5199 | lods byte [esi] |
||
5200 | call convert_register |
||
5201 | push eax |
||
5202 | mov [operand_size],0 |
||
5203 | lods byte [esi] |
||
5204 | cmp al,',' |
||
5205 | jne invalid_operand |
||
5206 | lods byte [esi] |
||
5207 | call get_size_operator |
||
5208 | cmp al,10h |
||
5209 | jne invalid_operand |
||
5210 | lods byte [esi] |
||
5211 | call convert_xmm_register |
||
2287 | heavyiron | 5212 | mov [postbyte_register],al |
1039 | heavyiron | 5213 | pop ebx |
5214 | mov al,bh |
||
5215 | cmp al,4 |
||
1189 | heavyiron | 5216 | je mmx_nomem_imm8 |
5217 | cmp al,8 |
||
1039 | heavyiron | 5218 | jne invalid_operand_size |
5219 | cmp [code_type],64 |
||
6467 | dunkaist | 5220 | jne illegal_instruction |
5221 | jmp mmx_nomem_imm8 |
||
1039 | heavyiron | 5222 | setup_66_0f_3a: |
6467 | dunkaist | 5223 | mov [extended_code],3Ah |
5224 | mov [supplemental_code],al |
||
5225 | mov [base_code],0Fh |
||
5226 | mov [opcode_prefix],66h |
||
5227 | ret |
||
5228 | insertps_instruction: |
||
1039 | heavyiron | 5229 | call setup_66_0f_3a |
6467 | dunkaist | 5230 | lods byte [esi] |
1039 | heavyiron | 5231 | call get_size_operator |
5232 | cmp al,10h |
||
5233 | jne invalid_operand |
||
5234 | lods byte [esi] |
||
5235 | call convert_xmm_register |
||
2287 | heavyiron | 5236 | mov [postbyte_register],al |
1039 | heavyiron | 5237 | mov [operand_size],0 |
5238 | lods byte [esi] |
||
5239 | cmp al,',' |
||
5240 | jne invalid_operand |
||
5241 | lods byte [esi] |
||
5242 | call get_size_operator |
||
5243 | cmp al,10h |
||
5244 | je insertps_xmmreg_reg |
||
2287 | heavyiron | 5245 | cmp al,'[' |
1039 | heavyiron | 5246 | jne invalid_operand |
5247 | call get_address |
||
5248 | cmp [operand_size],4 |
||
5249 | je insertps_size_ok |
||
5250 | cmp [operand_size],0 |
||
5251 | jne invalid_operand_size |
||
5252 | insertps_size_ok: |
||
5253 | jmp mmx_imm8 |
||
5254 | insertps_xmmreg_reg: |
||
2287 | heavyiron | 5255 | lods byte [esi] |
1039 | heavyiron | 5256 | call convert_mmx_register |
5257 | mov bl,al |
||
5258 | jmp mmx_nomem_imm8 |
||
5259 | pextrq_instruction: |
||
5260 | mov [mmx_size],8 |
||
5261 | jmp pextr_instruction |
||
5262 | pextrd_instruction: |
||
5263 | mov [mmx_size],4 |
||
5264 | jmp pextr_instruction |
||
5265 | pextrw_instruction: |
||
5266 | mov [mmx_size],2 |
||
5267 | jmp pextr_instruction |
||
5268 | pextrb_instruction: |
||
5269 | mov [mmx_size],1 |
||
5270 | pextr_instruction: |
||
5271 | call setup_66_0f_3a |
||
6467 | dunkaist | 5272 | lods byte [esi] |
1039 | heavyiron | 5273 | call get_size_operator |
5274 | cmp al,10h |
||
5275 | je pextr_reg |
||
5276 | cmp al,'[' |
||
5277 | jne invalid_operand |
||
5278 | call get_address |
||
5279 | mov al,[mmx_size] |
||
5280 | cmp al,[operand_size] |
||
5281 | je pextr_size_ok |
||
5282 | cmp [operand_size],0 |
||
5283 | jne invalid_operand_size |
||
5284 | pextr_size_ok: |
||
5285 | cmp al,8 |
||
2287 | heavyiron | 5286 | jne pextr_prefix_ok |
5287 | call operand_64bit |
||
5288 | pextr_prefix_ok: |
||
5289 | push edx ebx ecx |
||
1039 | heavyiron | 5290 | mov [operand_size],0 |
5291 | lods byte [esi] |
||
5292 | cmp al,',' |
||
5293 | jne invalid_operand |
||
5294 | lods byte [esi] |
||
5295 | call get_size_operator |
||
5296 | cmp al,10h |
||
5297 | jne invalid_operand |
||
5298 | lods byte [esi] |
||
5299 | call convert_xmm_register |
||
2287 | heavyiron | 5300 | mov [postbyte_register],al |
1039 | heavyiron | 5301 | pop ecx ebx edx |
5302 | jmp mmx_imm8 |
||
5303 | pextr_reg: |
||
5304 | lods byte [esi] |
||
5305 | call convert_register |
||
5306 | cmp [mmx_size],4 |
||
5307 | ja pextrq_reg |
||
5308 | cmp ah,4 |
||
5309 | je pextr_reg_size_ok |
||
5310 | cmp [code_type],64 |
||
1342 | heavyiron | 5311 | jne pextr_invalid_size |
5312 | cmp ah,8 |
||
1039 | heavyiron | 5313 | je pextr_reg_size_ok |
5314 | pextr_invalid_size: |
||
5315 | jmp invalid_operand_size |
||
5316 | pextrq_reg: |
||
5317 | cmp ah,8 |
||
5318 | jne pextr_invalid_size |
||
5319 | call operand_64bit |
||
5320 | pextr_reg_size_ok: |
||
5321 | mov [operand_size],0 |
||
5322 | push eax |
||
5323 | lods byte [esi] |
||
5324 | cmp al,',' |
||
5325 | jne invalid_operand |
||
5326 | lods byte [esi] |
||
5327 | call get_size_operator |
||
5328 | cmp al,10h |
||
5329 | jne invalid_operand |
||
5330 | lods byte [esi] |
||
5331 | call convert_mmx_register |
||
5332 | mov ebx,eax |
||
5333 | pop eax |
||
5334 | mov [postbyte_register],al |
||
5335 | mov al,ah |
||
5336 | cmp [mmx_size],2 |
||
5337 | jne pextr_reg_store |
||
5338 | mov [opcode_prefix],0 |
||
5339 | mov [extended_code],0C5h |
||
5340 | call make_mmx_prefix |
||
5341 | jmp mmx_nomem_imm8 |
||
5342 | pextr_reg_store: |
||
5343 | cmp bh,16 |
||
5344 | jne invalid_operand_size |
||
5345 | xchg bl,[postbyte_register] |
||
5346 | jmp mmx_nomem_imm8 |
||
5347 | pinsrb_instruction: |
||
5348 | mov [mmx_size],1 |
||
5349 | jmp pinsr_instruction |
||
5350 | pinsrd_instruction: |
||
5351 | mov [mmx_size],4 |
||
5352 | jmp pinsr_instruction |
||
5353 | pinsrq_instruction: |
||
5354 | mov [mmx_size],8 |
||
5355 | call operand_64bit |
||
2287 | heavyiron | 5356 | pinsr_instruction: |
1039 | heavyiron | 5357 | call setup_66_0f_3a |
6467 | dunkaist | 5358 | lods byte [esi] |
1039 | heavyiron | 5359 | call get_size_operator |
5360 | cmp al,10h |
||
5361 | jne invalid_operand |
||
5362 | lods byte [esi] |
||
5363 | call convert_xmm_register |
||
2287 | heavyiron | 5364 | mov [postbyte_register],al |
1039 | heavyiron | 5365 | pinsr_xmmreg: |
2287 | heavyiron | 5366 | mov [operand_size],0 |
1039 | heavyiron | 5367 | lods byte [esi] |
5368 | cmp al,',' |
||
5369 | jne invalid_operand |
||
5370 | lods byte [esi] |
||
5371 | call get_size_operator |
||
5372 | cmp al,10h |
||
5373 | je pinsr_xmmreg_reg |
||
5374 | cmp al,'[' |
||
5375 | jne invalid_operand |
||
5376 | call get_address |
||
5377 | cmp [operand_size],0 |
||
5378 | je mmx_imm8 |
||
5379 | mov al,[mmx_size] |
||
5380 | cmp al,[operand_size] |
||
5381 | je mmx_imm8 |
||
5382 | jmp invalid_operand_size |
||
5383 | pinsr_xmmreg_reg: |
||
5384 | lods byte [esi] |
||
5385 | call convert_register |
||
5386 | mov bl,al |
||
5387 | cmp [mmx_size],8 |
||
5388 | je pinsrq_xmmreg_reg |
||
5389 | cmp ah,4 |
||
5390 | je mmx_nomem_imm8 |
||
5391 | jmp invalid_operand_size |
||
5392 | pinsrq_xmmreg_reg: |
||
5393 | cmp ah,8 |
||
5394 | je mmx_nomem_imm8 |
||
5395 | jmp invalid_operand_size |
||
5396 | pmovsxbw_instruction: |
||
5397 | mov [mmx_size],8 |
||
5398 | jmp pmovsx_instruction |
||
5399 | pmovsxbd_instruction: |
||
5400 | mov [mmx_size],4 |
||
5401 | jmp pmovsx_instruction |
||
5402 | pmovsxbq_instruction: |
||
5403 | mov [mmx_size],2 |
||
5404 | jmp pmovsx_instruction |
||
5405 | pmovsxwd_instruction: |
||
5406 | mov [mmx_size],8 |
||
5407 | jmp pmovsx_instruction |
||
5408 | pmovsxwq_instruction: |
||
5409 | mov [mmx_size],4 |
||
5410 | jmp pmovsx_instruction |
||
5411 | pmovsxdq_instruction: |
||
5412 | mov [mmx_size],8 |
||
5413 | pmovsx_instruction: |
||
5414 | call setup_66_0f_38 |
||
6467 | dunkaist | 5415 | lods byte [esi] |
1039 | heavyiron | 5416 | call get_size_operator |
5417 | cmp al,10h |
||
5418 | jne invalid_operand |
||
5419 | lods byte [esi] |
||
5420 | call convert_xmm_register |
||
2287 | heavyiron | 5421 | mov [postbyte_register],al |
1039 | heavyiron | 5422 | lods byte [esi] |
5423 | cmp al,',' |
||
5424 | jne invalid_operand |
||
5425 | mov [operand_size],0 |
||
5426 | lods byte [esi] |
||
5427 | call get_size_operator |
||
5428 | cmp al,10h |
||
5429 | je pmovsx_xmmreg_reg |
||
5430 | cmp al,'[' |
||
5431 | jne invalid_operand |
||
5432 | call get_address |
||
5433 | cmp [operand_size],0 |
||
5434 | je instruction_ready |
||
2665 | dunkaist | 5435 | mov al,[mmx_size] |
1039 | heavyiron | 5436 | cmp al,[operand_size] |
5437 | jne invalid_operand_size |
||
5438 | jmp instruction_ready |
||
1053 | heavyiron | 5439 | pmovsx_xmmreg_reg: |
1039 | heavyiron | 5440 | lods byte [esi] |
5441 | call convert_xmm_register |
||
2287 | heavyiron | 5442 | mov bl,al |
1039 | heavyiron | 5443 | jmp nomem_instruction_ready |
1053 | heavyiron | 5444 | setup_66_0f_38: |
6467 | dunkaist | 5445 | mov [extended_code],38h |
5446 | mov [supplemental_code],al |
||
5447 | mov [base_code],0Fh |
||
5448 | mov [opcode_prefix],66h |
||
5449 | ret |
||
5450 | |||
707 | heavyiron | 5451 | |
2287 | heavyiron | 5452 | call operand_64bit |
5453 | fxsave_instruction: |
||
31 | halyavin | 5454 | mov [extended_code],0AEh |
157 | heavyiron | 5455 | mov [base_code],0Fh |
5456 | mov [postbyte_register],al |
||
5457 | lods byte [esi] |
||
5458 | call get_size_operator |
||
5459 | cmp al,'[' |
||
5460 | jne invalid_operand |
||
5461 | call get_address |
||
5462 | mov ah,[operand_size] |
||
5463 | or ah,ah |
||
5464 | jz fxsave_size_ok |
||
5465 | mov al,[postbyte_register] |
||
5466 | cmp al,111b |
||
5467 | je clflush_size_check |
||
5468 | cmp al,10b |
||
5469 | jb invalid_operand_size |
||
5470 | cmp al,11b |
||
5471 | ja invalid_operand_size |
||
5472 | cmp ah,4 |
||
5473 | jne invalid_operand_size |
||
5474 | jmp fxsave_size_ok |
||
5475 | clflush_size_check: |
||
31 | halyavin | 5476 | cmp ah,1 |
157 | heavyiron | 5477 | jne invalid_operand_size |
5478 | fxsave_size_ok: |
||
31 | halyavin | 5479 | jmp instruction_ready |
1053 | heavyiron | 5480 | prefetch_instruction: |
31 | halyavin | 5481 | mov [extended_code],18h |
157 | heavyiron | 5482 | prefetch_mem_8bit: |
31 | halyavin | 5483 | mov [base_code],0Fh |
157 | heavyiron | 5484 | mov [postbyte_register],al |
5485 | lods byte [esi] |
||
5486 | call get_size_operator |
||
5487 | cmp al,'[' |
||
5488 | jne invalid_operand |
||
5489 | or ah,ah |
||
5490 | jz prefetch_size_ok |
||
5491 | cmp ah,1 |
||
5492 | jne invalid_operand_size |
||
5493 | prefetch_size_ok: |
||
31 | halyavin | 5494 | call get_address |
157 | heavyiron | 5495 | jmp instruction_ready |
1053 | heavyiron | 5496 | amd_prefetch_instruction: |
31 | halyavin | 5497 | mov [extended_code],0Dh |
157 | heavyiron | 5498 | jmp prefetch_mem_8bit |
5499 | clflushopt_instruction: |
||
6467 | dunkaist | 5500 | mov [extended_code],0AEh |
5501 | mov [opcode_prefix],66h |
||
5502 | jmp prefetch_mem_8bit |
||
5503 | pcommit_instruction: |
||
5504 | mov byte [edi],66h |
||
5505 | inc edi |
||
5506 | fence_instruction: |
||
31 | halyavin | 5507 | mov bl,al |
157 | heavyiron | 5508 | mov ax,0AE0Fh |
5509 | stos word [edi] |
||
5510 | mov al,bl |
||
5511 | stos byte [edi] |
||
5512 | jmp instruction_assembled |
||
5513 | pause_instruction: |
||
31 | halyavin | 5514 | mov ax,90F3h |
157 | heavyiron | 5515 | stos word [edi] |
5516 | jmp instruction_assembled |
||
5517 | movntq_instruction: |
||
31 | halyavin | 5518 | mov [mmx_size],8 |
157 | heavyiron | 5519 | jmp movnt_instruction |
5520 | movntpd_instruction: |
||
2287 | heavyiron | 5521 | mov [opcode_prefix],66h |
5522 | movntps_instruction: |
||
31 | halyavin | 5523 | mov [mmx_size],16 |
157 | heavyiron | 5524 | movnt_instruction: |
31 | halyavin | 5525 | mov [extended_code],al |
157 | heavyiron | 5526 | mov [base_code],0Fh |
5527 | lods byte [esi] |
||
5528 | call get_size_operator |
||
5529 | cmp al,'[' |
||
5530 | jne invalid_operand |
||
5531 | call get_address |
||
5532 | lods byte [esi] |
||
5533 | cmp al,',' |
||
5534 | jne invalid_operand |
||
5535 | lods byte [esi] |
||
5536 | call get_size_operator |
||
5537 | cmp al,10h |
||
5538 | jne invalid_operand |
||
5539 | lods byte [esi] |
||
5540 | call convert_mmx_register |
||
5541 | cmp ah,[mmx_size] |
||
5542 | jne invalid_operand_size |
||
5543 | mov [postbyte_register],al |
||
5544 | jmp instruction_ready |
||
1053 | heavyiron | 5545 | |
1039 | heavyiron | 5546 | |
5547 | mov [opcode_prefix],0F2h |
||
5548 | mov [mmx_size],8 |
||
5549 | jmp movnts_instruction |
||
5550 | movntss_instruction: |
||
5551 | mov [opcode_prefix],0F3h |
||
5552 | mov [mmx_size],4 |
||
5553 | movnts_instruction: |
||
5554 | mov [extended_code],al |
||
5555 | mov [base_code],0Fh |
||
5556 | lods byte [esi] |
||
5557 | call get_size_operator |
||
5558 | cmp al,'[' |
||
5559 | jne invalid_operand |
||
5560 | call get_address |
||
5561 | mov al,[operand_size] |
||
5562 | cmp al,[mmx_size] |
||
5563 | je movnts_size_ok |
||
5564 | test al,al |
||
5565 | jnz invalid_operand_size |
||
5566 | movnts_size_ok: |
||
5567 | lods byte [esi] |
||
5568 | cmp al,',' |
||
5569 | jne invalid_operand |
||
5570 | mov [operand_size],0 |
||
5571 | lods byte [esi] |
||
5572 | call get_size_operator |
||
5573 | cmp al,10h |
||
5574 | jne invalid_operand |
||
5575 | lods byte [esi] |
||
5576 | call convert_xmm_register |
||
2287 | heavyiron | 5577 | mov [postbyte_register],al |
1039 | heavyiron | 5578 | jmp instruction_ready |
1053 | heavyiron | 5579 | |
1039 | heavyiron | 5580 | |
31 | halyavin | 5581 | mov [base_code],0Fh |
157 | heavyiron | 5582 | mov [extended_code],al |
5583 | lods byte [esi] |
||
5584 | call get_size_operator |
||
5585 | cmp al,'[' |
||
5586 | jne invalid_operand |
||
5587 | call get_address |
||
5588 | lods byte [esi] |
||
5589 | cmp al,',' |
||
5590 | jne invalid_operand |
||
5591 | call take_register |
||
6467 | dunkaist | 5592 | cmp ah,4 |
157 | heavyiron | 5593 | je movnti_store |
5594 | cmp ah,8 |
||
5595 | jne invalid_operand_size |
||
5596 | call operand_64bit |
||
5597 | movnti_store: |
||
31 | halyavin | 5598 | mov [postbyte_register],al |
157 | heavyiron | 5599 | jmp instruction_ready |
1053 | heavyiron | 5600 | monitor_instruction: |
31 | halyavin | 5601 | mov [postbyte_register],al |
157 | heavyiron | 5602 | cmp byte [esi],0 |
1189 | heavyiron | 5603 | je monitor_instruction_store |
5604 | cmp byte [esi],0Fh |
||
5605 | je monitor_instruction_store |
||
5606 | call take_register |
||
6467 | dunkaist | 5607 | cmp ax,0400h |
157 | heavyiron | 5608 | jne invalid_operand |
5609 | lods byte [esi] |
||
5610 | cmp al,',' |
||
5611 | jne invalid_operand |
||
5612 | call take_register |
||
6467 | dunkaist | 5613 | cmp ax,0401h |
157 | heavyiron | 5614 | jne invalid_operand |
5615 | cmp [postbyte_register],0C8h |
||
5616 | jne monitor_instruction_store |
||
5617 | lods byte [esi] |
||
5618 | cmp al,',' |
||
5619 | jne invalid_operand |
||
5620 | call take_register |
||
6467 | dunkaist | 5621 | cmp ax,0402h |
157 | heavyiron | 5622 | jne invalid_operand |
5623 | monitor_instruction_store: |
||
31 | halyavin | 5624 | mov ax,010Fh |
157 | heavyiron | 5625 | stos word [edi] |
5626 | mov al,[postbyte_register] |
||
5627 | stos byte [edi] |
||
5628 | jmp instruction_assembled |
||
5629 | movntdqa_instruction: |
||
1039 | heavyiron | 5630 | call setup_66_0f_38 |
6467 | dunkaist | 5631 | lods byte [esi] |
1039 | heavyiron | 5632 | call get_size_operator |
5633 | cmp al,10h |
||
5634 | jne invalid_operand |
||
5635 | lods byte [esi] |
||
5636 | call convert_xmm_register |
||
2287 | heavyiron | 5637 | mov [postbyte_register],al |
1039 | heavyiron | 5638 | lods byte [esi] |
5639 | cmp al,',' |
||
5640 | jne invalid_operand |
||
5641 | lods byte [esi] |
||
5642 | call get_size_operator |
||
5643 | cmp al,'[' |
||
5644 | jne invalid_operand |
||
5645 | call get_address |
||
5646 | jmp instruction_ready |
||
1053 | heavyiron | 5647 | |
31 | halyavin | 5648 | |
1039 | heavyiron | 5649 | mov [opcode_prefix],66h |
5650 | mov [base_code],0Fh |
||
5651 | mov [extended_code],78h |
||
5652 | lods byte [esi] |
||
5653 | call get_size_operator |
||
5654 | cmp al,10h |
||
5655 | jne invalid_operand |
||
5656 | lods byte [esi] |
||
5657 | call convert_xmm_register |
||
2287 | heavyiron | 5658 | mov [postbyte_register],al |
1039 | heavyiron | 5659 | mov [operand_size],0 |
5660 | lods byte [esi] |
||
5661 | cmp al,',' |
||
5662 | jne invalid_operand |
||
5663 | lods byte [esi] |
||
5664 | call get_size_operator |
||
5665 | cmp al,10h |
||
5666 | je extrq_xmmreg_xmmreg |
||
5667 | test ah,not 1 |
||
5668 | jnz invalid_operand_size |
||
5669 | cmp al,'(' |
||
5670 | jne invalid_operand |
||
5671 | xor bl,bl |
||
5672 | xchg bl,[postbyte_register] |
||
1242 | heavyiron | 5673 | call store_nomem_instruction |
1039 | heavyiron | 5674 | call get_byte_value |
5675 | stosb |
||
5676 | call append_imm8 |
||
5677 | jmp instruction_assembled |
||
5678 | extrq_xmmreg_xmmreg: |
||
5679 | inc [extended_code] |
||
5680 | lods byte [esi] |
||
5681 | call convert_xmm_register |
||
2287 | heavyiron | 5682 | mov bl,al |
1039 | heavyiron | 5683 | jmp nomem_instruction_ready |
1053 | heavyiron | 5684 | insertq_instruction: |
1039 | heavyiron | 5685 | mov [opcode_prefix],0F2h |
5686 | mov [base_code],0Fh |
||
5687 | mov [extended_code],78h |
||
5688 | lods byte [esi] |
||
5689 | call get_size_operator |
||
5690 | cmp al,10h |
||
5691 | jne invalid_operand |
||
5692 | lods byte [esi] |
||
5693 | call convert_xmm_register |
||
2287 | heavyiron | 5694 | mov [postbyte_register],al |
1039 | heavyiron | 5695 | mov [operand_size],0 |
5696 | lods byte [esi] |
||
5697 | cmp al,',' |
||
5698 | jne invalid_operand |
||
5699 | lods byte [esi] |
||
5700 | call get_size_operator |
||
5701 | cmp al,10h |
||
5702 | jne invalid_operand |
||
5703 | lods byte [esi] |
||
5704 | call convert_xmm_register |
||
2287 | heavyiron | 5705 | mov bl,al |
1039 | heavyiron | 5706 | cmp byte [esi],',' |
5707 | je insertq_with_imm |
||
5708 | inc [extended_code] |
||
5709 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 5710 | insertq_with_imm: |
1039 | heavyiron | 5711 | call store_nomem_instruction |
5712 | call append_imm8 |
||
5713 | call append_imm8 |
||
5714 | jmp instruction_assembled |
||
5715 | |||
5716 | |||
5717 | mov [opcode_prefix],0F2h |
||
5718 | mov [base_code],0Fh |
||
5719 | mov [extended_code],38h |
||
5720 | mov [supplemental_code],0F0h |
||
5721 | call take_register |
||
6467 | dunkaist | 5722 | mov [postbyte_register],al |
1039 | heavyiron | 5723 | cmp ah,4 |
6467 | dunkaist | 5724 | je crc32_reg_size_ok |
5725 | cmp ah,8 |
||
1039 | heavyiron | 5726 | jne invalid_operand |
5727 | cmp [code_type],64 |
||
6467 | dunkaist | 5728 | jne illegal_instruction |
5729 | crc32_reg_size_ok: |
||
5730 | lods byte [esi] |
||
1039 | heavyiron | 5731 | cmp al,',' |
5732 | jne invalid_operand |
||
5733 | mov [operand_size],0 |
||
5734 | lods byte [esi] |
||
5735 | call get_size_operator |
||
5736 | cmp al,10h |
||
5737 | je crc32_reg_reg |
||
6467 | dunkaist | 5738 | cmp al,'[' |
1039 | heavyiron | 5739 | jne invalid_operand |
5740 | call get_address |
||
5741 | mov al,[operand_size] |
||
5742 | test al,al |
||
5743 | jz crc32_unknown_size |
||
5744 | cmp al,1 |
||
5745 | je crc32_reg_mem_store |
||
6467 | dunkaist | 5746 | inc [supplemental_code] |
1039 | heavyiron | 5747 | call operand_autodetect |
5748 | crc32_reg_mem_store: |
||
6467 | dunkaist | 5749 | jmp instruction_ready |
1053 | heavyiron | 5750 | crc32_unknown_size: |
1039 | heavyiron | 5751 | call recoverable_unknown_size |
2665 | dunkaist | 5752 | jmp crc32_reg_mem_store |
6467 | dunkaist | 5753 | crc32_reg_reg: |
5754 | lods byte [esi] |
||
1039 | heavyiron | 5755 | call convert_register |
5756 | mov bl,al |
||
5757 | mov al,ah |
||
5758 | cmp al,1 |
||
5759 | je crc32_reg_reg_store |
||
6467 | dunkaist | 5760 | inc [supplemental_code] |
1039 | heavyiron | 5761 | call operand_autodetect |
5762 | crc32_reg_reg_store: |
||
6467 | dunkaist | 5763 | jmp nomem_instruction_ready |
1053 | heavyiron | 5764 | popcnt_instruction: |
1039 | heavyiron | 5765 | mov [opcode_prefix],0F3h |
5766 | jmp bs_instruction |
||
5767 | movbe_instruction: |
||
1189 | heavyiron | 5768 | mov [supplemental_code],al |
5769 | mov [extended_code],38h |
||
5770 | mov [base_code],0Fh |
||
5771 | lods byte [esi] |
||
5772 | call get_size_operator |
||
5773 | cmp al,'[' |
||
5774 | je movbe_mem |
||
5775 | cmp al,10h |
||
5776 | jne invalid_operand |
||
5777 | lods byte [esi] |
||
5778 | call convert_register |
||
5779 | mov [postbyte_register],al |
||
5780 | lods byte [esi] |
||
5781 | cmp al,',' |
||
5782 | jne invalid_operand |
||
5783 | lods byte [esi] |
||
5784 | call get_size_operator |
||
5785 | cmp al,'[' |
||
5786 | jne invalid_argument |
||
5787 | call get_address |
||
5788 | mov al,[operand_size] |
||
5789 | call operand_autodetect |
||
5790 | jmp instruction_ready |
||
5791 | movbe_mem: |
||
5792 | inc [supplemental_code] |
||
5793 | call get_address |
||
5794 | push edx ebx ecx |
||
5795 | lods byte [esi] |
||
5796 | cmp al,',' |
||
5797 | jne invalid_operand |
||
5798 | call take_register |
||
6467 | dunkaist | 5799 | mov [postbyte_register],al |
1189 | heavyiron | 5800 | pop ecx ebx edx |
5801 | mov al,[operand_size] |
||
5802 | call operand_autodetect |
||
5803 | jmp instruction_ready |
||
5804 | adx_instruction: |
||
4039 | heavyiron | 5805 | mov [base_code],0Fh |
5806 | mov [extended_code],38h |
||
5807 | mov [supplemental_code],0F6h |
||
5808 | mov [operand_prefix],al |
||
5809 | call get_reg_mem |
||
5810 | jc adx_reg_reg |
||
5811 | mov al,[operand_size] |
||
5812 | cmp al,4 |
||
5813 | je instruction_ready |
||
5814 | cmp al,8 |
||
5815 | jne invalid_operand_size |
||
5816 | call operand_64bit |
||
5817 | jmp instruction_ready |
||
5818 | adx_reg_reg: |
||
5819 | cmp ah,4 |
||
5820 | je nomem_instruction_ready |
||
5821 | cmp ah,8 |
||
5822 | jne invalid_operand_size |
||
5823 | call operand_64bit |
||
5824 | jmp nomem_instruction_ready |
||
5825 | |||
1039 | heavyiron | 5826 | |
31 | halyavin | 5827 | mov [opcode_prefix],66h |
1039 | heavyiron | 5828 | jmp vmx_instruction |
157 | heavyiron | 5829 | vmxon_instruction: |
31 | halyavin | 5830 | mov [opcode_prefix],0F3h |
1039 | heavyiron | 5831 | vmx_instruction: |
31 | halyavin | 5832 | mov [postbyte_register],al |
157 | heavyiron | 5833 | mov [extended_code],0C7h |
5834 | lods byte [esi] |
||
5835 | call get_size_operator |
||
5836 | cmp al,'[' |
||
5837 | jne invalid_operand |
||
5838 | call get_address |
||
5839 | mov al,[operand_size] |
||
5840 | or al,al |
||
5841 | jz vmx_size_ok |
||
5842 | cmp al,8 |
||
5843 | jne invalid_operand_size |
||
5844 | vmx_size_ok: |
||
31 | halyavin | 5845 | mov [base_code],0Fh |
157 | heavyiron | 5846 | jmp instruction_ready |
1053 | heavyiron | 5847 | vmread_instruction: |
31 | halyavin | 5848 | mov [extended_code],78h |
157 | heavyiron | 5849 | lods byte [esi] |
5850 | call get_size_operator |
||
5851 | cmp al,10h |
||
607 | heavyiron | 5852 | je vmread_nomem |
5853 | cmp al,'[' |
||
157 | heavyiron | 5854 | jne invalid_operand |
5855 | call get_address |
||
5856 | lods byte [esi] |
||
5857 | cmp al,',' |
||
5858 | jne invalid_operand |
||
5859 | call take_register |
||
6467 | dunkaist | 5860 | mov [postbyte_register],al |
157 | heavyiron | 5861 | call vmread_check_size |
872 | heavyiron | 5862 | jmp vmx_size_ok |
607 | heavyiron | 5863 | vmread_nomem: |
5864 | lods byte [esi] |
||
5865 | call convert_register |
||
5866 | push eax |
||
5867 | call vmread_check_size |
||
5868 | lods byte [esi] |
||
5869 | cmp al,',' |
||
5870 | jne invalid_operand |
||
5871 | call take_register |
||
6467 | dunkaist | 5872 | mov [postbyte_register],al |
607 | heavyiron | 5873 | call vmread_check_size |
872 | heavyiron | 5874 | pop ebx |
607 | heavyiron | 5875 | mov [base_code],0Fh |
5876 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 5877 | vmread_check_size: |
31 | halyavin | 5878 | cmp [code_type],64 |
157 | heavyiron | 5879 | je vmread_long |
5880 | cmp [operand_size],4 |
||
5881 | jne invalid_operand_size |
||
607 | heavyiron | 5882 | ret |
5883 | vmread_long: |
||
31 | halyavin | 5884 | cmp [operand_size],8 |
157 | heavyiron | 5885 | jne invalid_operand_size |
607 | heavyiron | 5886 | ret |
5887 | vmwrite_instruction: |
||
31 | halyavin | 5888 | mov [extended_code],79h |
157 | heavyiron | 5889 | call take_register |
6467 | dunkaist | 5890 | mov [postbyte_register],al |
157 | heavyiron | 5891 | lods byte [esi] |
5892 | cmp al,',' |
||
5893 | jne invalid_operand |
||
5894 | lods byte [esi] |
||
5895 | call get_size_operator |
||
5896 | cmp al,10h |
||
607 | heavyiron | 5897 | je vmwrite_nomem |
5898 | cmp al,'[' |
||
157 | heavyiron | 5899 | jne invalid_operand |
5900 | call get_address |
||
5901 | call vmread_check_size |
||
607 | heavyiron | 5902 | jmp vmx_size_ok |
5903 | vmwrite_nomem: |
||
5904 | lods byte [esi] |
||
5905 | call convert_register |
||
5906 | mov bl,al |
||
5907 | mov [base_code],0Fh |
||
5908 | jmp nomem_instruction_ready |
||
1053 | heavyiron | 5909 | vmx_inv_instruction: |
1115 | heavyiron | 5910 | call setup_66_0f_38 |
6467 | dunkaist | 5911 | call take_register |
5912 | mov [postbyte_register],al |
||
1115 | heavyiron | 5913 | call vmread_check_size |
5914 | mov [operand_size],0 |
||
5915 | lods byte [esi] |
||
5916 | cmp al,',' |
||
5917 | jne invalid_operand |
||
5918 | lods byte [esi] |
||
5919 | call get_size_operator |
||
5920 | cmp al,'[' |
||
5921 | jne invalid_operand |
||
5922 | call get_address |
||
5923 | mov al,[operand_size] |
||
5924 | or al,al |
||
5925 | jz vmx_size_ok |
||
5926 | cmp al,16 |
||
5927 | jne invalid_operand_size |
||
5928 | jmp vmx_size_ok |
||
5929 | simple_svm_instruction: |
||
109 | heavyiron | 5930 | push eax |
157 | heavyiron | 5931 | mov [base_code],0Fh |
5932 | mov [extended_code],1 |
||
5933 | call take_register |
||
6467 | dunkaist | 5934 | or al,al |
157 | heavyiron | 5935 | jnz invalid_operand |
5936 | simple_svm_detect_size: |
||
109 | heavyiron | 5937 | cmp ah,2 |
157 | heavyiron | 5938 | je simple_svm_16bit |
5939 | cmp ah,4 |
||
5940 | je simple_svm_32bit |
||
5941 | cmp [code_type],64 |
||
5942 | jne invalid_operand_size |
||
5943 | jmp simple_svm_store |
||
5944 | simple_svm_16bit: |
||
109 | heavyiron | 5945 | cmp [code_type],16 |
157 | heavyiron | 5946 | je simple_svm_store |
5947 | cmp [code_type],64 |
||
5948 | je invalid_operand_size |
||
5949 | jmp prefixed_svm_store |
||
5950 | simple_svm_32bit: |
||
109 | heavyiron | 5951 | cmp [code_type],32 |
157 | heavyiron | 5952 | je simple_svm_store |
5953 | prefixed_svm_store: |
||
109 | heavyiron | 5954 | mov al,67h |
157 | heavyiron | 5955 | stos byte [edi] |
5956 | simple_svm_store: |
||
109 | heavyiron | 5957 | call store_classic_instruction_code |
6467 | dunkaist | 5958 | pop eax |
157 | heavyiron | 5959 | stos byte [edi] |
5960 | jmp instruction_assembled |
||
5961 | skinit_instruction: |
||
109 | heavyiron | 5962 | call take_register |
6467 | dunkaist | 5963 | cmp ax,0400h |
157 | heavyiron | 5964 | jne invalid_operand |
5965 | mov al,0DEh |
||
5966 | jmp simple_instruction_0f_01 |
||
6467 | dunkaist | 5967 | invlpga_instruction: |
109 | heavyiron | 5968 | push eax |
157 | heavyiron | 5969 | mov [base_code],0Fh |
5970 | mov [extended_code],1 |
||
5971 | call take_register |
||
6467 | dunkaist | 5972 | or al,al |
157 | heavyiron | 5973 | jnz invalid_operand |
5974 | mov bl,ah |
||
5975 | mov [operand_size],0 |
||
5976 | lods byte [esi] |
||
5977 | cmp al,',' |
||
5978 | jne invalid_operand |
||
5979 | call take_register |
||
6467 | dunkaist | 5980 | cmp ax,0401h |
157 | heavyiron | 5981 | jne invalid_operand |
5982 | mov ah,bl |
||
5983 | jmp simple_svm_detect_size |
||
5984 | |||
31 | halyavin | 5985 | |
2287 | heavyiron | 5986 | mov [base_code],0Fh |
5987 | mov [extended_code],0C7h |
||
5988 | mov [postbyte_register],al |
||
5989 | call take_register |
||
6467 | dunkaist | 5990 | mov bl,al |
2287 | heavyiron | 5991 | mov al,ah |
5992 | call operand_autodetect |
||
5993 | jmp nomem_instruction_ready |
||
5994 | rdfsbase_instruction: |
||
5995 | cmp [code_type],64 |
||
2665 | dunkaist | 5996 | jne illegal_instruction |
5997 | mov [opcode_prefix],0F3h |
||
2287 | heavyiron | 5998 | mov [base_code],0Fh |
5999 | mov [extended_code],0AEh |
||
6000 | mov [postbyte_register],al |
||
6001 | call take_register |
||
6467 | dunkaist | 6002 | mov bl,al |
2287 | heavyiron | 6003 | mov al,ah |
6004 | cmp ah,2 |
||
6005 | je invalid_operand_size |
||
6006 | call operand_autodetect |
||
6007 | jmp nomem_instruction_ready |
||
6008 | |||
6009 | |||
2665 | dunkaist | 6010 | lods byte [esi] |
6011 | call get_size_operator |
||
6012 | cmp ah,1 |
||
6013 | ja invalid_operand_size |
||
6014 | cmp al,'(' |
||
6015 | jne invalid_operand |
||
6016 | call get_byte_value |
||
6017 | mov dl,al |
||
6018 | mov ax,0F8C6h |
||
6019 | stos word [edi] |
||
6020 | mov al,dl |
||
6021 | stos byte [edi] |
||
6022 | jmp instruction_assembled |
||
6023 | xbegin_instruction: |
||
6024 | lods byte [esi] |
||
6025 | cmp al,'(' |
||
6026 | jne invalid_operand |
||
6027 | mov al,[code_type] |
||
6028 | cmp al,64 |
||
6029 | je xbegin_64bit |
||
6030 | cmp al,32 |
||
6031 | je xbegin_32bit |
||
6032 | xbegin_16bit: |
||
6033 | call get_address_word_value |
||
6034 | add edi,4 |
||
6035 | mov ebp,[addressing_space] |
||
4039 | heavyiron | 6036 | call calculate_relative_offset |
2665 | dunkaist | 6037 | sub edi,4 |
6038 | shl eax,16 |
||
6039 | mov ax,0F8C7h |
||
6040 | stos dword [edi] |
||
6041 | jmp instruction_assembled |
||
6042 | xbegin_32bit: |
||
6043 | call get_address_dword_value |
||
6044 | jmp xbegin_address_ok |
||
6045 | xbegin_64bit: |
||
6046 | call get_address_qword_value |
||
6047 | xbegin_address_ok: |
||
6048 | add edi,5 |
||
6049 | mov ebp,[addressing_space] |
||
4039 | heavyiron | 6050 | call calculate_relative_offset |
2665 | dunkaist | 6051 | sub edi,5 |
6052 | mov edx,eax |
||
6053 | cwde |
||
6054 | cmp eax,edx |
||
6055 | jne xbegin_rel32 |
||
6056 | mov al,66h |
||
6057 | stos byte [edi] |
||
6058 | mov eax,edx |
||
6059 | shl eax,16 |
||
6060 | mov ax,0F8C7h |
||
6061 | stos dword [edi] |
||
6062 | jmp instruction_assembled |
||
6063 | xbegin_rel32: |
||
6064 | sub edx,1 |
||
6065 | jno xbegin_rel32_ok |
||
6066 | cmp [code_type],64 |
||
6067 | je jump_out_of_range |
||
6467 | dunkaist | 6068 | xbegin_rel32_ok: |
2665 | dunkaist | 6069 | mov ax,0F8C7h |
6070 | stos word [edi] |
||
6071 | mov eax,edx |
||
6072 | stos dword [edi] |
||
6073 | jmp instruction_assembled |
||
6074 | |||
6075 | |||
6467 | dunkaist | 6076 | mov ah,0F3h |
6077 | jmp bndc_instruction |
||
6078 | bndcu_instruction: |
||
6079 | mov ah,0F2h |
||
6080 | bndc_instruction: |
||
6081 | mov [opcode_prefix],ah |
||
6082 | mov [base_code],0Fh |
||
6083 | mov [extended_code],al |
||
6084 | call take_bnd_register |
||
6085 | mov [postbyte_register],al |
||
6086 | call get_bnd_size |
||
6087 | mov [operand_size],al |
||
6088 | lods byte [esi] |
||
6089 | cmp al,',' |
||
6090 | jne invalid_operand |
||
6091 | lods byte [esi] |
||
6092 | call get_size_operator |
||
6093 | cmp al,'[' |
||
6094 | je bndc_mem |
||
6095 | cmp al,10h |
||
6096 | jne invalid_operand |
||
6097 | lods byte [esi] |
||
6098 | call convert_register |
||
6099 | mov bl,al |
||
6100 | jmp nomem_instruction_ready |
||
6101 | bndc_mem: |
||
6102 | call get_address_of_required_size |
||
6103 | jmp instruction_ready |
||
6104 | bndmov_instruction: |
||
6105 | mov [opcode_prefix],66h |
||
6106 | mov [base_code],0Fh |
||
6107 | mov [extended_code],al |
||
6108 | call get_bnd_size |
||
6109 | shl al,1 |
||
6110 | mov [operand_size],al |
||
6111 | lods byte [esi] |
||
6112 | cmp al,14h |
||
6113 | je bndmov_reg |
||
6114 | call get_size_operator |
||
6115 | cmp al,'[' |
||
6116 | jne invalid_operand |
||
6117 | inc [extended_code] |
||
6118 | call get_address_of_required_size |
||
6119 | lods byte [esi] |
||
6120 | cmp al,',' |
||
6121 | jne invalid_operand |
||
6122 | call take_bnd_register |
||
6123 | mov [postbyte_register],al |
||
6124 | jmp instruction_ready |
||
6125 | bndmov_reg: |
||
6126 | lods byte [esi] |
||
6127 | call convert_bnd_register |
||
6128 | mov [postbyte_register],al |
||
6129 | lods byte [esi] |
||
6130 | cmp al,',' |
||
6131 | jne invalid_operand |
||
6132 | lods byte [esi] |
||
6133 | cmp al,14h |
||
6134 | je bndmov_reg_reg |
||
6135 | call get_size_operator |
||
6136 | cmp al,'[' |
||
6137 | jne invalid_operand |
||
6138 | call get_address_of_required_size |
||
6139 | jmp instruction_ready |
||
6140 | bndmov_reg_reg: |
||
6141 | lods byte [esi] |
||
6142 | call convert_bnd_register |
||
6143 | mov bl,al |
||
6144 | jmp nomem_instruction_ready |
||
6145 | take_bnd_register: |
||
6146 | lods byte [esi] |
||
6147 | cmp al,14h |
||
6148 | jne invalid_operand |
||
6149 | lods byte [esi] |
||
6150 | convert_bnd_register: |
||
6151 | mov ah,al |
||
6152 | shr ah,4 |
||
6153 | cmp ah,6 |
||
6154 | jne invalid_operand |
||
6155 | and al,1111b |
||
6156 | ret |
||
6157 | bndmk_instruction: |
||
6158 | mov [opcode_prefix],0F3h |
||
6159 | mov [base_code],0Fh |
||
6160 | mov [extended_code],al |
||
6161 | call take_bnd_register |
||
6162 | mov [postbyte_register],al |
||
6163 | lods byte [esi] |
||
6164 | cmp al,',' |
||
6165 | jne invalid_operand |
||
6166 | lods byte [esi] |
||
6167 | call get_size_operator |
||
6168 | cmp al,'[' |
||
6169 | jne invalid_operand |
||
6170 | call get_bnd_size |
||
6171 | call get_address_prefixes |
||
6172 | call get_address_component |
||
6173 | cmp byte [esi-1],']' |
||
6174 | je bndmk_ready |
||
6175 | lods byte [esi] |
||
6176 | cmp al,',' |
||
6177 | jne invalid_operand |
||
6178 | lods byte [esi] |
||
6179 | cmp al,'(' |
||
6180 | jne invalid_operand |
||
6181 | or dl,bl |
||
6182 | or dl,[address_sign] |
||
6183 | or edx,[address_high] |
||
6184 | jnz invalid_address |
||
6185 | mov [address_register],bh |
||
6186 | call get_address_component |
||
6187 | lods byte [esi] |
||
6188 | cmp al,']' |
||
6189 | jne invalid_operand |
||
6190 | or bh,bh |
||
6191 | jz bndmk_selected_base |
||
6192 | cmp bl,bh |
||
6193 | je bndmk_to_index |
||
6194 | or bl,bl |
||
6195 | jnz invalid_address |
||
6196 | mov bl,bh |
||
6197 | bndmk_to_index: |
||
6198 | inc cl |
||
6199 | bndmk_selected_base: |
||
6200 | mov bh,[address_register] |
||
6201 | bndmk_ready: |
||
6202 | or bx,bx |
||
6203 | jz instruction_ready |
||
6204 | cmp [address_size_declared],0 |
||
6205 | jne instruction_ready |
||
6206 | and ch,not 0Fh |
||
6207 | jmp instruction_ready |
||
6208 | get_bnd_size: |
||
6209 | mov al,4 |
||
6210 | cmp [code_type],64 |
||
6211 | jne bnd_size_ok |
||
6212 | add al,4 |
||
6213 | bnd_size_ok: |
||
6214 | mov [address_size],al |
||
6215 | ret |
||
6216 | get_address_component: |
||
6217 | mov [free_address_range],0 |
||
6218 | call calculate_address |
||
6219 | mov [address_high],edx |
||
6220 | mov edx,eax |
||
6221 | or bx,bx |
||
6222 | jz address_component_ok |
||
6223 | mov al,bl |
||
6224 | or al,bh |
||
6225 | shr al,4 |
||
6226 | cmp al,[address_size] |
||
6227 | jne invalid_address |
||
6228 | address_component_ok: |
||
6229 | ret |
||
6230 | bndldx_instruction: |
||
6231 | mov [base_code],0Fh |
||
6232 | mov [extended_code],al |
||
6233 | call take_bnd_register |
||
6234 | mov [postbyte_register],al |
||
6235 | lods byte [esi] |
||
6236 | cmp al,',' |
||
6237 | jne invalid_operand |
||
6238 | call take_bnd_mib |
||
6239 | jmp bndmk_ready |
||
6240 | bndstx_instruction: |
||
6241 | mov [base_code],0Fh |
||
6242 | mov [extended_code],al |
||
6243 | call take_bnd_mib |
||
6244 | lods byte [esi] |
||
6245 | cmp al,',' |
||
6246 | jne invalid_operand |
||
6247 | call take_bnd_register |
||
6248 | mov [postbyte_register],al |
||
6249 | jmp bndmk_ready |
||
6250 | take_bnd_mib: |
||
6251 | lods byte [esi] |
||
6252 | cmp al,'[' |
||
6253 | jne invalid_operand |
||
6254 | call get_bnd_size |
||
6255 | call get_address_prefixes |
||
6256 | call get_address_component |
||
6257 | cmp byte [esi-1],']' |
||
6258 | je bnd_mib_ok |
||
6259 | lods byte [esi] |
||
6260 | cmp al,',' |
||
6261 | jne invalid_operand |
||
6262 | lods byte [esi] |
||
6263 | cmp al,'(' |
||
6264 | jne invalid_operand |
||
6265 | mov al,[address_sign] |
||
6266 | push eax ebx ecx edx [address_symbol] |
||
6267 | call get_address_component |
||
6268 | lods byte [esi] |
||
6269 | cmp al,']' |
||
6270 | jne invalid_operand |
||
6271 | or dl,bl |
||
6272 | or dl,[address_sign] |
||
6273 | or edx,[address_high] |
||
6274 | jnz invalid_address |
||
6275 | mov [address_register],bh |
||
6276 | pop [address_symbol] edx ecx ebx eax |
||
6277 | mov [address_sign],al |
||
6278 | or bl,bl |
||
6279 | jz mib_place_index |
||
6280 | or bh,bh |
||
6281 | jnz invalid_address |
||
6282 | cmp cl,1 |
||
6283 | jne invalid_address |
||
6284 | mov bh,bl |
||
6285 | mib_place_index: |
||
6286 | mov bl,[address_register] |
||
6287 | xor cl,cl |
||
6288 | or al,al |
||
6289 | jz bnd_mib_ok |
||
6290 | inc cl |
||
6291 | bnd_mib_ok: |
||
6292 | ret |
||
6293 | |||
6294 | |||
6295 | lods byte [esi] |
||
6296 | call get_size_operator |
||
6297 | cmp al,10h |
||
6298 | jne invalid_operand |
||
6299 | lods byte [esi] |
||
6300 | convert_register: |
||
31 | halyavin | 6301 | mov ah,al |
157 | heavyiron | 6302 | shr ah,4 |
6303 | and al,0Fh |
||
6304 | cmp ah,8 |
||
6305 | je match_register_size |
||
6306 | cmp ah,4 |
||
6307 | ja invalid_operand |
||
6308 | cmp ah,1 |
||
6309 | ja match_register_size |
||
6310 | cmp al,4 |
||
6311 | jb match_register_size |
||
6312 | or ah,ah |
||
6313 | jz high_byte_register |
||
6314 | or [rex_prefix],40h |
||
6315 | match_register_size: |
||
31 | halyavin | 6316 | cmp ah,[operand_size] |
157 | heavyiron | 6317 | je register_size_ok |
6318 | cmp [operand_size],0 |
||
6319 | jne operand_sizes_do_not_match |
||
6320 | mov [operand_size],ah |
||
6321 | register_size_ok: |
||
31 | halyavin | 6322 | ret |
157 | heavyiron | 6323 | high_byte_register: |
31 | halyavin | 6324 | mov ah,1 |
157 | heavyiron | 6325 | or [rex_prefix],10h |
6467 | dunkaist | 6326 | jmp match_register_size |
157 | heavyiron | 6327 | convert_fpu_register: |
31 | halyavin | 6328 | mov ah,al |
157 | heavyiron | 6329 | shr ah,4 |
6330 | and al,111b |
||
6331 | cmp ah,10 |
||
6332 | jne invalid_operand |
||
6333 | jmp match_register_size |
||
6334 | convert_mmx_register: |
||
31 | halyavin | 6335 | mov ah,al |
157 | heavyiron | 6336 | shr ah,4 |
6337 | cmp ah,0Ch |
||
6338 | je xmm_register |
||
6339 | ja invalid_operand |
||
6340 | and al,111b |
||
6341 | cmp ah,0Bh |
||
6342 | jne invalid_operand |
||
6343 | mov ah,8 |
||
6344 | jmp match_register_size |
||
6345 | xmm_register: |
||
31 | halyavin | 6346 | and al,0Fh |
157 | heavyiron | 6347 | mov ah,16 |
6348 | cmp al,8 |
||
6349 | jb match_register_size |
||
6350 | cmp [code_type],64 |
||
6351 | jne invalid_operand |
||
6352 | jmp match_register_size |
||
6353 | convert_xmm_register: |
||
2287 | heavyiron | 6354 | mov ah,al |
6355 | shr ah,4 |
||
6356 | cmp ah,0Ch |
||
6357 | je xmm_register |
||
6358 | jmp invalid_operand |
||
6359 | get_size_operator: |
||
31 | halyavin | 6360 | xor ah,ah |
157 | heavyiron | 6361 | cmp al,11h |
6362 | jne no_size_operator |
||
6363 | mov [size_declared],1 |
||
6364 | lods word [esi] |
||
6365 | xchg al,ah |
||
6366 | or [operand_flags],1 |
||
6467 | dunkaist | 6367 | cmp ah,[operand_size] |
157 | heavyiron | 6368 | je size_operator_ok |
6369 | cmp [operand_size],0 |
||
6370 | jne operand_sizes_do_not_match |
||
6371 | mov [operand_size],ah |
||
6372 | size_operator_ok: |
||
31 | halyavin | 6373 | ret |
157 | heavyiron | 6374 | no_size_operator: |
31 | halyavin | 6375 | mov [size_declared],0 |
157 | heavyiron | 6376 | cmp al,'[' |
6377 | jne size_operator_ok |
||
6378 | and [operand_flags],not 1 |
||
6467 | dunkaist | 6379 | ret |
157 | heavyiron | 6380 | get_jump_operator: |
31 | halyavin | 6381 | mov [jump_type],0 |
157 | heavyiron | 6382 | cmp al,12h |
6383 | jne jump_operator_ok |
||
6384 | lods word [esi] |
||
6385 | mov [jump_type],al |
||
6386 | mov al,ah |
||
6387 | jump_operator_ok: |
||
31 | halyavin | 6388 | ret |
157 | heavyiron | 6389 | get_address: |
31 | halyavin | 6390 | and [address_size],0 |
6467 | dunkaist | 6391 | get_address_of_required_size: |
6392 | call get_address_prefixes |
||
6393 | and [free_address_range],0 |
||
6394 | call calculate_address |
||
157 | heavyiron | 6395 | cmp byte [esi-1],']' |
6396 | jne invalid_address |
||
6397 | mov [address_high],edx |
||
6398 | mov edx,eax |
||
6399 | cmp [address_size_declared],0 |
||
6467 | dunkaist | 6400 | jne address_ok |
6401 | or bx,bx |
||
6402 | jnz clear_address_size |
||
6403 | cmp [code_type],64 |
||
157 | heavyiron | 6404 | jne address_ok |
6405 | calculate_relative_address: |
||
31 | halyavin | 6406 | mov edx,[address_symbol] |
196 | heavyiron | 6407 | mov [symbol_identifier],edx |
6408 | mov edx,[address_high] |
||
176 | heavyiron | 6409 | mov ebp,[addressing_space] |
4039 | heavyiron | 6410 | call calculate_relative_offset |
157 | heavyiron | 6411 | mov [address_high],edx |
6412 | cdq |
||
176 | heavyiron | 6413 | cmp edx,[address_high] |
6414 | je address_high_ok |
||
707 | heavyiron | 6415 | call recoverable_overflow |
2665 | dunkaist | 6416 | address_high_ok: |
707 | heavyiron | 6417 | mov edx,eax |
157 | heavyiron | 6418 | ror ecx,16 |
205 | heavyiron | 6419 | mov cl,[value_type] |
6420 | rol ecx,16 |
||
6421 | mov bx,9900h |
||
6467 | dunkaist | 6422 | clear_address_size: |
6423 | and ch,not 0Fh |
||
6424 | address_ok: |
||
31 | halyavin | 6425 | ret |
157 | heavyiron | 6426 | get_address_prefixes: |
6467 | dunkaist | 6427 | and [segment_register],0 |
6428 | and [address_size_declared],0 |
||
6429 | mov al,[code_type] |
||
6430 | shr al,3 |
||
6431 | mov [value_size],al |
||
6432 | mov al,[esi] |
||
6433 | and al,11110000b |
||
6434 | cmp al,60h |
||
6435 | jne get_address_size_prefix |
||
6436 | lods byte [esi] |
||
6437 | sub al,60h |
||
6438 | mov [segment_register],al |
||
6439 | mov al,[esi] |
||
6440 | and al,11110000b |
||
6441 | get_address_size_prefix: |
||
6442 | cmp al,70h |
||
6443 | jne address_size_prefix_ok |
||
6444 | lods byte [esi] |
||
6445 | sub al,70h |
||
6446 | cmp al,2 |
||
6447 | jb invalid_address_size |
||
6448 | cmp al,8 |
||
6449 | ja invalid_address_size |
||
6450 | mov [value_size],al |
||
6451 | or [address_size_declared],1 |
||
6452 | or [address_size],al |
||
6453 | cmp al,[address_size] |
||
6454 | jne invalid_address_size |
||
6455 | address_size_prefix_ok: |
||
6456 | ret |
||
6457 | operand_16bit: |
||
31 | halyavin | 6458 | cmp [code_type],16 |
157 | heavyiron | 6459 | je size_prefix_ok |
6460 | mov [operand_prefix],66h |
||
6461 | ret |
||
6462 | operand_32bit: |
||
31 | halyavin | 6463 | cmp [code_type],16 |
157 | heavyiron | 6464 | jne size_prefix_ok |
6465 | mov [operand_prefix],66h |
||
6466 | size_prefix_ok: |
||
31 | halyavin | 6467 | ret |
157 | heavyiron | 6468 | operand_64bit: |
31 | halyavin | 6469 | cmp [code_type],64 |
157 | heavyiron | 6470 | jne illegal_instruction |
6471 | or [rex_prefix],48h |
||
6472 | ret |
||
6473 | operand_autodetect: |
||
31 | halyavin | 6474 | cmp al,2 |
157 | heavyiron | 6475 | je operand_16bit |
6476 | cmp al,4 |
||
6477 | je operand_32bit |
||
6478 | cmp al,8 |
||
6479 | je operand_64bit |
||
6480 | jmp invalid_operand_size |
||
6481 | store_segment_prefix_if_necessary: |
||
31 | halyavin | 6482 | mov al,[segment_register] |
157 | heavyiron | 6483 | or al,al |
6484 | jz segment_prefix_ok |
||
6485 | cmp al,4 |
||
2287 | heavyiron | 6486 | ja segment_prefix_386 |
6487 | cmp [code_type],64 |
||
6488 | je segment_prefix_ok |
||
6489 | cmp al,3 |
||
157 | heavyiron | 6490 | je ss_prefix |
6491 | jb segment_prefix_86 |
||
6492 | cmp bl,25h |
||
6493 | je segment_prefix_86 |
||
6494 | cmp bh,25h |
||
6495 | je segment_prefix_86 |
||
6496 | cmp bh,45h |
||
6497 | je segment_prefix_86 |
||
6498 | cmp bh,44h |
||
6499 | je segment_prefix_86 |
||
6500 | ret |
||
6501 | ss_prefix: |
||
31 | halyavin | 6502 | cmp bl,25h |
157 | heavyiron | 6503 | je segment_prefix_ok |
6504 | cmp bh,25h |
||
6505 | je segment_prefix_ok |
||
6506 | cmp bh,45h |
||
6507 | je segment_prefix_ok |
||
6508 | cmp bh,44h |
||
6509 | je segment_prefix_ok |
||
6510 | jmp segment_prefix_86 |
||
6511 | store_segment_prefix: |
||
31 | halyavin | 6512 | mov al,[segment_register] |
157 | heavyiron | 6513 | or al,al |
6514 | jz segment_prefix_ok |
||
6515 | cmp al,5 |
||
6516 | jae segment_prefix_386 |
||
6517 | segment_prefix_86: |
||
31 | halyavin | 6518 | dec al |
157 | heavyiron | 6519 | shl al,3 |
6520 | add al,26h |
||
6521 | stos byte [edi] |
||
6522 | jmp segment_prefix_ok |
||
6523 | segment_prefix_386: |
||
31 | halyavin | 6524 | add al,64h-5 |
157 | heavyiron | 6525 | stos byte [edi] |
6526 | segment_prefix_ok: |
||
31 | halyavin | 6527 | ret |
157 | heavyiron | 6528 | store_instruction_code: |
31 | halyavin | 6529 | cmp [vex_required],0 |
2287 | heavyiron | 6530 | jne store_vex_instruction_code |
6531 | store_classic_instruction_code: |
||
6467 | dunkaist | 6532 | mov al,[operand_prefix] |
157 | heavyiron | 6533 | or al,al |
6534 | jz operand_prefix_ok |
||
6535 | stos byte [edi] |
||
6536 | operand_prefix_ok: |
||
31 | halyavin | 6537 | mov al,[opcode_prefix] |
1039 | heavyiron | 6538 | or al,al |
6539 | jz opcode_prefix_ok |
||
6540 | stos byte [edi] |
||
6541 | opcode_prefix_ok: |
||
6542 | mov al,[rex_prefix] |
||
157 | heavyiron | 6543 | test al,40h |
6544 | jz rex_prefix_ok |
||
6545 | cmp [code_type],64 |
||
6546 | jne invalid_operand |
||
6547 | test al,0B0h |
||
6548 | jnz disallowed_combination_of_registers |
||
2665 | dunkaist | 6549 | stos byte [edi] |
157 | heavyiron | 6550 | rex_prefix_ok: |
31 | halyavin | 6551 | mov al,[base_code] |
157 | heavyiron | 6552 | stos byte [edi] |
6553 | cmp al,0Fh |
||
6554 | jne instruction_code_ok |
||
6555 | store_extended_code: |
||
31 | halyavin | 6556 | mov al,[extended_code] |
157 | heavyiron | 6557 | stos byte [edi] |
6558 | cmp al,38h |
||
174 | heavyiron | 6559 | je store_supplemental_code |
6560 | cmp al,3Ah |
||
6561 | je store_supplemental_code |
||
6562 | instruction_code_ok: |
||
31 | halyavin | 6563 | ret |
157 | heavyiron | 6564 | store_supplemental_code: |
174 | heavyiron | 6565 | mov al,[supplemental_code] |
6566 | stos byte [edi] |
||
6567 | ret |
||
6568 | store_nomem_instruction: |
||
31 | halyavin | 6569 | test [postbyte_register],10000b |
6467 | dunkaist | 6570 | jz nomem_reg_high_code_ok |
6571 | or [vex_required],10h |
||
6572 | and [postbyte_register],1111b |
||
6573 | nomem_reg_high_code_ok: |
||
6574 | test [postbyte_register],1000b |
||
157 | heavyiron | 6575 | jz nomem_reg_code_ok |
6576 | or [rex_prefix],44h |
||
6577 | and [postbyte_register],111b |
||
6578 | nomem_reg_code_ok: |
||
31 | halyavin | 6579 | test bl,10000b |
6467 | dunkaist | 6580 | jz nomem_rm_high_code_ok |
6581 | or [rex_prefix],42h |
||
6582 | or [vex_required],8 |
||
6583 | and bl,1111b |
||
6584 | nomem_rm_high_code_ok: |
||
6585 | test bl,1000b |
||
157 | heavyiron | 6586 | jz nomem_rm_code_ok |
6587 | or [rex_prefix],41h |
||
6588 | and bl,111b |
||
6589 | nomem_rm_code_ok: |
||
31 | halyavin | 6590 | and [displacement_compression],0 |
6467 | dunkaist | 6591 | call store_instruction_code |
157 | heavyiron | 6592 | mov al,[postbyte_register] |
6593 | shl al,3 |
||
6594 | or al,bl |
||
6595 | or al,11000000b |
||
6596 | stos byte [edi] |
||
6597 | ret |
||
6598 | store_instruction: |
||
31 | halyavin | 6599 | mov [current_offset],edi |
157 | heavyiron | 6600 | and [displacement_compression],0 |
6467 | dunkaist | 6601 | test [postbyte_register],10000b |
6602 | jz reg_high_code_ok |
||
6603 | or [vex_required],10h |
||
6604 | and [postbyte_register],1111b |
||
6605 | reg_high_code_ok: |
||
6606 | test [postbyte_register],1000b |
||
157 | heavyiron | 6607 | jz reg_code_ok |
6608 | or [rex_prefix],44h |
||
6609 | and [postbyte_register],111b |
||
6610 | reg_code_ok: |
||
31 | halyavin | 6611 | cmp [code_type],64 |
2287 | heavyiron | 6612 | jne address_value_ok |
6613 | xor eax,eax |
||
6614 | bt edx,31 |
||
6615 | sbb eax,[address_high] |
||
6616 | jz address_value_ok |
||
6617 | cmp [address_high],0 |
||
6618 | jne address_value_out_of_range |
||
6619 | test ch,44h |
||
6620 | jnz address_value_ok |
||
6621 | test bx,8080h |
||
6622 | jz address_value_ok |
||
6623 | address_value_out_of_range: |
||
6624 | call recoverable_overflow |
||
2665 | dunkaist | 6625 | address_value_ok: |
2287 | heavyiron | 6626 | call store_segment_prefix_if_necessary |
157 | heavyiron | 6627 | test [vex_required],4 |
2665 | dunkaist | 6628 | jnz address_vsib |
6629 | or bx,bx |
||
157 | heavyiron | 6630 | jz address_immediate |
6631 | cmp bx,9800h |
||
6467 | dunkaist | 6632 | je address_rip_based |
157 | heavyiron | 6633 | cmp bx,9400h |
6467 | dunkaist | 6634 | je address_eip_based |
176 | heavyiron | 6635 | cmp bx,9900h |
6467 | dunkaist | 6636 | je address_relative |
157 | heavyiron | 6637 | mov al,bl |
6638 | or al,bh |
||
6639 | and al,11110000b |
||
6640 | cmp al,80h |
||
6641 | je postbyte_64bit |
||
6642 | cmp al,40h |
||
6643 | je postbyte_32bit |
||
6644 | cmp al,20h |
||
6645 | jne invalid_address |
||
6646 | cmp [code_type],64 |
||
6647 | je invalid_address_size |
||
6648 | call address_16bit_prefix |
||
6649 | test ch,22h |
||
6467 | dunkaist | 6650 | setz [displacement_compression] |
6651 | call store_instruction_code |
||
157 | heavyiron | 6652 | cmp bl,bh |
1053 | heavyiron | 6653 | jbe determine_16bit_address |
6654 | xchg bl,bh |
||
6655 | determine_16bit_address: |
||
6656 | cmp bx,2600h |
||
157 | heavyiron | 6657 | je address_si |
6658 | cmp bx,2700h |
||
6659 | je address_di |
||
6660 | cmp bx,2300h |
||
6661 | je address_bx |
||
6662 | cmp bx,2500h |
||
6663 | je address_bp |
||
6664 | cmp bx,2625h |
||
1053 | heavyiron | 6665 | je address_bp_si |
6666 | cmp bx,2725h |
||
6667 | je address_bp_di |
||
6668 | cmp bx,2723h |
||
6669 | je address_bx_di |
||
6670 | cmp bx,2623h |
||
6671 | jne invalid_address |
||
6672 | address_bx_si: |
||
31 | halyavin | 6673 | xor al,al |
157 | heavyiron | 6674 | jmp postbyte_16bit |
6675 | address_bx_di: |
||
31 | halyavin | 6676 | mov al,1 |
157 | heavyiron | 6677 | jmp postbyte_16bit |
6678 | address_bp_si: |
||
31 | halyavin | 6679 | mov al,10b |
157 | heavyiron | 6680 | jmp postbyte_16bit |
6681 | address_bp_di: |
||
31 | halyavin | 6682 | mov al,11b |
157 | heavyiron | 6683 | jmp postbyte_16bit |
6684 | address_si: |
||
31 | halyavin | 6685 | mov al,100b |
157 | heavyiron | 6686 | jmp postbyte_16bit |
6687 | address_di: |
||
31 | halyavin | 6688 | mov al,101b |
157 | heavyiron | 6689 | jmp postbyte_16bit |
6690 | address_bx: |
||
31 | halyavin | 6691 | mov al,111b |
157 | heavyiron | 6692 | jmp postbyte_16bit |
6693 | address_bp: |
||
31 | halyavin | 6694 | mov al,110b |
157 | heavyiron | 6695 | postbyte_16bit: |
31 | halyavin | 6696 | test ch,22h |
157 | heavyiron | 6697 | jnz address_16bit_value |
6698 | or ch,ch |
||
6699 | jnz address_sizes_do_not_agree |
||
6700 | cmp edx,10000h |
||
6701 | jge value_out_of_range |
||
6702 | cmp edx,-8000h |
||
6703 | jl value_out_of_range |
||
6704 | or dx,dx |
||
6705 | jz address |
||
6706 | cmp [displacement_compression],2 |
||
6467 | dunkaist | 6707 | ja address_8bit_value |
6708 | je address_16bit_value |
||
6709 | cmp dx,80h |
||
157 | heavyiron | 6710 | jb address_8bit_value |
6711 | cmp dx,-80h |
||
6712 | jae address_8bit_value |
||
6713 | address_16bit_value: |
||
31 | halyavin | 6714 | or al,10000000b |
157 | heavyiron | 6715 | mov cl,[postbyte_register] |
6716 | shl cl,3 |
||
6717 | or al,cl |
||
6718 | stos byte [edi] |
||
6719 | mov eax,edx |
||
6720 | stos word [edi] |
||
6721 | ret |
||
6722 | address_8bit_value: |
||
31 | halyavin | 6723 | or al,01000000b |
157 | heavyiron | 6724 | mov cl,[postbyte_register] |
6725 | shl cl,3 |
||
6726 | or al,cl |
||
6727 | stos byte [edi] |
||
6728 | mov al,dl |
||
6729 | stos byte [edi] |
||
6730 | ret |
||
6731 | address: |
||
31 | halyavin | 6732 | cmp al,110b |
157 | heavyiron | 6733 | je address_8bit_value |
6734 | mov cl,[postbyte_register] |
||
6735 | shl cl,3 |
||
6736 | or al,cl |
||
6737 | stos byte [edi] |
||
6738 | ret |
||
6739 | address_vsib: |
||
2665 | dunkaist | 6740 | mov al,bl |
6741 | shr al,4 |
||
6742 | test al,1 |
||
6467 | dunkaist | 6743 | jz vsib_high_code_ok |
6744 | or [vex_register],10000b |
||
6745 | or [vex_required],8 |
||
6746 | xor al,1 |
||
6747 | vsib_high_code_ok: |
||
6748 | cmp al,6 |
||
6749 | je vsib_index_ok |
||
6750 | cmp al,0Ch |
||
2665 | dunkaist | 6751 | jb invalid_address |
6467 | dunkaist | 6752 | vsib_index_ok: |
6753 | mov al,bh |
||
2665 | dunkaist | 6754 | shr al,4 |
6755 | cmp al,4 |
||
6756 | je postbyte_32bit |
||
6757 | cmp [code_type],64 |
||
6758 | je address_prefix_ok |
||
6759 | test al,al |
||
6760 | jnz invalid_address |
||
6761 | postbyte_32bit: |
||
31 | halyavin | 6762 | call address_32bit_prefix |
157 | heavyiron | 6763 | jmp address_prefix_ok |
6764 | postbyte_64bit: |
||
31 | halyavin | 6765 | cmp [code_type],64 |
157 | heavyiron | 6766 | jne invalid_address_size |
6767 | address_prefix_ok: |
||
109 | heavyiron | 6768 | cmp bl,44h |
157 | heavyiron | 6769 | je invalid_address |
6770 | cmp bl,84h |
||
6771 | je invalid_address |
||
6772 | test bh,1000b |
||
1189 | heavyiron | 6773 | jz base_code_ok |
6774 | or [rex_prefix],41h |
||
6775 | base_code_ok: |
||
6776 | test bl,1000b |
||
6777 | jz index_code_ok |
||
6778 | or [rex_prefix],42h |
||
6779 | index_code_ok: |
||
6780 | test ch,44h or 88h |
||
6467 | dunkaist | 6781 | setz [displacement_compression] |
6782 | call store_instruction_code |
||
1189 | heavyiron | 6783 | or cl,cl |
157 | heavyiron | 6784 | jz only_base_register |
6785 | base_and_index: |
||
31 | halyavin | 6786 | mov al,100b |
157 | heavyiron | 6787 | xor ah,ah |
6788 | cmp cl,1 |
||
6789 | je scale_ok |
||
6790 | cmp cl,2 |
||
6791 | je scale_1 |
||
6792 | cmp cl,4 |
||
6793 | je scale_2 |
||
6794 | or ah,11000000b |
||
6795 | jmp scale_ok |
||
6796 | scale_2: |
||
31 | halyavin | 6797 | or ah,10000000b |
157 | heavyiron | 6798 | jmp scale_ok |
6799 | scale_1: |
||
31 | halyavin | 6800 | or ah,01000000b |
157 | heavyiron | 6801 | scale_ok: |
31 | halyavin | 6802 | or bh,bh |
157 | heavyiron | 6803 | jz only_index_register |
6804 | and bl,111b |
||
6805 | shl bl,3 |
||
6806 | or ah,bl |
||
6807 | and bh,111b |
||
6808 | or ah,bh |
||
6809 | sib_ready: |
||
2665 | dunkaist | 6810 | test ch,44h or 88h |
6467 | dunkaist | 6811 | jnz sib_address_32bit_value |
157 | heavyiron | 6812 | or ch,ch |
6813 | jnz address_sizes_do_not_agree |
||
6814 | cmp bh,5 |
||
6815 | je address_value |
||
6816 | or edx,edx |
||
6817 | jz sib_address |
||
6818 | address_value: |
||
31 | halyavin | 6819 | cmp [displacement_compression],2 |
6467 | dunkaist | 6820 | ja sib_address_8bit_value |
6821 | je sib_address_32bit_value |
||
6822 | cmp edx,80h |
||
157 | heavyiron | 6823 | jb sib_address_8bit_value |
6824 | cmp edx,-80h |
||
6825 | jnb sib_address_8bit_value |
||
6467 | dunkaist | 6826 | sib_address_32bit_value: |
31 | halyavin | 6827 | or al,10000000b |
157 | heavyiron | 6828 | mov cl,[postbyte_register] |
6829 | shl cl,3 |
||
6830 | or al,cl |
||
6831 | stos word [edi] |
||
6832 | jmp store_address_32bit_value |
||
6833 | sib_address_8bit_value: |
||
31 | halyavin | 6834 | or al,01000000b |
157 | heavyiron | 6835 | mov cl,[postbyte_register] |
6836 | shl cl,3 |
||
6837 | or al,cl |
||
6838 | stos word [edi] |
||
6839 | mov al,dl |
||
6840 | stos byte [edi] |
||
6841 | ret |
||
6842 | sib_address: |
||
31 | halyavin | 6843 | mov cl,[postbyte_register] |
157 | heavyiron | 6844 | shl cl,3 |
6845 | or al,cl |
||
6846 | stos word [edi] |
||
6847 | ret |
||
6848 | only_index_register: |
||
31 | halyavin | 6849 | or ah,101b |
157 | heavyiron | 6850 | and bl,111b |
6851 | shl bl,3 |
||
6852 | or ah,bl |
||
6853 | mov cl,[postbyte_register] |
||
6854 | shl cl,3 |
||
6855 | or al,cl |
||
6856 | stos word [edi] |
||
6857 | test ch,44h or 88h |
||
6467 | dunkaist | 6858 | jnz store_address_32bit_value |
2287 | heavyiron | 6859 | or ch,ch |
157 | heavyiron | 6860 | jnz invalid_address_size |
6861 | cmp [displacement_compression],2 |
||
6467 | dunkaist | 6862 | jbe store_address_32bit_value |
6863 | mov edx,[uncompressed_displacement] |
||
6864 | jmp store_address_32bit_value |
||
2287 | heavyiron | 6865 | zero_index_register: |
31 | halyavin | 6866 | mov bl,4 |
157 | heavyiron | 6867 | mov cl,1 |
6868 | jmp base_and_index |
||
6869 | only_base_register: |
||
31 | halyavin | 6870 | mov al,bh |
157 | heavyiron | 6871 | and al,111b |
6872 | cmp al,4 |
||
6873 | je zero_index_register |
||
6874 | test ch,44h or 88h |
||
6467 | dunkaist | 6875 | jnz simple_address_32bit_value |
157 | heavyiron | 6876 | or ch,ch |
6877 | jnz address_sizes_do_not_agree |
||
6878 | or edx,edx |
||
6879 | jz simple_address |
||
6880 | cmp [displacement_compression],2 |
||
6467 | dunkaist | 6881 | ja simple_address_8bit_value |
6882 | je simple_address_32bit_value |
||
6883 | cmp edx,80h |
||
157 | heavyiron | 6884 | jb simple_address_8bit_value |
6885 | cmp edx,-80h |
||
6886 | jnb simple_address_8bit_value |
||
6467 | dunkaist | 6887 | simple_address_32bit_value: |
31 | halyavin | 6888 | or al,10000000b |
157 | heavyiron | 6889 | mov cl,[postbyte_register] |
6890 | shl cl,3 |
||
6891 | or al,cl |
||
6892 | stos byte [edi] |
||
6893 | jmp store_address_32bit_value |
||
2287 | heavyiron | 6894 | simple_address_8bit_value: |
31 | halyavin | 6895 | or al,01000000b |
157 | heavyiron | 6896 | mov cl,[postbyte_register] |
6897 | shl cl,3 |
||
6898 | or al,cl |
||
6899 | stos byte [edi] |
||
6900 | mov al,dl |
||
6901 | stos byte [edi] |
||
6902 | ret |
||
6903 | simple_address: |
||
31 | halyavin | 6904 | cmp al,5 |
157 | heavyiron | 6905 | je simple_address_8bit_value |
6906 | mov cl,[postbyte_register] |
||
6907 | shl cl,3 |
||
6908 | or al,cl |
||
6909 | stos byte [edi] |
||
6910 | ret |
||
6911 | address_immediate: |
||
31 | halyavin | 6912 | cmp [code_type],64 |
157 | heavyiron | 6913 | je address_immediate_sib |
6914 | test ch,44h or 88h |
||
6467 | dunkaist | 6915 | jnz address_immediate_32bit |
157 | heavyiron | 6916 | test ch,22h |
6917 | jnz address_immediate_16bit |
||
6918 | or ch,ch |
||
6919 | jnz invalid_address_size |
||
6920 | cmp [code_type],16 |
||
6921 | je addressing_16bit |
||
6922 | address_immediate_32bit: |
||
31 | halyavin | 6923 | call address_32bit_prefix |
157 | heavyiron | 6924 | call store_instruction_code |
6925 | store_immediate_address: |
||
31 | halyavin | 6926 | mov al,101b |
157 | heavyiron | 6927 | mov cl,[postbyte_register] |
6928 | shl cl,3 |
||
6929 | or al,cl |
||
6930 | stos byte [edi] |
||
6931 | store_address_32bit_value: |
||
31 | halyavin | 6932 | test ch,0F0h |
157 | heavyiron | 6933 | jz address_32bit_relocation_ok |
6934 | mov eax,ecx |
||
174 | heavyiron | 6935 | shr eax,16 |
6936 | cmp al,4 |
||
340 | heavyiron | 6937 | jne address_32bit_relocation |
6938 | mov al,2 |
||
6939 | address_32bit_relocation: |
||
6940 | xchg [value_type],al |
||
157 | heavyiron | 6941 | mov ebx,[address_symbol] |
6942 | xchg ebx,[symbol_identifier] |
||
6943 | call mark_relocation |
||
6944 | mov [value_type],al |
||
6945 | mov [symbol_identifier],ebx |
||
6946 | address_32bit_relocation_ok: |
||
31 | halyavin | 6947 | mov eax,edx |
157 | heavyiron | 6948 | stos dword [edi] |
6949 | ret |
||
6950 | store_address_64bit_value: |
||
31 | halyavin | 6951 | test ch,0F0h |
157 | heavyiron | 6952 | jz address_64bit_relocation_ok |
6953 | mov eax,ecx |
||
174 | heavyiron | 6954 | shr eax,16 |
6955 | xchg [value_type],al |
||
157 | heavyiron | 6956 | mov ebx,[address_symbol] |
6957 | xchg ebx,[symbol_identifier] |
||
6958 | call mark_relocation |
||
6959 | mov [value_type],al |
||
6960 | mov [symbol_identifier],ebx |
||
6961 | address_64bit_relocation_ok: |
||
31 | halyavin | 6962 | mov eax,edx |
157 | heavyiron | 6963 | stos dword [edi] |
6964 | mov eax,[address_high] |
||
6965 | stos dword [edi] |
||
6966 | ret |
||
6967 | address_immediate_sib: |
||
31 | halyavin | 6968 | test ch,44h |
1242 | heavyiron | 6969 | jnz address_immediate_sib_32bit |
6970 | test ch,not 88h |
||
6971 | jnz invalid_address_size |
||
157 | heavyiron | 6972 | address_immediate_sib_store: |
1242 | heavyiron | 6973 | call store_instruction_code |
157 | heavyiron | 6974 | mov al,100b |
6975 | mov ah,100101b |
||
6976 | mov cl,[postbyte_register] |
||
6977 | shl cl,3 |
||
6978 | or al,cl |
||
6979 | stos word [edi] |
||
6980 | jmp store_address_32bit_value |
||
6981 | address_immediate_sib_32bit: |
||
1242 | heavyiron | 6982 | test ecx,0FF0000h |
6983 | jnz address_immediate_sib_nosignextend |
||
6984 | test edx,80000000h |
||
6985 | jz address_immediate_sib_store |
||
6986 | address_immediate_sib_nosignextend: |
||
6987 | call address_32bit_prefix |
||
6988 | jmp address_immediate_sib_store |
||
6989 | address_eip_based: |
||
176 | heavyiron | 6990 | mov al,67h |
6991 | stos byte [edi] |
||
6992 | address_rip_based: |
||
31 | halyavin | 6993 | cmp [code_type],64 |
157 | heavyiron | 6994 | jne invalid_address |
6995 | call store_instruction_code |
||
6996 | jmp store_immediate_address |
||
6997 | address_relative: |
||
31 | halyavin | 6998 | call store_instruction_code |
157 | heavyiron | 6999 | movzx eax,[immediate_size] |
7000 | add eax,edi |
||
7001 | sub eax,[current_offset] |
||
7002 | add eax,5 |
||
7003 | sub edx,eax |
||
7004 | jno @f |
||
6467 | dunkaist | 7005 | call recoverable_overflow |
7006 | @@: |
||
7007 | mov al,101b |
||
157 | heavyiron | 7008 | mov cl,[postbyte_register] |
7009 | shl cl,3 |
||
7010 | or al,cl |
||
7011 | stos byte [edi] |
||
7012 | shr ecx,16 |
||
174 | heavyiron | 7013 | xchg [value_type],cl |
7014 | mov ebx,[address_symbol] |
||
157 | heavyiron | 7015 | xchg ebx,[symbol_identifier] |
7016 | mov eax,edx |
||
7017 | call mark_relocation |
||
7018 | mov [value_type],cl |
||
174 | heavyiron | 7019 | mov [symbol_identifier],ebx |
157 | heavyiron | 7020 | stos dword [edi] |
7021 | ret |
||
7022 | addressing_16bit: |
||
31 | halyavin | 7023 | cmp edx,10000h |
157 | heavyiron | 7024 | jge address_immediate_32bit |
7025 | cmp edx,-8000h |
||
7026 | jl address_immediate_32bit |
||
7027 | movzx edx,dx |
||
7028 | address_immediate_16bit: |
||
31 | halyavin | 7029 | call address_16bit_prefix |
157 | heavyiron | 7030 | call store_instruction_code |
7031 | mov al,110b |
||
7032 | mov cl,[postbyte_register] |
||
7033 | shl cl,3 |
||
7034 | or al,cl |
||
7035 | stos byte [edi] |
||
7036 | mov eax,edx |
||
7037 | stos word [edi] |
||
7038 | cmp edx,10000h |
||
7039 | jge value_out_of_range |
||
7040 | cmp edx,-8000h |
||
7041 | jl value_out_of_range |
||
7042 | ret |
||
7043 | address_16bit_prefix: |
||
31 | halyavin | 7044 | cmp [code_type],16 |
157 | heavyiron | 7045 | je instruction_prefix_ok |
7046 | mov al,67h |
||
7047 | stos byte [edi] |
||
7048 | ret |
||
7049 | address_32bit_prefix: |
||
31 | halyavin | 7050 | cmp [code_type],32 |
157 | heavyiron | 7051 | je instruction_prefix_ok |
7052 | mov al,67h |
||
7053 | stos byte [edi] |
||
7054 | instruction_prefix_ok: |
||
31 | halyavin | 7055 | ret |
157 | heavyiron | 7056 | store_instruction_with_imm8: |
31 | halyavin | 7057 | mov [immediate_size],1 |
157 | heavyiron | 7058 | call store_instruction |
7059 | mov al,byte [value] |
||
7060 | stos byte [edi] |
||
7061 | ret |
||
7062 | store_instruction_with_imm16: |
||
31 | halyavin | 7063 | mov [immediate_size],2 |
157 | heavyiron | 7064 | call store_instruction |
7065 | mov ax,word [value] |
||
7066 | call mark_relocation |
||
7067 | stos word [edi] |
||
7068 | ret |
||
7069 | store_instruction_with_imm32: |
||
31 | halyavin | 7070 | mov [immediate_size],4 |
157 | heavyiron | 7071 | call store_instruction |
7072 | mov eax,dword [value] |
||
7073 | call mark_relocation |
||
7074 | stos dword [edi] |
||
7075 | ret |
||
7076 |