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