Rev 7836 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7836 | Rev 9459 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ; flat assembler core |
1 | ; flat assembler core |
2 | ; Copyright (c) 1999-2020, Tomasz Grysztar. |
2 | ; Copyright (c) 1999-2021, Tomasz Grysztar. |
3 | ; All rights reserved. |
3 | ; All rights reserved. |
Line 4... | Line 4... | ||
4 | 4 | ||
5 | simple_instruction_except64: |
5 | simple_instruction_except64: |
6 | cmp [code_type],64 |
6 | cmp [code_type],64 |
Line 226... | Line 226... | ||
226 | call get_qword_value |
226 | call get_qword_value |
227 | mov ecx,edx |
227 | mov ecx,edx |
228 | cdq |
228 | cdq |
229 | cmp ecx,edx |
229 | cmp ecx,edx |
230 | jne value_out_of_range |
230 | je simm32_range_ok |
231 | cmp [value_type],4 |
231 | call recoverable_overflow |
- | 232 | simm32_range_ok: |
|
- | 233 | cmp [value_type],4 |
|
232 | jne get_simm32_ok |
234 | jne get_simm32_ok |
233 | mov [value_type],2 |
235 | mov [value_type],2 |
234 | get_simm32_ok: |
236 | get_simm32_ok: |
235 | ret |
237 | ret |
236 | basic_reg: |
238 | basic_reg: |
Line 466... | Line 468... | ||
466 | test ch,22h |
468 | test ch,22h |
467 | jnz mov_mem_address16_al |
469 | jnz mov_mem_address16_al |
468 | test ch,44h |
470 | test ch,44h |
469 | jnz mov_mem_address32_al |
471 | jnz mov_mem_address32_al |
470 | test ch,88h |
472 | test ch,not 88h |
471 | jnz mov_mem_address64_al |
473 | jnz invalid_address_size |
472 | or ch,ch |
- | |
473 | jnz invalid_address_size |
- | |
474 | call check_mov_address64 |
474 | call check_mov_address64 |
475 | cmp al,0 |
475 | cmp al,0 |
476 | jg mov_mem_address64_al |
476 | jg mov_mem_address64_al |
477 | jl instruction_ready |
477 | jl instruction_ready |
478 | cmp [code_type],16 |
478 | cmp [code_type],16 |
Line 502... | Line 502... | ||
502 | jmp instruction_assembled |
502 | jmp instruction_assembled |
503 | check_mov_address64: |
503 | check_mov_address64: |
504 | cmp [code_type],64 |
504 | cmp [code_type],64 |
505 | jne no_address64 |
505 | jne no_address64 |
506 | mov eax,[address_high] |
506 | test ch,88h |
- | 507 | jnz address64_required |
|
- | 508 | mov eax,[address_high] |
|
507 | or eax,eax |
509 | or eax,eax |
508 | jz no_address64 |
510 | jz no_address64 |
509 | bt edx,31 |
511 | bt edx,31 |
510 | adc eax,0 |
512 | adc eax,0 |
511 | jz address64_simm32 |
513 | jz address64_simm32 |
Line 515... | Line 517... | ||
515 | address64_simm32: |
517 | address64_simm32: |
516 | mov al,-1 |
518 | mov al,-1 |
517 | ret |
519 | ret |
518 | no_address64: |
520 | no_address64: |
519 | xor al,al |
521 | test ch,08h |
- | 522 | jnz invalid_address_size |
|
- | 523 | xor al,al |
|
520 | ret |
524 | ret |
521 | mov_mem_address64_al: |
525 | mov_mem_address64_al: |
522 | call store_segment_prefix_if_necessary |
526 | call store_segment_prefix_if_necessary |
523 | mov [base_code],0A2h |
527 | mov [base_code],0A2h |
524 | store_mov_address64: |
528 | store_mov_address64: |
Line 529... | Line 533... | ||
529 | test ch,22h |
533 | test ch,22h |
530 | jnz mov_mem_address16_ax |
534 | jnz mov_mem_address16_ax |
531 | test ch,44h |
535 | test ch,44h |
532 | jnz mov_mem_address32_ax |
536 | jnz mov_mem_address32_ax |
533 | test ch,88h |
537 | test ch,not 88h |
534 | jnz mov_mem_address64_ax |
538 | jnz invalid_address_size |
535 | or ch,ch |
- | |
536 | jnz invalid_address_size |
- | |
537 | call check_mov_address64 |
539 | call check_mov_address64 |
538 | cmp al,0 |
540 | cmp al,0 |
539 | jg mov_mem_address64_ax |
541 | jg mov_mem_address64_ax |
540 | jl instruction_ready |
542 | jl instruction_ready |
541 | cmp [code_type],16 |
543 | cmp [code_type],16 |
Line 731... | Line 733... | ||
731 | test ch,22h |
733 | test ch,22h |
732 | jnz mov_al_mem_address16 |
734 | jnz mov_al_mem_address16 |
733 | test ch,44h |
735 | test ch,44h |
734 | jnz mov_al_mem_address32 |
736 | jnz mov_al_mem_address32 |
735 | test ch,88h |
737 | test ch,not 88h |
736 | jnz mov_al_mem_address64 |
738 | jnz invalid_address_size |
737 | or ch,ch |
- | |
738 | jnz invalid_address_size |
- | |
739 | call check_mov_address64 |
739 | call check_mov_address64 |
740 | cmp al,0 |
740 | cmp al,0 |
741 | jg mov_al_mem_address64 |
741 | jg mov_al_mem_address64 |
742 | jl instruction_ready |
742 | jl instruction_ready |
743 | cmp [code_type],16 |
743 | cmp [code_type],16 |
Line 762... | Line 762... | ||
762 | test ch,22h |
762 | test ch,22h |
763 | jnz mov_ax_mem_address16 |
763 | jnz mov_ax_mem_address16 |
764 | test ch,44h |
764 | test ch,44h |
765 | jnz mov_ax_mem_address32 |
765 | jnz mov_ax_mem_address32 |
766 | test ch,88h |
766 | test ch,not 88h |
767 | jnz mov_ax_mem_address64 |
767 | jnz invalid_address_size |
768 | or ch,ch |
- | |
769 | jnz invalid_address_size |
- | |
770 | call check_mov_address64 |
768 | call check_mov_address64 |
771 | cmp al,0 |
769 | cmp al,0 |
772 | jg mov_ax_mem_address64 |
770 | jg mov_ax_mem_address64 |
773 | jl instruction_ready |
771 | jl instruction_ready |
774 | cmp [code_type],16 |
772 | cmp [code_type],16 |
Line 3029... | Line 3027... | ||
3029 | lods byte [esi] |
3027 | lods byte [esi] |
3030 | cmp al,'(' |
3028 | cmp al,'(' |
3031 | jne invalid_operand |
3029 | jne invalid_operand |
3032 | mov al,[value_type] |
3030 | mov al,[value_type] |
3033 | push eax [symbol_identifier] |
3031 | push eax |
- | 3032 | push [symbol_identifier] |
|
3034 | cmp byte [esi],'.' |
3033 | cmp byte [esi],'.' |
3035 | je invalid_value |
3034 | je invalid_value |
3036 | mov al,[operand_size] |
3035 | mov al,[operand_size] |
3037 | cmp al,4 |
3036 | cmp al,4 |
3038 | je jmp_far_16bit |
3037 | je jmp_far_16bit |
3039 | cmp al,6 |
3038 | cmp al,6 |
Line 3050... | Line 3049... | ||
3050 | mov ax,bx |
3049 | mov ax,bx |
3051 | call mark_relocation |
3050 | call mark_relocation |
3052 | stos word [edi] |
3051 | stos word [edi] |
3053 | jmp_far_segment: |
3052 | jmp_far_segment: |
3054 | pop [symbol_identifier] eax |
3053 | pop [symbol_identifier] |
3055 | mov [value_type],al |
3054 | pop eax |
- | 3055 | mov [value_type],al |
|
3056 | pop eax |
3056 | pop eax |
3057 | call mark_relocation |
3057 | call mark_relocation |
3058 | stos word [edi] |
3058 | stos word [edi] |
3059 | jmp instruction_assembled |
3059 | jmp instruction_assembled |
3060 | jmp_far_32bit: |
3060 | jmp_far_32bit: |
Line 6398... | Line 6398... | ||
6398 | lods byte [esi] |
6398 | lods byte [esi] |
6399 | cmp al,'(' |
6399 | cmp al,'(' |
6400 | jne invalid_operand |
6400 | jne invalid_operand |
6401 | mov al,[address_sign] |
6401 | mov al,[address_sign] |
6402 | push eax ebx ecx edx [address_symbol] |
6402 | push eax ebx ecx edx |
- | 6403 | push [address_symbol] |
|
6403 | call get_address_component |
6404 | call get_address_component |
6404 | lods byte [esi] |
6405 | lods byte [esi] |
6405 | cmp al,']' |
6406 | cmp al,']' |
6406 | jne invalid_operand |
6407 | jne invalid_operand |
6407 | or dl,bl |
6408 | or dl,bl |
6408 | or dl,[address_sign] |
6409 | or dl,[address_sign] |
6409 | or edx,[address_high] |
6410 | or edx,[address_high] |
6410 | jnz invalid_address |
6411 | jnz invalid_address |
6411 | mov [address_register],bh |
6412 | mov [address_register],bh |
6412 | pop [address_symbol] edx ecx ebx eax |
6413 | pop [address_symbol] |
6413 | mov [address_sign],al |
6414 | pop edx ecx ebx eax |
- | 6415 | mov [address_sign],al |
|
6414 | or bl,bl |
6416 | or bl,bl |
6415 | jz mib_place_index |
6417 | jz mib_place_index |
6416 | or bh,bh |
6418 | or bh,bh |
6417 | jnz invalid_address |
6419 | jnz invalid_address |
6418 | cmp cl,1 |
6420 | cmp cl,1 |
Line 7312... | Line 7314... | ||
7312 | add eax,edi |
7314 | add eax,edi |
7313 | sub eax,[current_offset] |
7315 | sub eax,[current_offset] |
7314 | add eax,5 |
7316 | add eax,5 |
7315 | sub edx,eax |
7317 | sub edx,eax |
7316 | jno @f |
7318 | jno address_relative_ok |
7317 | call recoverable_overflow |
7319 | call recoverable_overflow |
7318 | @@: |
7320 | address_relative_ok: |
7319 | mov al,101b |
7321 | mov al,101b |
7320 | mov cl,[postbyte_register] |
7322 | mov cl,[postbyte_register] |
7321 | shl cl,3 |
7323 | shl cl,3 |
7322 | or al,cl |
7324 | or al,cl |
7323 | stos byte [edi] |
7325 | stos byte [edi] |
7324 | shr ecx,16 |
7326 | shr ecx,16 |