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