diff --git a/programs/develop/fasm/trunk/assemble.inc b/programs/develop/fasm/trunk/assemble.inc index f49cc9c0b..58853adbc 100644 --- a/programs/develop/fasm/trunk/assemble.inc +++ b/programs/develop/fasm/trunk/assemble.inc @@ -1,14 +1,15 @@ ; flat assembler core -; Copyright (c) 1999-2009, Tomasz Grysztar. +; Copyright (c) 1999-2011, Tomasz Grysztar. ; All rights reserved. assembler: xor eax,eax mov [stub_size],eax - mov [number_of_sections],eax mov [current_pass],ax mov [resolver_flags],eax + mov [number_of_sections],eax + mov [actual_fixups_size],eax assembler_loop: mov eax,[labels_list] mov [display_buffer],eax @@ -115,6 +116,14 @@ assembler: or eax,eax jz assemble_ok mov [current_line],eax + cmp [error],undefined_symbol + jne error_confirmed + mov eax,[error_info] + or eax,eax + jz error_confirmed + test byte [eax+8],1 + jnz next_pass + error_confirmed: call error_handler error_handler: mov eax,[error] @@ -360,10 +369,13 @@ assemble_line: ; mov [operand_size],0 ; mov [size_override],0 ; mov [operand_prefix],0 -; mov [rex_prefix],0 +; mov [opcode_prefix],0 mov dword [operand_size],0 - mov [opcode_prefix],0 - mov [immediate_size],0 +; mov [rex_prefix],0 +; mov [vex_required],0 +; mov [vex_register],0 +; mov [immediate_size],0 + mov dword [rex_prefix],0 call instruction_handler instruction_handler: movzx ebx,word [esi] @@ -384,87 +396,6 @@ assemble_line: dec esi stc ret -skip_line: - call skip_symbol - jnc skip_line - ret -skip_symbol: - lods byte [esi] - or al,al - jz nothing_to_skip - cmp al,0Fh - je nothing_to_skip - cmp al,1 - je skip_instruction - cmp al,2 - je skip_label - cmp al,3 - je skip_label - cmp al,20h - jb skip_assembler_symbol - cmp al,'(' - je skip_expression - cmp al,'[' - je skip_address - skip_done: - clc - ret - skip_label: - add esi,2 - skip_instruction: - add esi,2 - skip_assembler_symbol: - inc esi - jmp skip_done - skip_address: - mov al,[esi] - and al,11110000b - cmp al,60h - jb skip_expression - cmp al,70h - ja skip_expression - inc esi - jmp skip_address - skip_expression: - lods byte [esi] - or al,al - jz skip_string - cmp al,'.' - je skip_fp_value - cmp al,')' - je skip_done - cmp al,']' - je skip_done - cmp al,'!' - je skip_expression - cmp al,0Fh - je skip_expression - cmp al,10h - je skip_register - cmp al,11h - je skip_label_value - cmp al,80h - jae skip_expression - movzx eax,al - add esi,eax - jmp skip_expression - skip_label_value: - add esi,3 - skip_register: - inc esi - jmp skip_expression - skip_fp_value: - add esi,12 - jmp skip_done - skip_string: - lods dword [esi] - add esi,eax - inc esi - jmp skip_done - nothing_to_skip: - dec esi - stc - ret org_directive: lods byte [esi] @@ -576,7 +507,6 @@ label_directive: mov [ebx+4],edx setne al or ah,al - jmp finish_label finish_label: cmp cl,[ebx+10] mov [ebx+10],cl @@ -818,15 +748,9 @@ times_directive: jne invalid_argument cmp byte [esi],'.' je invalid_value - call get_dword_value - cmp [next_pass_needed],0 - jne times_value_ok - cmp [value_type],0 - jne invalid_use_of_symbol - times_value_ok: + call get_count_value cmp eax,0 je zero_times - jl negative_times cmp byte [esi],':' jne times_argument_ok inc esi @@ -855,14 +779,9 @@ times_directive: pop [counter_limit] pop [counter] jmp instruction_assembled - negative_times: - cmp [error_line],0 - jne zero_times - mov eax,[current_line] - mov [error_line],eax - mov [error],invalid_value zero_times: - call skip_line + call skip_symbol + jnc zero_times jmp instruction_assembled virtual_directive: @@ -973,13 +892,15 @@ virtual_directive: mov edi,[ebx+8] remove_structure_data: push esi edi - mov esi,[structures_buffer] mov ecx,ebx - sub ecx,esi - lea edi,[esi+20h] - mov [structures_buffer],edi + sub ecx,[structures_buffer] shr ecx,2 + lea esi,[ebx-4] + lea edi,[esi+20h] + std rep movs dword [edi],[esi] + cld + add [structures_buffer],20h pop edi esi ret repeat_directive: @@ -990,15 +911,9 @@ repeat_directive: jne invalid_argument cmp byte [esi],'.' je invalid_value - call get_dword_value - cmp [next_pass_needed],0 - jne repeat_value_ok - cmp [value_type],0 - jne invalid_use_of_symbol - repeat_value_ok: + call get_count_value cmp eax,0 je zero_repeat - jl negative_repeat call allocate_structure_data mov word [ebx],repeat_directive-instruction_handler xchg eax,[counter_limit] @@ -1029,12 +944,6 @@ repeat_directive: continue_repeating: mov esi,[ebx+8] jmp instruction_assembled - negative_repeat: - cmp [error_line],0 - jne zero_repeat - mov eax,[current_line] - mov [error_line],eax - mov [error],invalid_value zero_repeat: mov al,[esi] or al,al @@ -1187,7 +1096,8 @@ if_directive: mov eax,[current_line] mov [error_line],eax find_end_directive: - call skip_line + call skip_symbol + jnc find_end_directive lods byte [esi] cmp al,0Fh jne no_end_directive @@ -1358,23 +1268,10 @@ data_bytes: cmp byte [ebx],81h jne simple_data_value inc esi - call get_dword_value - cmp [next_pass_needed],0 - jne dup_value_ok - cmp [value_type],0 - jne invalid_use_of_symbol - dup_value_ok: + call get_count_value inc esi - cmp eax,0 - jg dup_positive - cmp [error_line],0 - jne dup_invalid - mov eax,[current_line] - mov [error_line],eax - mov [error],invalid_value - dup_invalid: - mov eax,1 - dup_positive: + or eax,eax + jz duplicate_zero_times cmp byte [esi],'{' jne duplicate_single_data_value inc esi @@ -1404,6 +1301,20 @@ data_bytes: jz data_defined mov esi,ebx jmp duplicate_single_data_value + duplicate_zero_times: + cmp byte [esi],'{' + jne skip_single_data_value + inc esi + skip_data_value: + call skip_symbol + jc invalid_argument + cmp byte [esi],'}' + jne skip_data_value + inc esi + jmp data_defined + skip_single_data_value: + call skip_symbol + jmp data_defined simple_data_value: cmp edi,[display_buffer] jae out_of_memory @@ -1691,7 +1602,7 @@ data_file: cmp byte [esi],'.' je invalid_value push ebx - call get_dword_value + call get_count_value pop ebx mov edx,eax sub [esp],edx @@ -1706,7 +1617,7 @@ data_file: cmp byte [esi],'.' je invalid_value push ebx edx - call get_dword_value + call get_count_value pop edx ebx cmp eax,[esp] ja value_out_of_range @@ -1731,8 +1642,13 @@ data_file: open_binary_file: push esi push edi - mov esi,[current_line] - mov esi,[esi] + mov eax,[current_line] + find_current_source_path: + mov esi,[eax] + test byte [eax+7],80h + jz get_current_path + mov eax,[eax+12] + jmp find_current_source_path get_current_path: lodsb stosb @@ -1772,14 +1688,7 @@ reserve_bytes: jne invalid_argument cmp byte [esi],'.' je invalid_value - call get_dword_value - cmp [next_pass_needed],0 - jne rb_value_ok - cmp [value_type],0 - jne invalid_use_of_symbol - rb_value_ok: - cmp eax,0 - jl reserve_negative + call get_count_value mov ecx,eax mov edx,ecx add edx,edi @@ -1806,27 +1715,13 @@ reserve_bytes: pop eax call undefined_data jmp instruction_assembled - reserve_negative: - cmp [error_line],0 - jne instruction_assembled - mov eax,[current_line] - mov [error_line],eax - mov [error],invalid_value - jmp instruction_assembled reserve_words: lods byte [esi] cmp al,'(' jne invalid_argument cmp byte [esi],'.' je invalid_value - call get_dword_value - cmp [next_pass_needed],0 - jne rw_value_ok - cmp [value_type],0 - jne invalid_use_of_symbol - rw_value_ok: - cmp eax,0 - jl reserve_negative + call get_count_value mov ecx,eax mov edx,ecx shl edx,1 @@ -1854,14 +1749,7 @@ reserve_dwords: jne invalid_argument cmp byte [esi],'.' je invalid_value - call get_dword_value - cmp [next_pass_needed],0 - jne rd_value_ok - cmp [value_type],0 - jne invalid_use_of_symbol - rd_value_ok: - cmp eax,0 - jl reserve_negative + call get_count_value mov ecx,eax mov edx,ecx shl edx,1 @@ -1887,14 +1775,7 @@ reserve_pwords: jne invalid_argument cmp byte [esi],'.' je invalid_value - call get_dword_value - cmp [next_pass_needed],0 - jne rp_value_ok - cmp [value_type],0 - jne invalid_use_of_symbol - rp_value_ok: - cmp eax,0 - jl reserve_negative + call get_count_value mov ecx,eax shl ecx,1 jc out_of_memory @@ -1917,14 +1798,7 @@ reserve_qwords: jne invalid_argument cmp byte [esi],'.' je invalid_value - call get_dword_value - cmp [next_pass_needed],0 - jne rq_value_ok - cmp [value_type],0 - jne invalid_use_of_symbol - rq_value_ok: - cmp eax,0 - jl reserve_negative + call get_count_value mov ecx,eax shl ecx,1 jc out_of_memory @@ -1948,14 +1822,7 @@ reserve_twords: jne invalid_argument cmp byte [esi],'.' je invalid_value - call get_dword_value - cmp [next_pass_needed],0 - jne rt_value_ok - cmp [value_type],0 - jne invalid_use_of_symbol - rt_value_ok: - cmp eax,0 - jl reserve_negative + call get_count_value mov ecx,eax shl ecx,2 jc out_of_memory @@ -1978,15 +1845,13 @@ align_directive: jne invalid_argument cmp byte [esi],'.' je invalid_value - call get_dword_value - cmp [value_type],0 - jne invalid_use_of_symbol + call get_count_value mov edx,eax dec edx test eax,edx - jnz negative_times + jnz invalid_align_value or eax,eax - jz negative_times + jz invalid_align_value cmp eax,1 je instruction_assembled mov ecx,edi @@ -2023,6 +1888,13 @@ align_directive: je nops add edi,ecx jmp reserved_data + invalid_align_value: + cmp [error_line],0 + jne instruction_assembled + mov eax,[current_line] + mov [error_line],eax + mov [error],invalid_value + jmp instruction_assembled nops: mov eax,90909090h shr ecx,1 diff --git a/programs/develop/fasm/trunk/avx.inc b/programs/develop/fasm/trunk/avx.inc new file mode 100644 index 000000000..763bfb3e3 --- /dev/null +++ b/programs/develop/fasm/trunk/avx.inc @@ -0,0 +1,1353 @@ + +; flat assembler core +; Copyright (c) 1999-2011, Tomasz Grysztar. +; All rights reserved. + +avx_single_source_pd_instruction: + or [vex_required],2 + jmp avx_pd_instruction +avx_pd_instruction_imm8: + mov [immediate_size],1 +avx_pd_instruction: + mov [opcode_prefix],66h + mov [mmx_size],0 + jmp avx_instruction +avx_single_source_ps_instruction: + or [vex_required],2 + jmp avx_ps_instruction +avx_ps_instruction_imm8: + mov [immediate_size],1 +avx_ps_instruction: + mov [mmx_size],0 + jmp avx_instruction +avx_sd_instruction_imm8: + mov [immediate_size],1 +avx_sd_instruction: + mov [opcode_prefix],0F2h + mov [mmx_size],8 + jmp avx_instruction +avx_ss_instruction_imm8: + mov [immediate_size],1 +avx_ss_instruction: + mov [opcode_prefix],0F3h + mov [mmx_size],4 + jmp avx_instruction +avx_cmp_pd_instruction: + mov [opcode_prefix],66h +avx_cmp_ps_instruction: + mov [mmx_size],0 + mov byte [value],al + mov al,0C2h + jmp avx_instruction +avx_cmp_sd_instruction: + mov [opcode_prefix],0F2h + mov [mmx_size],8 + mov byte [value],al + mov al,0C2h + jmp avx_instruction +avx_cmp_ss_instruction: + mov [opcode_prefix],0F3h + mov [mmx_size],4 + mov byte [value],al + mov al,0C2h + jmp avx_instruction +avx_comiss_instruction: + or [vex_required],2 + mov [mmx_size],4 + jmp avx_instruction +avx_comisd_instruction: + or [vex_required],2 + mov [opcode_prefix],66h + mov [mmx_size],8 + jmp avx_instruction +avx_haddps_instruction: + mov [opcode_prefix],0F2h + mov [mmx_size],0 + jmp avx_instruction +avx_movshdup_instruction: + or [vex_required],2 + mov [opcode_prefix],0F3h + mov [mmx_size],0 +avx_instruction: + mov [base_code],0Fh + mov [extended_code],al + avx_common: + or [vex_required],1 + lods byte [esi] + call get_size_operator + cmp al,10h + jne invalid_operand + avx_reg: + lods byte [esi] + call convert_avx_register + mov [postbyte_register],al + avx_vex_reg: + test [vex_required],2 + jnz avx_vex_reg_ok + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_register + mov [vex_register],al + avx_vex_reg_ok: + cmp [mmx_size],0 + je avx_regs_size_ok + cmp ah,16 + jne invalid_operand + avx_regs_size_ok: + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_rm + jc avx_regs_reg + mov al,[extended_code] + mov ah,[supplemental_code] + cmp al,0C2h + je sse_cmp_mem_ok + cmp ax,443Ah + je sse_cmp_mem_ok + mov al,[base_code] + and al,11011100b + cmp al,11001100b + je sse_cmp_mem_ok + cmp [immediate_size],1 + je mmx_imm8 + cmp [immediate_size],0 + jge instruction_ready + cmp byte [esi],',' + jne invalid_operand + inc esi + call take_avx_register + shl al,4 + or byte [value],al + test al,80h + jz avx_regs_mem_reg_store + cmp [code_type],64 + jne invalid_operand + avx_regs_mem_reg_store: + call take_imm4_if_needed + call store_instruction_with_imm8 + jmp instruction_assembled + avx_regs_reg: + mov bl,al + mov al,[extended_code] + mov ah,[supplemental_code] + cmp al,0C2h + je sse_cmp_nomem_ok + cmp ax,443Ah + je sse_cmp_nomem_ok + mov al,[base_code] + and al,11011100b + cmp al,11001100b + je sse_cmp_nomem_ok + cmp [immediate_size],1 + je mmx_nomem_imm8 + cmp [immediate_size],0 + jge nomem_instruction_ready + lods byte [esi] + cmp al,',' + jne invalid_operand + mov al,bl + shl al,4 + or byte [value],al + test al,80h + jz avx_regs_reg_ + cmp [code_type],64 + jne invalid_operand + avx_regs_reg_: + call take_avx_rm + jc avx_regs_reg_reg + cmp [immediate_size],-2 + jg invalid_operand + or [rex_prefix],8 + call take_imm4_if_needed + call store_instruction_with_imm8 + jmp instruction_assembled + avx_regs_reg_reg: + shl al,4 + and byte [value],1111b + or byte [value],al + call take_imm4_if_needed + call store_nomem_instruction + mov al,byte [value] + stos byte [edi] + jmp instruction_assembled + take_avx_rm: + xor cl,cl + xchg cl,[operand_size] + lods byte [esi] + call get_size_operator + cmp al,'[' + je take_avx_mem + mov [operand_size],cl + cmp al,10h + jne invalid_operand + lods byte [esi] + call convert_avx_register + cmp [mmx_size],0 + je avx_reg_ok + cmp ah,16 + jne invalid_operand + avx_reg_ok: + stc + ret + take_avx_mem: + push ecx + call get_address + pop eax + cmp [mmx_size],0 + jne avx_smem + xchg al,[operand_size] + or al,al + jz avx_mem_ok + cmp al,[operand_size] + jne operand_sizes_do_not_match + avx_mem_ok: + clc + ret + avx_smem: + xchg al,[operand_size] + cmp al,[mmx_size] + jne invalid_operand_size + clc + ret + take_imm4_if_needed: + cmp [immediate_size],-3 + jne imm4_ok + push ebx ecx edx + lods byte [esi] + cmp al,',' + jne invalid_operand + lods byte [esi] + cmp al,'(' + jne invalid_operand + call get_byte_value + test al,11110000b + jnz value_out_of_range + or byte [value],al + pop edx ecx ebx + imm4_ok: + ret + +avx_128bit_instruction: + mov [mmx_size],16 + mov [opcode_prefix],66h + jmp avx_instruction +avx_single_source_128bit_instruction_38: + or [vex_required],2 +avx_128bit_instruction_38: + mov [mmx_size],16 + avx_instruction_38_setup: + mov [opcode_prefix],66h + mov [supplemental_code],al + mov al,38h + jmp avx_instruction +avx_single_source_instruction_38: + or [vex_required],2 + mov [mmx_size],0 + jmp avx_instruction_38_setup +avx_ss_instruction_3a_imm8: + mov [mmx_size],4 + jmp avx_instruction_3a_imm8_setup +avx_sd_instruction_3a_imm8: + mov [mmx_size],8 + jmp avx_instruction_3a_imm8_setup +avx_single_source_128bit_instruction_3a_imm8: + or [vex_required],2 +avx_128bit_instruction_3a_imm8: + mov [mmx_size],16 + jmp avx_instruction_3a_imm8_setup +avx_triple_source_instruction_3a: + mov [mmx_size],0 + mov [immediate_size],-1 + mov byte [value],0 + jmp avx_instruction_3a_setup +avx_triple_source_128bit_instruction_3a: + mov [mmx_size],16 + mov [immediate_size],-1 + mov byte [value],0 + jmp avx_instruction_3a_setup +avx_single_source_instruction_3a_imm8: + or [vex_required],2 +avx_instruction_3a_imm8: + mov [mmx_size],0 + avx_instruction_3a_imm8_setup: + mov [immediate_size],1 + avx_instruction_3a_setup: + mov [opcode_prefix],66h + mov [supplemental_code],al + mov al,3Ah + jmp avx_instruction +avx_pclmulqdq_instruction: + mov byte [value],al + mov [mmx_size],16 + mov al,44h + jmp avx_instruction_3a_setup +avx_perm2f128_instruction: + call setup_66_0f_3a + mov [immediate_size],1 + mov [mmx_size],0 + or [vex_required],1 + call take_avx_register + cmp ah,32 + jne invalid_operand_size + mov [postbyte_register],al + jmp avx_vex_reg + setup_66_0f_3a: + mov [opcode_prefix],66h + mov [base_code],0Fh + mov [extended_code],3Ah + mov [supplemental_code],al + ret + +avx_movdqu_instruction: + mov [opcode_prefix],0F3h + jmp avx_movps_instruction +avx_movpd_instruction: + mov [opcode_prefix],66h +avx_movps_instruction: + mov [mmx_size],0 + or [vex_required],2 + mov [base_code],0Fh + mov [extended_code],al + lods byte [esi] + call get_size_operator + cmp al,10h + je avx_reg + inc [extended_code] + test [extended_code],1 + jnz avx_mem + add [extended_code],-1+10h + avx_mem: + cmp al,'[' + jne invalid_operand + call get_address + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_register + mov [postbyte_register],al + jmp instruction_ready +avx_movntpd_instruction: + mov [opcode_prefix],66h +avx_movntps_instruction: + or [vex_required],1 + mov [base_code],0Fh + mov [extended_code],al + lods byte [esi] + call get_size_operator + jmp avx_mem +avx_lddqu_instruction: + mov [opcode_prefix],0F2h + mov [mmx_size],0 + xor cl,cl + avx_load_instruction: + mov [base_code],0Fh + mov [extended_code],al + or [vex_required],1 + call take_avx_register + or cl,cl + jz avx_load_reg_ok + cmp ah,cl + jne invalid_operand + avx_load_reg_ok: + cmp [mmx_size],0 + je avx_load_reg_ + xor ah,ah + avx_load_reg_: + xchg ah,[operand_size] + push eax + lods byte [esi] + cmp al,',' + jne invalid_operand + lods byte [esi] + call get_size_operator + cmp al,'[' + jne invalid_operand + call get_address + pop eax + xchg ah,[operand_size] + mov [postbyte_register],al + mov al,[mmx_size] + or al,al + jz instruction_ready + or ah,ah + jz instruction_ready + cmp al,ah + jne invalid_operand_size + jmp instruction_ready +avx_movntdqa_instruction: + mov [mmx_size],16 + mov al,2Ah + mov cl,16 + jmp avx_load_instruction_38 +avx_broadcastss_instruction: + mov [mmx_size],4 + mov al,18h + xor cl,cl + jmp avx_load_instruction_38 +avx_broadcastsd_instruction: + mov [mmx_size],8 + mov al,19h + mov cl,32 + jmp avx_load_instruction_38 +avx_broadcastf128_instruction: + mov [mmx_size],16 + mov al,1Ah + mov cl,32 + avx_load_instruction_38: + mov [opcode_prefix],66h + mov [supplemental_code],al + mov al,38h + jmp avx_load_instruction +avx_movlpd_instruction: + mov [opcode_prefix],66h +avx_movlps_instruction: + mov [base_code],0Fh + mov [extended_code],al + mov [mmx_size],8 + or [vex_required],1 + lods byte [esi] + call get_size_operator + cmp al,10h + jne avx_movlps_mem + lods byte [esi] + call convert_avx_register + mov [postbyte_register],al + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_register + mov [vex_register],al + cmp [operand_size],16 + jne invalid_operand + mov [operand_size],0 + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_rm + jc invalid_operand + jmp instruction_ready + avx_movlps_mem: + cmp al,'[' + jne invalid_operand + call get_address + mov al,[operand_size] + or al,al + jz avx_movlps_mem_size_ok + cmp al,[mmx_size] + jne invalid_operand_size + mov [operand_size],0 + avx_movlps_mem_size_ok: + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_register + cmp ah,16 + jne invalid_operand + mov [postbyte_register],al + inc [extended_code] + jmp instruction_ready +avx_movhlps_instruction: + mov [base_code],0Fh + mov [extended_code],al + or [vex_required],1 + call take_avx_register + cmp ah,16 + jne invalid_operand + mov [postbyte_register],al + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_register + mov [vex_register],al + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_register + mov bl,al + jmp nomem_instruction_ready +avx_maskmov_instruction: + mov [opcode_prefix],66h + mov [base_code],0Fh + mov [extended_code],38h + mov [supplemental_code],al + mov [mmx_size],0 + or [vex_required],1 + lods byte [esi] + call get_size_operator + cmp al,10h + jne avx_maskmov_mem + lods byte [esi] + call convert_avx_register + mov [postbyte_register],al + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_register + mov [vex_register],al + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_rm + jc invalid_operand + jmp instruction_ready + avx_maskmov_mem: + cmp al,'[' + jne invalid_operand + call get_address + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_register + mov [vex_register],al + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_register + mov [postbyte_register],al + add [supplemental_code],2 + jmp instruction_ready +avx_movd_instruction: + or [vex_required],1 + jmp movd_instruction +avx_movq_instruction: + or [vex_required],1 + jmp movq_instruction +avx_movddup_instruction: + or [vex_required],1 + mov [opcode_prefix],0F2h + mov [base_code],0Fh + mov [extended_code],al + lods byte [esi] + call get_size_operator + cmp al,10h + jne invalid_operand + lods byte [esi] + call convert_avx_register + mov [postbyte_register],al + mov [mmx_size],0 + cmp ah,32 + je avx_regs_size_ok + mov [mmx_size],8 + jmp avx_regs_size_ok +avx_movmskpd_instruction: + mov [opcode_prefix],66h +avx_movmskps_instruction: + mov [base_code],0Fh + mov [extended_code],50h + or [vex_required],1 + lods byte [esi] + call get_size_operator + cmp al,10h + jne invalid_operand + lods byte [esi] + call convert_register + mov [postbyte_register],al + cmp ah,4 + je avx_movmskps_reg_ok + cmp ah,8 + jne invalid_operand_size + cmp [code_type],64 + jne invalid_operand + avx_movmskps_reg_ok: + mov [operand_size],0 + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_register + mov bl,al + jmp nomem_instruction_ready +avx_movsd_instruction: + mov [opcode_prefix],0F2h + mov [mmx_size],8 + jmp avx_movs_instruction +avx_movss_instruction: + mov [opcode_prefix],0F3h + mov [mmx_size],4 + avx_movs_instruction: + or [vex_required],1 + mov [base_code],0Fh + mov [extended_code],10h + lods byte [esi] + call get_size_operator + cmp al,10h + jne avx_movlps_mem + lods byte [esi] + call convert_xmm_register + mov [postbyte_register],al + xor cl,cl + xchg cl,[operand_size] + lods byte [esi] + cmp al,',' + jne invalid_operand + lods byte [esi] + call get_size_operator + cmp al,10h + jne avx_movs_reg_mem + mov [operand_size],cl + lods byte [esi] + call convert_avx_register + mov [vex_register],al + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_register + mov bl,al + cmp bl,8 + jb nomem_instruction_ready + inc [extended_code] + xchg bl,[postbyte_register] + jmp nomem_instruction_ready + avx_movs_reg_mem: + cmp al,'[' + jne invalid_operand + call get_address + mov al,[operand_size] + or al,al + jz avx_movs_reg_mem_ok + cmp al,[mmx_size] + jne invalid_operand_size + avx_movs_reg_mem_ok: + jmp instruction_ready + +avx_cvtdq2pd_instruction: + mov [opcode_prefix],0F3h +avx_cvtps2pd_instruction: + mov [base_code],0Fh + mov [extended_code],al + or [vex_required],1 + call take_avx_register + mov [postbyte_register],al + lods byte [esi] + cmp al,',' + jne invalid_operand + xor cl,cl + xchg cl,[operand_size] + lods byte [esi] + call get_size_operator + cmp al,10h + jne avx_cvtdq2pd_reg_mem + lods byte [esi] + call convert_xmm_register + mov bl,al + mov [operand_size],cl + jmp nomem_instruction_ready + avx_cvtdq2pd_reg_mem: + cmp al,'[' + jne invalid_operand + mov [mmx_size],cl + call get_address + mov al,[operand_size] + or al,al + jz instruction_ready + shl al,1 + cmp al,[mmx_size] + jne invalid_operand_size + mov [operand_size],al + jmp instruction_ready +avx_cvtpd2dq_instruction: + mov [opcode_prefix],0F2h + jmp avx_cvtpd_instruction +avx_cvtpd2ps_instruction: + mov [opcode_prefix],66h + avx_cvtpd_instruction: + mov [base_code],0Fh + mov [extended_code],al + or [vex_required],1 + call take_avx_register + mov [postbyte_register],al + cmp ah,16 + jne invalid_operand + lods byte [esi] + cmp al,',' + jne invalid_operand + mov [operand_size],0 + lods byte [esi] + call get_size_operator + cmp al,10h + jne avx_cvtpd2dq_reg_mem + lods byte [esi] + call convert_avx_register + mov bl,al + jmp nomem_instruction_ready + avx_cvtpd2dq_reg_mem: + cmp al,'[' + jne invalid_operand + call get_address + mov al,[operand_size] + or al,al + jz operand_size_not_specified + cmp al,16 + je instruction_ready + cmp al,32 + jne invalid_operand_size + jmp instruction_ready +avx_cvttps2dq_instruction: + or [vex_required],2 + mov [opcode_prefix],0F3h + mov [mmx_size],0 + jmp avx_instruction +avx_cvtsd2si_instruction: + or [vex_required],1 + jmp cvtsd2si_instruction +avx_cvtss2si_instruction: + or [vex_required],1 + jmp cvtss2si_instruction +avx_cvtsi2ss_instruction: + mov [opcode_prefix],0F3h + jmp avx_cvtsi_instruction +avx_cvtsi2sd_instruction: + mov [opcode_prefix],0F2h + avx_cvtsi_instruction: + mov [base_code],0Fh + mov [extended_code],al + or [vex_required],1 + call take_avx_register + cmp ah,16 + jne invalid_operand_size + mov [postbyte_register],al + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_register + mov [vex_register],al + jmp cvtsi_xmmreg + +avx_extractf128_instruction: + or [vex_required],1 + call setup_66_0f_3a + lods byte [esi] + call get_size_operator + cmp al,10h + je avx_extractf128_reg + cmp al,'[' + jne invalid_operand + call get_address + xor al,al + xchg al,[operand_size] + or al,al + jz avx_extractf128_mem_size_ok + cmp al,16 + jne invalid_operand_size + avx_extractf128_mem_size_ok: + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_register + cmp ah,32 + jne invalid_operand_size + mov [postbyte_register],al + jmp mmx_imm8 + avx_extractf128_reg: + lods byte [esi] + call convert_xmm_register + mov [operand_size],0 + push eax + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_register + cmp ah,32 + jne invalid_operand_size + mov [postbyte_register],al + pop ebx + jmp mmx_nomem_imm8 +avx_insertf128_instruction: + or [vex_required],1 + call setup_66_0f_3a + call take_avx_register + cmp ah,32 + jne invalid_operand + mov [postbyte_register],al + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_register + mov [vex_register],al + mov [operand_size],0 + mov [mmx_size],16 + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_rm + mov [operand_size],32 + jnc mmx_imm8 + mov bl,al + jmp mmx_nomem_imm8 +avx_extractps_instruction: + or [vex_required],1 + jmp extractps_instruction +avx_insertps_instruction: + or [vex_required],1 + call take_avx_register + cmp ah,16 + jne invalid_operand_size + mov [postbyte_register],al + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_register + mov [vex_register],al + jmp insertps_xmmreg +avx_pextrb_instruction: + or [vex_required],1 + jmp pextrb_instruction +avx_pextrw_instruction: + or [vex_required],1 + jmp pextrw_instruction +avx_pextrd_instruction: + or [vex_required],1 + jmp pextrd_instruction +avx_pextrq_instruction: + or [vex_required],1 + jmp pextrq_instruction +avx_pinsrb_instruction: + mov [mmx_size],1 + or [vex_required],1 + jmp avx_pinsr_instruction_3a +avx_pinsrw_instruction: + mov [mmx_size],2 + or [vex_required],1 + jmp avx_pinsr_instruction +avx_pinsrd_instruction: + mov [mmx_size],4 + or [vex_required],1 + jmp avx_pinsr_instruction_3a +avx_pinsrq_instruction: + mov [mmx_size],8 + or [vex_required],1 + call operand_64bit + avx_pinsr_instruction_3a: + mov [supplemental_code],al + mov al,3Ah + avx_pinsr_instruction: + mov [opcode_prefix],66h + mov [base_code],0Fh + mov [extended_code],al + call take_avx_register + cmp ah,16 + jne invalid_operand_size + mov [postbyte_register],al + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_register + mov [vex_register],al + jmp pinsr_xmmreg +avx_maskmovdqu_instruction: + or [vex_required],1 + jmp maskmovdqu_instruction +avx_pmovmskb_instruction: + or [vex_required],1 + jmp pmovmskb_instruction +avx_pshufd_instruction: + or [vex_required],1 + jmp pshufd_instruction +avx_pmovsxbw_instruction: + mov [mmx_size],8 + jmp avx_pmovsx_instruction +avx_pmovsxbd_instruction: + mov [mmx_size],4 + jmp avx_pmovsx_instruction +avx_pmovsxbq_instruction: + mov [mmx_size],2 + jmp avx_pmovsx_instruction +avx_pmovsxwd_instruction: + mov [mmx_size],8 + jmp avx_pmovsx_instruction +avx_pmovsxwq_instruction: + mov [mmx_size],4 + jmp avx_pmovsx_instruction +avx_pmovsxdq_instruction: + mov [mmx_size],8 + avx_pmovsx_instruction: + or [vex_required],1 + jmp pmovsx_instruction +avx_permil_instruction: + call setup_66_0f_3a + or [vex_required],1 + call take_avx_register + mov [postbyte_register],al + lods byte [esi] + cmp al,',' + jne invalid_operand + lods byte [esi] + call get_size_operator + cmp al,'[' + je avx_permil_reg_mem + cmp al,10h + jne invalid_operand + lods byte [esi] + call convert_avx_register + mov [vex_register],al + lods byte [esi] + cmp al,',' + jne invalid_operand + push esi + xor cl,cl + xchg cl,[operand_size] + lods byte [esi] + call get_size_operator + xchg cl,[operand_size] + pop esi + cmp al,'[' + je avx_permil_reg_reg_mem + cmp al,10h + jne avx_permil_reg_reg_imm8 + call take_avx_register + mov bl,al + mov [extended_code],38h + add [supplemental_code],8 + jmp nomem_instruction_ready + avx_permil_reg_reg_mem: + lods byte [esi] + call get_size_operator + call get_address + mov [extended_code],38h + add [supplemental_code],8 + jmp instruction_ready + avx_permil_reg_reg_imm8: + dec esi + xor bl,bl + xchg bl,[vex_register] + jmp mmx_nomem_imm8 + avx_permil_reg_mem: + call get_address + jmp mmx_imm8 +avx_pslldq_instruction: + mov [postbyte_register],al + mov [opcode_prefix],66h + mov [base_code],0Fh + mov [extended_code],73h + or [vex_required],1 + call take_avx_register + cmp ah,16 + jne invalid_operand + mov [vex_register],al + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_register + mov bl,al + jmp mmx_nomem_imm8 +avx_bit_shift_instruction: + mov [opcode_prefix],66h + mov [base_code],0Fh + mov [extended_code],al + or [vex_required],1 + call take_avx_register + cmp ah,16 + jne invalid_operand + mov [postbyte_register],al + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_register + mov [vex_register],al + lods byte [esi] + cmp al,',' + jne invalid_operand + push esi + xor cl,cl + xchg cl,[operand_size] + lods byte [esi] + call get_size_operator + xchg cl,[operand_size] + pop esi + cmp al,10h + je avx_bit_shift_regs_reg + cmp al,'[' + je avx_bit_shift_regs_mem + dec esi + mov bl,[extended_code] + mov al,bl + shr bl,4 + and al,1111b + add al,70h + mov [extended_code],al + sub bl,0Ch + shl bl,1 + xchg bl,[postbyte_register] + xchg bl,[vex_register] + jmp mmx_nomem_imm8 + avx_bit_shift_regs_reg: + call take_avx_register + mov bl,al + jmp nomem_instruction_ready + avx_bit_shift_regs_mem: + lods byte [esi] + call get_size_operator + call get_address + jmp instruction_ready + +vzeroall_instruction: + mov [operand_size],32 +vzeroupper_instruction: + mov [base_code],0Fh + mov [extended_code],al + or [vex_required],1 + call store_instruction_code + jmp instruction_assembled +vldmxcsr_instruction: + or [vex_required],1 + jmp fxsave_instruction +vcvtph2ps_instruction: + mov [opcode_prefix],66h + mov [supplemental_code],al + mov al,38h + jmp avx_cvtps2pd_instruction +vcvtps2ph_instruction: + call setup_66_0f_3a + or [vex_required],1 + lods byte [esi] + call get_size_operator + cmp al,10h + je vcvtps2ph_reg + cmp al,'[' + jne invalid_operand + call get_address + lods byte [esi] + cmp al,',' + jne invalid_operand + shl [operand_size],1 + call take_avx_register + mov [postbyte_register],al + jmp mmx_imm8 + vcvtps2ph_reg: + lods byte [esi] + call convert_xmm_register + mov bl,al + mov [operand_size],0 + lods byte [esi] + cmp al,',' + jne invalid_operand + call take_avx_register + mov [postbyte_register],al + jmp mmx_nomem_imm8 + +fma_instruction_pd: + or [rex_prefix],8 +fma_instruction_ps: + mov [mmx_size],0 + jmp avx_instruction_38_setup +fma_instruction_sd: + or [rex_prefix],8 + mov [mmx_size],8 + jmp avx_instruction_38_setup +fma_instruction_ss: + mov [mmx_size],4 + jmp avx_instruction_38_setup + +fma4_instruction_p: + mov [mmx_size],0 + jmp fma4_instruction_setup +fma4_instruction_sd: + mov [mmx_size],8 + jmp fma4_instruction_setup +fma4_instruction_ss: + mov [mmx_size],4 + fma4_instruction_setup: + mov [immediate_size],-2 + mov byte [value],0 + jmp avx_instruction_3a_setup + +xop_single_source_sd_instruction: + or [vex_required],2 + mov [mmx_size],8 + jmp xop_instruction_9 +xop_single_source_ss_instruction: + or [vex_required],2 + mov [mmx_size],4 + jmp xop_instruction_9 +xop_single_source_instruction: + or [vex_required],2 + mov [mmx_size],0 + xop_instruction_9: + mov [base_code],al + mov [xop_opcode_map],9 + jmp avx_common +xop_single_source_128bit_instruction: + or [vex_required],2 + mov [mmx_size],16 + jmp xop_instruction_9 +xop_triple_source_128bit_instruction: + mov [immediate_size],-1 + mov byte [value],0 + mov [mmx_size],16 + jmp xop_instruction_8 +xop_128bit_instruction: + mov [immediate_size],-2 + mov byte [value],0 + mov [mmx_size],16 + xop_instruction_8: + mov [base_code],al + mov [xop_opcode_map],8 + jmp avx_common +xop_pcom_b_instruction: + mov ah,0CCh + jmp xop_pcom_instruction +xop_pcom_d_instruction: + mov ah,0CEh + jmp xop_pcom_instruction +xop_pcom_q_instruction: + mov ah,0CFh + jmp xop_pcom_instruction +xop_pcom_w_instruction: + mov ah,0CDh + jmp xop_pcom_instruction +xop_pcom_ub_instruction: + mov ah,0ECh + jmp xop_pcom_instruction +xop_pcom_ud_instruction: + mov ah,0EEh + jmp xop_pcom_instruction +xop_pcom_uq_instruction: + mov ah,0EFh + jmp xop_pcom_instruction +xop_pcom_uw_instruction: + mov ah,0EDh + xop_pcom_instruction: + mov byte [value],al + mov [mmx_size],16 + mov [base_code],ah + mov [xop_opcode_map],8 + jmp avx_common +vpcmov_instruction: + or [vex_required],1 + mov [immediate_size],-2 + mov byte [value],0 + mov [mmx_size],0 + mov [base_code],al + mov [xop_opcode_map],8 + jmp avx_common +xop_shift_instruction: + mov [base_code],al + or [vex_required],1 + mov [xop_opcode_map],9 + call take_avx_register + cmp ah,16 + jne invalid_operand + mov [postbyte_register],al + lods byte [esi] + cmp al,',' + jne invalid_operand + lods byte [esi] + call get_size_operator + cmp al,'[' + je xop_shift_reg_mem + cmp al,10h + jne invalid_operand + lods byte [esi] + call convert_xmm_register + mov [vex_register],al + lods byte [esi] + cmp al,',' + jne invalid_operand + push esi + xor cl,cl + xchg cl,[operand_size] + lods byte [esi] + call get_size_operator + pop esi + xchg cl,[operand_size] + cmp al,'[' + je xop_shift_reg_reg_mem + cmp al,10h + jne xop_shift_reg_reg_imm + call take_avx_register + mov bl,al + xchg bl,[vex_register] + jmp nomem_instruction_ready + xop_shift_reg_reg_mem: + or [rex_prefix],8 + lods byte [esi] + call get_size_operator + call get_address + jmp instruction_ready + xop_shift_reg_reg_imm: + xor bl,bl + xchg bl,[vex_register] + cmp [base_code],94h + jae invalid_operand + add [base_code],30h + mov [xop_opcode_map],8 + dec esi + jmp mmx_nomem_imm8 + xop_shift_reg_mem: + call get_address + lods byte [esi] + cmp al,',' + jne invalid_operand + push esi + xor cl,cl + xchg cl,[operand_size] + lods byte [esi] + call get_size_operator + pop esi + xchg cl,[operand_size] + cmp al,10h + jne xop_shift_reg_mem_imm + call take_avx_register + mov [vex_register],al + jmp instruction_ready + xop_shift_reg_mem_imm: + cmp [base_code],94h + jae invalid_operand + add [base_code],30h + mov [xop_opcode_map],8 + dec esi + jmp mmx_imm8 + +vpermil_2pd_instruction: + mov [immediate_size],-2 + mov byte [value],al + mov al,49h + jmp vpermil2_instruction_setup +vpermil_2ps_instruction: + mov [immediate_size],-2 + mov byte [value],al + mov al,48h + jmp vpermil2_instruction_setup +vpermil2_instruction: + mov [immediate_size],-3 + mov byte [value],0 + vpermil2_instruction_setup: + mov [base_code],0Fh + mov [supplemental_code],al + mov al,3Ah + mov [mmx_size],0 + jmp avx_instruction + +take_avx_register: + lods byte [esi] + call get_size_operator + cmp al,10h + jne invalid_operand + lods byte [esi] +convert_avx_register: + mov ah,al + and al,0Fh + and ah,0F0h + sub ah,0B0h + jbe invalid_operand + cmp ah,32 + ja invalid_operand + cmp al,8 + jb match_register_size + cmp [code_type],64 + jne invalid_operand + jmp match_register_size +store_vex_instruction_code: + mov al,[base_code] + cmp al,0Fh + jne store_xop_instruction_code + mov ah,[extended_code] + cmp ah,38h + je store_vex_0f38_instruction_code + cmp ah,3Ah + je store_vex_0f3a_instruction_code + test [rex_prefix],1011b + jnz store_vex_0f_instruction_code + mov [edi+2],ah + mov byte [edi],0C5h + mov al,[vex_register] + not al + shl al,3 + mov ah,[rex_prefix] + shl ah,5 + and ah,80h + xor al,ah + call get_vex_lpp_bits + mov [edi+1],al + call check_vex + add edi,3 + ret + get_vex_lpp_bits: + cmp [operand_size],32 + jne vex_l_bit_ok + or al,100b + vex_l_bit_ok: + mov ah,[opcode_prefix] + cmp ah,66h + je vex_66 + cmp ah,0F3h + je vex_f3 + cmp ah,0F2h + je vex_f2 + test ah,ah + jnz prefix_conflict + ret + vex_f2: + or al,11b + ret + vex_f3: + or al,10b + ret + vex_66: + or al,1 + ret + store_vex_0f38_instruction_code: + mov al,11100010b + mov ah,[supplemental_code] + jmp make_c4_vex + store_vex_0f3a_instruction_code: + mov al,11100011b + mov ah,[supplemental_code] + jmp make_c4_vex + store_vex_0f_instruction_code: + mov al,11100001b + make_c4_vex: + mov [edi+3],ah + mov byte [edi],0C4h + mov ah,[rex_prefix] + shl ah,5 + xor al,ah + mov [edi+1],al + call check_vex + mov al,[vex_register] + xor al,1111b + shl al,3 + mov ah,[rex_prefix] + shl ah,4 + and ah,80h + or al,ah + call get_vex_lpp_bits + mov [edi+2],al + add edi,4 + ret + check_vex: + cmp [code_type],64 + je vex_ok + not al + test al,11000000b + jnz invalid_operand + test [rex_prefix],40h + jnz invalid_operand + vex_ok: + ret +store_xop_instruction_code: + mov [edi+3],al + mov byte [edi],8Fh + mov al,[xop_opcode_map] + mov ah,[rex_prefix] + test ah,40h + jz xop_ok + cmp [code_type],64 + jne invalid_operand + xop_ok: + not ah + shl ah,5 + xor al,ah + mov [edi+1],al + mov al,[vex_register] + xor al,1111b + shl al,3 + mov ah,[rex_prefix] + shl ah,4 + and ah,80h + or al,ah + call get_vex_lpp_bits + mov [edi+2],al + add edi,4 + ret diff --git a/programs/develop/fasm/trunk/errors.inc b/programs/develop/fasm/trunk/errors.inc index 5e5125038..4f0e8681f 100644 --- a/programs/develop/fasm/trunk/errors.inc +++ b/programs/develop/fasm/trunk/errors.inc @@ -1,6 +1,6 @@ ; flat assembler core -; Copyright (c) 1999-2009, Tomasz Grysztar. +; Copyright (c) 1999-2011, Tomasz Grysztar. ; All rights reserved. out_of_memory: @@ -12,95 +12,101 @@ stack_overflow: main_file_not_found: push _main_file_not_found jmp fatal_error -unexpected_end_of_file: - push _unexpected_end_of_file - jmp fatal_error -code_cannot_be_generated: - push _code_cannot_be_generated - jmp fatal_error -format_limitations_exceeded: - push _format_limitations_exceeded - jmp fatal_error -invalid_definition: - push _invalid_definition - jmp fatal_error write_failed: push _write_failed jmp fatal_error +unexpected_end_of_file: + push _unexpected_end_of_file + jmp general_error +code_cannot_be_generated: + push _code_cannot_be_generated + jmp general_error +format_limitations_exceeded: + push _format_limitations_exceeded + general_error: + cmp [symbols_file],0 + je fatal_error + call dump_preprocessed_source + jmp fatal_error + file_not_found: push _file_not_found - jmp assembler_error + jmp error_with_source error_reading_file: push _error_reading_file - jmp assembler_error + jmp error_with_source invalid_file_format: push _invalid_file_format - jmp assembler_error + jmp error_with_source invalid_macro_arguments: push _invalid_macro_arguments - jmp assembler_error + jmp error_with_source incomplete_macro: push _incomplete_macro - jmp assembler_error + jmp error_with_source unexpected_characters: push _unexpected_characters - jmp assembler_error + jmp error_with_source invalid_argument: push _invalid_argument - jmp assembler_error + jmp error_with_source illegal_instruction: push _illegal_instruction - jmp assembler_error + jmp error_with_source invalid_operand: push _invalid_operand - jmp assembler_error + jmp error_with_source invalid_operand_size: push _invalid_operand_size - jmp assembler_error + jmp error_with_source operand_size_not_specified: push _operand_size_not_specified - jmp assembler_error + jmp error_with_source operand_sizes_do_not_match: push _operand_sizes_do_not_match - jmp assembler_error + jmp error_with_source invalid_address_size: push _invalid_address_size - jmp assembler_error + jmp error_with_source address_sizes_do_not_agree: push _address_sizes_do_not_agree - jmp assembler_error + jmp error_with_source prefix_conflict: push _prefix_conflict - jmp assembler_error + jmp error_with_source long_immediate_not_encodable: push _long_immediate_not_encodable - jmp assembler_error + jmp error_with_source relative_jump_out_of_range: push _relative_jump_out_of_range - jmp assembler_error + jmp error_with_source invalid_expression: push _invalid_expression - jmp assembler_error + jmp error_with_source invalid_address: push _invalid_address - jmp assembler_error + jmp error_with_source invalid_value: push _invalid_value - jmp assembler_error + jmp error_with_source value_out_of_range: push _value_out_of_range - jmp assembler_error + jmp error_with_source undefined_symbol: mov edi,message mov esi,_undefined_symbol call copy_asciiz push message cmp [error_info],0 - je assembler_error + je error_with_source + mov esi,[error_info] + mov esi,[esi+24] + or esi,esi + jz error_with_source mov byte [edi-1],20h call write_quoted_symbol_name - jmp assembler_error + jmp error_with_source copy_asciiz: lods byte [esi] stos byte [edi] @@ -110,7 +116,6 @@ undefined_symbol: write_quoted_symbol_name: mov al,27h stosb - mov esi,[error_info] movzx ecx,byte [esi-1] rep movs byte [edi],[esi] mov ax,27h @@ -122,6 +127,10 @@ symbol_out_of_scope: call copy_asciiz cmp [error_info],0 je finish_symbol_out_of_scope_message + mov esi,[error_info] + mov esi,[esi+24] + or esi,esi + jz finish_symbol_out_of_scope_message mov byte [edi-1],20h call write_quoted_symbol_name finish_symbol_out_of_scope_message: @@ -129,46 +138,51 @@ symbol_out_of_scope: mov esi,_symbol_out_of_scope_2 call copy_asciiz push message - jmp assembler_error + jmp error_with_source invalid_use_of_symbol: push _invalid_use_of_symbol - jmp assembler_error + jmp error_with_source name_too_long: push _name_too_long - jmp assembler_error + jmp error_with_source invalid_name: push _invalid_name - jmp assembler_error + jmp error_with_source reserved_word_used_as_symbol: push _reserved_word_used_as_symbol - jmp assembler_error + jmp error_with_source symbol_already_defined: push _symbol_already_defined - jmp assembler_error + jmp error_with_source missing_end_quote: push _missing_end_quote - jmp assembler_error + jmp error_with_source missing_end_directive: push _missing_end_directive - jmp assembler_error + jmp error_with_source unexpected_instruction: push _unexpected_instruction - jmp assembler_error + jmp error_with_source extra_characters_on_line: push _extra_characters_on_line - jmp assembler_error + jmp error_with_source section_not_aligned_enough: push _section_not_aligned_enough - jmp assembler_error + jmp error_with_source setting_already_specified: push _setting_already_specified - jmp assembler_error + jmp error_with_source data_already_defined: push _data_already_defined - jmp assembler_error + jmp error_with_source too_many_repeats: push _too_many_repeats - jmp assembler_error + jmp error_with_source invoked_error: push _invoked_error - jmp assembler_error \ No newline at end of file + error_with_source: + cmp [symbols_file],0 + je assembler_error + call dump_preprocessed_source + call restore_preprocessed_source + jmp assembler_error diff --git a/programs/develop/fasm/trunk/expressi.inc b/programs/develop/fasm/trunk/exprcalc.inc similarity index 59% rename from programs/develop/fasm/trunk/expressi.inc rename to programs/develop/fasm/trunk/exprcalc.inc index f838dd6fc..46b176268 100644 --- a/programs/develop/fasm/trunk/expressi.inc +++ b/programs/develop/fasm/trunk/exprcalc.inc @@ -1,2909 +1,2018 @@ - -; flat assembler core -; Copyright (c) 1999-2009, Tomasz Grysztar. -; All rights reserved. - -convert_expression: - push ebp - call get_fp_value - jnc fp_expression - mov [current_offset],esp - expression_loop: - push edi - mov edi,single_operand_operators - call get_operator - pop edi - or al,al - jz expression_element - push eax - jmp expression_loop - expression_element: - mov al,[esi] - cmp al,1Ah - je expression_number - cmp al,22h - je expression_number - cmp al,'(' - je expression_number - mov al,'!' - stos byte [edi] - jmp expression_operator - expression_number: - call convert_number - expression_operator: - push edi - mov edi,operators - call get_operator - pop edi - or al,al - jz expression_end - operators_loop: - cmp esp,[current_offset] - je push_operator - mov bl,al - and bl,0F0h - mov bh,byte [esp] - and bh,0F0h - cmp bl,bh - ja push_operator - pop ebx - mov byte [edi],bl - inc edi - jmp operators_loop - push_operator: - push eax - jmp expression_loop - expression_end: - cmp esp,[current_offset] - je expression_converted - pop eax - stos byte [edi] - jmp expression_end - expression_converted: - pop ebp - ret - fp_expression: - mov al,'.' - stos byte [edi] - mov eax,[fp_value] - stos dword [edi] - mov eax,[fp_value+4] - stos dword [edi] - mov eax,[fp_value+8] - stos dword [edi] - pop ebp - ret - -convert_number: - lea eax,[edi-10h] - mov edx,[memory_end] - cmp [source_start],0 - je check_memory_for_number - mov edx,[labels_list] - check_memory_for_number: - cmp eax,edx - jae out_of_memory - mov eax,esp - sub eax,100h - jc stack_overflow - cmp eax,[stack_limit] - jb stack_overflow - cmp byte [esi],'(' - je expression_value - inc edi - call get_number - jc symbol_value - or ebp,ebp - jz valid_number - mov byte [edi-1],0Fh - ret - valid_number: - cmp dword [edi+4],0 - jne qword_number - cmp word [edi+2],0 - jne dword_number - cmp byte [edi+1],0 - jne word_number - byte_number: - mov byte [edi-1],1 - inc edi - ret - qword_number: - mov byte [edi-1],8 - add edi,8 - ret - dword_number: - mov byte [edi-1],4 - scas dword [edi] - ret - word_number: - mov byte [edi-1],2 - scas word [edi] - ret - expression_value: - inc esi - push [current_offset] - call convert_expression - pop [current_offset] - lods byte [esi] - cmp al,')' - jne invalid_expression - ret - symbol_value: - cmp [source_start],0 - je preprocessor_value - push edi - mov edi,address_registers - call get_operator - or al,al - jnz register_value - mov edi,directive_operators - call get_operator - pop edi - or al,al - jnz broken_value - lods byte [esi] - cmp al,1Ah - jne invalid_value - lods byte [esi] - movzx ecx,al - call get_label_id - store_label_value: - mov byte [edi-1],11h - stos dword [edi] - ret - broken_value: - mov eax,0Fh - jmp store_label_value - register_value: - pop edi - mov byte [edi-1],10h - stos byte [edi] - ret - preprocessor_value: - dec edi - cmp [hash_tree],0 - je invalid_value - lods byte [esi] - cmp al,1Ah - jne invalid_value - lods byte [esi] - mov cl,al - mov ch,10b - call get_preprocessor_symbol - jc invalid_value - push esi - mov esi,[edx+8] - push [current_offset] - call convert_expression - pop [current_offset] - pop esi - ret - -get_number: - xor ebp,ebp - lods byte [esi] - cmp al,22h - je get_text_number - cmp al,1Ah - jne not_number - lods byte [esi] - movzx ecx,al - mov [number_start],esi - mov al,[esi] - cmp al,'$' - je number_begin - sub al,30h - cmp al,9 - ja invalid_number - number_begin: - mov ebx,esi - add esi,ecx - push esi - dec esi - mov dword [edi],0 - mov dword [edi+4],0 - cmp byte [ebx],'$' - je pascal_hex_number - cmp word [ebx],'0x' - je get_hex_number - mov al,[esi] - dec esi - cmp al,'h' - je get_hex_number - cmp al,'b' - je get_bin_number - cmp al,'d' - je get_dec_number - cmp al,'o' - je get_oct_number - cmp al,'H' - je get_hex_number - cmp al,'B' - je get_bin_number - cmp al,'D' - je get_dec_number - cmp al,'O' - je get_oct_number - inc esi - get_dec_number: - mov ebx,esi - mov esi,[number_start] - get_dec_digit: - cmp esi,ebx - ja number_ok - cmp byte [esi],27h - je next_dec_digit - xor edx,edx - mov eax,[edi] - shld edx,eax,2 - shl eax,2 - add eax,[edi] - adc edx,0 - add eax,eax - adc edx,edx - mov [edi],eax - mov eax,[edi+4] - add eax,eax - jc dec_out_of_range - add eax,eax - jc dec_out_of_range - add eax,[edi+4] - jc dec_out_of_range - add eax,eax - jc dec_out_of_range - add eax,edx - jc dec_out_of_range - mov [edi+4],eax - movzx eax,byte [esi] - sub al,30h - cmp al,9 - ja bad_number - add [edi],eax - adc dword [edi+4],0 - jc dec_out_of_range - next_dec_digit: - inc esi - jmp get_dec_digit - dec_out_of_range: - or ebp,-1 - inc esi - jmp get_dec_digit - bad_number: - pop eax - invalid_number: - mov esi,[number_start] - dec esi - not_number: - dec esi - stc - ret - get_bin_number: - xor bl,bl - get_bin_digit: - cmp esi,[number_start] - jb number_ok - movzx eax,byte [esi] - cmp al,27h - je bin_digit_skip - sub al,30h - cmp al,1 - ja bad_number - xor edx,edx - mov cl,bl - dec esi - cmp bl,64 - je bin_out_of_range - inc bl - cmp cl,32 - jae bin_digit_high - shl eax,cl - or dword [edi],eax - jmp get_bin_digit - bin_digit_high: - sub cl,32 - shl eax,cl - or dword [edi+4],eax - jmp get_bin_digit - bin_out_of_range: - or al,al - jz get_bin_digit - or ebp,-1 - jmp get_bin_digit - bin_digit_skip: - dec esi - jmp get_bin_digit - pascal_hex_number: - cmp cl,1 - je bad_number - get_hex_number: - xor bl,bl - get_hex_digit: - cmp esi,[number_start] - jb number_ok - movzx eax,byte [esi] - cmp al,27h - je hex_digit_skip - cmp al,'x' - je hex_number_ok - cmp al,'$' - je pascal_hex_ok - sub al,30h - cmp al,9 - jbe hex_digit_ok - sub al,7 - cmp al,15 - jbe hex_letter_digit_ok - sub al,20h - cmp al,15 - ja bad_number - hex_letter_digit_ok: - cmp al,10 - jb bad_number - hex_digit_ok: - xor edx,edx - mov cl,bl - dec esi - cmp bl,64 - je hex_out_of_range - add bl,4 - cmp cl,32 - jae hex_digit_high - shl eax,cl - or dword [edi],eax - jmp get_hex_digit - hex_digit_high: - sub cl,32 - shl eax,cl - or dword [edi+4],eax - jmp get_hex_digit - hex_out_of_range: - or al,al - jz get_hex_digit - or ebp,-1 - jmp get_hex_digit - hex_digit_skip: - dec esi - jmp get_hex_digit - get_oct_number: - xor bl,bl - get_oct_digit: - cmp esi,[number_start] - jb number_ok - movzx eax,byte [esi] - cmp al,27h - je oct_digit_skip - sub al,30h - cmp al,7 - ja bad_number - oct_digit_ok: - xor edx,edx - mov cl,bl - dec esi - cmp bl,64 - jae oct_out_of_range - add bl,3 - cmp cl,30 - je oct_digit_wrap - ja oct_digit_high - shl eax,cl - or dword [edi],eax - jmp get_oct_digit - oct_digit_wrap: - shl eax,cl - adc dword [edi+4],0 - or dword [edi],eax - jmp get_oct_digit - oct_digit_high: - sub cl,32 - shl eax,cl - or dword [edi+4],eax - jmp get_oct_digit - oct_digit_skip: - dec esi - jmp get_oct_digit - oct_out_of_range: - or al,al - jz get_oct_digit - or ebp,-1 - jmp get_oct_digit - hex_number_ok: - dec esi - pascal_hex_ok: - cmp esi,[number_start] - jne bad_number - number_ok: - pop esi - number_done: - clc - ret - get_text_number: - lods dword [esi] - mov edx,eax - xor bl,bl - mov dword [edi],0 - mov dword [edi+4],0 - get_text_character: - sub edx,1 - jc number_done - movzx eax,byte [esi] - inc esi - mov cl,bl - cmp bl,64 - je text_out_of_range - add bl,8 - cmp cl,32 - jae text_character_high - shl eax,cl - or dword [edi],eax - jmp get_text_character - text_character_high: - sub cl,32 - shl eax,cl - or dword [edi+4],eax - jmp get_text_character - text_out_of_range: - or ebp,-1 - jmp get_text_character - -get_fp_value: - push edi esi - lods byte [esi] - cmp al,1Ah - je fp_value_start - cmp al,'-' - je fp_sign_ok - cmp al,'+' - jne not_fp_value - fp_sign_ok: - lods byte [esi] - cmp al,1Ah - jne not_fp_value - fp_value_start: - lods byte [esi] - movzx ecx,al - cmp cl,1 - jbe not_fp_value - lea edx,[esi+1] - xor ah,ah - check_fp_value: - lods byte [esi] - cmp al,'.' - je fp_character_dot - cmp al,'E' - je fp_character_exp - cmp al,'e' - je fp_character_exp - cmp al,'F' - je fp_last_character - cmp al,'f' - je fp_last_character - digit_expected: - cmp al,'0' - jb not_fp_value - cmp al,'9' - ja not_fp_value - jmp fp_character_ok - fp_character_dot: - cmp esi,edx - je not_fp_value - or ah,ah - jnz not_fp_value - or ah,1 - lods byte [esi] - loop digit_expected - not_fp_value: - pop esi edi - stc - ret - fp_last_character: - cmp cl,1 - jne not_fp_value - or ah,4 - jmp fp_character_ok - fp_character_exp: - cmp esi,edx - je not_fp_value - cmp ah,1 - ja not_fp_value - or ah,2 - cmp ecx,1 - jne fp_character_ok - cmp byte [esi],'+' - je fp_exp_sign - cmp byte [esi],'-' - jne fp_character_ok - fp_exp_sign: - inc esi - cmp byte [esi],1Ah - jne not_fp_value - inc esi - lods byte [esi] - movzx ecx,al - inc ecx - fp_character_ok: - dec ecx - jnz check_fp_value - or ah,ah - jz not_fp_value - pop esi - lods byte [esi] - mov [fp_sign],0 - cmp al,1Ah - je fp_get - inc esi - cmp al,'+' - je fp_get - mov [fp_sign],1 - fp_get: - lods byte [esi] - movzx ecx,al - xor edx,edx - mov edi,fp_value - mov [edi],edx - mov [edi+4],edx - mov [edi+12],edx - call fp_optimize - mov [fp_format],0 - mov al,[esi] - fp_before_dot: - lods byte [esi] - cmp al,'.' - je fp_dot - cmp al,'E' - je fp_exponent - cmp al,'e' - je fp_exponent - cmp al,'F' - je fp_done - cmp al,'f' - je fp_done - sub al,30h - mov edi,fp_value+16 - xor edx,edx - mov dword [edi+12],edx - mov dword [edi],edx - mov dword [edi+4],edx - mov [edi+7],al - mov dl,7 - mov dword [edi+8],edx - call fp_optimize - mov edi,fp_value - push ecx - mov ecx,10 - call fp_mul - pop ecx - mov ebx,fp_value+16 - call fp_add - loop fp_before_dot - fp_dot: - mov edi,fp_value+16 - xor edx,edx - mov [edi],edx - mov [edi+4],edx - mov byte [edi+7],80h - mov [edi+8],edx - mov dword [edi+12],edx - dec ecx - jz fp_done - fp_after_dot: - lods byte [esi] - cmp al,'E' - je fp_exponent - cmp al,'e' - je fp_exponent - cmp al,'F' - je fp_done - cmp al,'f' - je fp_done - inc [fp_format] - cmp [fp_format],80h - jne fp_counter_ok - mov [fp_format],7Fh - fp_counter_ok: - dec esi - mov edi,fp_value+16 - push ecx - mov ecx,10 - call fp_div - push dword [edi] - push dword [edi+4] - push dword [edi+8] - push dword [edi+12] - lods byte [esi] - sub al,30h - movzx ecx,al - call fp_mul - mov ebx,edi - mov edi,fp_value - call fp_add - mov edi,fp_value+16 - pop dword [edi+12] - pop dword [edi+8] - pop dword [edi+4] - pop dword [edi] - pop ecx - dec ecx - jnz fp_after_dot - jmp fp_done - fp_exponent: - or [fp_format],80h - xor edx,edx - xor ebp,ebp - dec ecx - jnz get_exponent - cmp byte [esi],'+' - je fp_exponent_sign - cmp byte [esi],'-' - jne fp_done - not ebp - fp_exponent_sign: - add esi,2 - lods byte [esi] - movzx ecx,al - get_exponent: - movzx eax,byte [esi] - inc esi - sub al,30h - cmp al,10 - jae exponent_ok - imul edx,10 - cmp edx,8000h - jae value_out_of_range - add edx,eax - loop get_exponent - exponent_ok: - mov edi,fp_value - or edx,edx - jz fp_done - mov ecx,edx - or ebp,ebp - jnz fp_negative_power - fp_power: - push ecx - mov ecx,10 - call fp_mul - pop ecx - loop fp_power - jmp fp_done - fp_negative_power: - push ecx - mov ecx,10 - call fp_div - pop ecx - loop fp_negative_power - fp_done: - mov edi,fp_value - mov al,[fp_format] - mov [edi+10],al - mov al,[fp_sign] - mov [edi+11],al - test byte [edi+15],80h - jz fp_ok - add dword [edi],1 - adc dword [edi+4],0 - jnc fp_ok - mov eax,[edi+4] - shrd [edi],eax,1 - shr eax,1 - or eax,80000000h - mov [edi+4],eax - inc word [edi+8] - fp_ok: - pop edi - clc - ret - fp_mul: - or ecx,ecx - jz fp_zero - mov eax,[edi+12] - mul ecx - mov [edi+12],eax - mov ebx,edx - mov eax,[edi] - mul ecx - add eax,ebx - adc edx,0 - mov [edi],eax - mov ebx,edx - mov eax,[edi+4] - mul ecx - add eax,ebx - adc edx,0 - mov [edi+4],eax - .loop: - or edx,edx - jz .done - mov eax,[edi] - shrd [edi+12],eax,1 - mov eax,[edi+4] - shrd [edi],eax,1 - shrd eax,edx,1 - mov [edi+4],eax - shr edx,1 - inc dword [edi+8] - cmp dword [edi+8],8000h - jge value_out_of_range - jmp .loop - .done: - ret - fp_div: - mov eax,[edi+4] - xor edx,edx - div ecx - mov [edi+4],eax - mov eax,[edi] - div ecx - mov [edi],eax - mov eax,[edi+12] - div ecx - mov [edi+12],eax - mov ebx,eax - or ebx,[edi] - or ebx,[edi+4] - jz fp_zero - .loop: - test byte [edi+7],80h - jnz .exp_ok - mov eax,[edi] - shld [edi+4],eax,1 - mov eax,[edi+12] - shld [edi],eax,1 - add eax,eax - mov [edi+12],eax - dec dword [edi+8] - add edx,edx - jmp .loop - .exp_ok: - mov eax,edx - xor edx,edx - div ecx - add [edi+12],eax - adc dword [edi],0 - adc dword [edi+4],0 - jnc .done - mov eax,[edi+4] - mov ebx,[edi] - shrd [edi],eax,1 - shrd [edi+12],ebx,1 - shr eax,1 - or eax,80000000h - mov [edi+4],eax - inc dword [edi+8] - .done: - ret - fp_add: - cmp dword [ebx+8],8000h - je .done - cmp dword [edi+8],8000h - je .copy - mov eax,[ebx+8] - cmp eax,[edi+8] - jge .exp_ok - mov eax,[edi+8] - .exp_ok: - call .change_exp - xchg ebx,edi - call .change_exp - xchg ebx,edi - mov edx,[ebx+12] - mov eax,[ebx] - mov ebx,[ebx+4] - add [edi+12],edx - adc [edi],eax - adc [edi+4],ebx - jnc .done - mov eax,[edi] - shrd [edi+12],eax,1 - mov eax,[edi+4] - shrd [edi],eax,1 - shr eax,1 - or eax,80000000h - mov [edi+4],eax - inc dword [edi+8] - .done: - ret - .copy: - mov eax,[ebx] - mov [edi],eax - mov eax,[ebx+4] - mov [edi+4],eax - mov eax,[ebx+8] - mov [edi+8],eax - mov eax,[ebx+12] - mov [edi+12],eax - ret - .change_exp: - push ecx - mov ecx,eax - sub ecx,[ebx+8] - mov edx,[ebx+4] - jecxz .exp_done - .exp_loop: - mov ebp,[ebx] - shrd [ebx+12],ebp,1 - shrd [ebx],edx,1 - shr edx,1 - inc dword [ebx+8] - loop .exp_loop - .exp_done: - mov [ebx+4],edx - pop ecx - ret - fp_optimize: - mov eax,[edi] - mov ebp,[edi+4] - or ebp,[edi] - or ebp,[edi+12] - jz fp_zero - .loop: - test byte [edi+7],80h - jnz .done - shld [edi+4],eax,1 - mov ebp,[edi+12] - shld eax,ebp,1 - mov [edi],eax - shl dword [edi+12],1 - dec dword [edi+8] - jmp .loop - .done: - ret - fp_zero: - mov dword [edi+8],8000h - ret - -calculate_expression: - mov [current_offset],edi - mov [value_undefined],0 - cmp byte [esi],0 - je get_string_value - cmp byte [esi],'.' - je convert_fp - calculation_loop: - lods byte [esi] - cmp al,1 - je get_byte_number - cmp al,2 - je get_word_number - cmp al,4 - je get_dword_number - cmp al,8 - je get_qword_number - cmp al,0Fh - je value_out_of_range - cmp al,10h - je get_register - cmp al,11h - je get_label - cmp al,')' - je expression_calculated - cmp al,']' - je expression_calculated - cmp al,'!' - je invalid_expression - sub edi,14h - mov ebx,edi - sub ebx,14h - cmp al,0E0h - je calculate_rva - cmp al,0E1h - je calculate_plt - cmp al,0D0h - je calculate_not - cmp al,083h - je calculate_neg - mov dx,[ebx+8] - or dx,[edi+8] - cmp al,80h - je calculate_add - cmp al,81h - je calculate_sub - mov ah,[ebx+12] - or ah,[edi+12] - jz absolute_values_calculation - cmp [error_line],0 - jne absolute_values_calculation - mov eax,[current_line] - mov [error_line],eax - mov [error],invalid_use_of_symbol - absolute_values_calculation: - cmp al,90h - je calculate_mul - cmp al,91h - je calculate_div - or dx,dx - jnz invalid_expression - cmp al,0A0h - je calculate_mod - cmp al,0B0h - je calculate_and - cmp al,0B1h - je calculate_or - cmp al,0B2h - je calculate_xor - cmp al,0C0h - je calculate_shl - cmp al,0C1h - je calculate_shr - jmp invalid_expression - expression_calculated: - sub edi,14h - cmp [value_undefined],0 - je expression_value_ok - xor eax,eax - mov [edi],eax - mov [edi+4],eax - mov [edi+12],al - expression_value_ok: - ret - get_byte_number: - xor eax,eax - lods byte [esi] - stos dword [edi] - xor al,al - stos dword [edi] - got_number: - mov word [edi-8+8],0 - mov byte [edi-8+12],0 - mov dword [edi-8+16],0 - add edi,0Ch - jmp calculation_loop - get_word_number: - xor eax,eax - lods word [esi] - stos dword [edi] - xor ax,ax - stos dword [edi] - jmp got_number - get_dword_number: - movs dword [edi],[esi] - xor eax,eax - stos dword [edi] - jmp got_number - get_qword_number: - movs dword [edi],[esi] - movs dword [edi],[esi] - jmp got_number - get_register: - mov byte [edi+9],0 - mov byte [edi+12],0 - lods byte [esi] - mov [edi+8],al - mov byte [edi+10],1 - xor eax,eax - mov [edi+16],eax - stos dword [edi] - stos dword [edi] - add edi,0Ch - jmp calculation_loop - get_label: - xor eax,eax - mov [edi+8],eax - mov [edi+12],al - mov [edi+20],eax - lods dword [esi] - cmp eax,0Fh - jb predefined_label - je reserved_word_used_as_symbol - mov ebx,eax - mov ax,[current_pass] - mov [ebx+18],ax - or byte [ebx+8],8 - test byte [ebx+8],1 - jz label_undefined - cmp ax,[ebx+16] - je label_defined - test byte [ebx+8],4 - jnz label_out_of_scope - test byte [ebx+9],1 - jz label_defined - mov eax,[ebx] - sub eax,dword [adjustment] - stos dword [edi] - mov eax,[ebx+4] - sbb eax,dword [adjustment+4] - stos dword [edi] - mov eax,dword [adjustment] - or eax,dword [adjustment+4] - jz got_label - or [next_pass_needed],-1 - jmp got_label - label_defined: - mov eax,[ebx] - stos dword [edi] - mov eax,[ebx+4] - stos dword [edi] - got_label: - mov al,[ebx+11] - mov [edi-8+12],al - mov eax,[ebx+12] - mov [edi-8+8],eax - mov eax,[ebx+20] - mov [edi-8+16],eax - add edi,0Ch - mov al,[ebx+10] - or al,al - jz calculation_loop - cmp [size_override],-1 - je calculation_loop - cmp [size_override],0 - je check_size - cmp [operand_size],0 - jne calculation_loop - mov [operand_size],al - jmp calculation_loop - check_size: - xchg [operand_size],al - or al,al - jz calculation_loop - cmp al,[operand_size] - jne operand_sizes_do_not_match - jmp calculation_loop - current_offset_label: - mov eax,[current_offset] - make_current_offset_label: - xor edx,edx - sub eax,dword [org_origin] - sbb edx,dword [org_origin+4] - stos dword [edi] - mov eax,edx - stos dword [edi] - mov eax,[org_registers] - stos dword [edi] - mov al,[labels_type] - mov [edi-12+12],al - mov eax,[org_symbol] - mov [edi-12+16],eax - add edi,8 - jmp calculation_loop - org_origin_label: - mov eax,[org_start] - jmp make_current_offset_label - counter_label: - mov eax,[counter] - make_dword_label_value: - stos dword [edi] - xor eax,eax - stos dword [edi] - add edi,0Ch - jmp calculation_loop - timestamp_label: - call make_timestamp - make_qword_label_value: - stos dword [edi] - mov eax,edx - stos dword [edi] - add edi,0Ch - jmp calculation_loop - predefined_label: - or eax,eax - jz current_offset_label - cmp eax,1 - je counter_label - cmp eax,2 - je timestamp_label - cmp eax,3 - je org_origin_label - mov edx,invalid_value - jmp error_undefined - label_out_of_scope: - mov edx,symbol_out_of_scope - mov eax,[ebx+24] - cmp [error_line],0 - jne error_undefined - mov [error_info],eax - jmp error_undefined - label_undefined: - mov edx,undefined_symbol - cmp [error_line],0 - jne error_undefined - mov eax,[ebx+24] - mov [error_info],eax - error_undefined: - cmp [current_pass],1 - ja undefined_value - force_next_pass: - or [next_pass_needed],-1 - undefined_value: - mov byte [edi+12],0 - or [value_undefined],-1 - xor eax,eax - stos dword [edi] - stos dword [edi] - add edi,0Ch - cmp [error_line],0 - jne calculation_loop - mov eax,[current_line] - mov [error_line],eax - mov [error],edx - jmp calculation_loop - calculate_add: - mov ecx,[ebx+16] - cmp byte [edi+12],0 - je add_values - mov ecx,[edi+16] - cmp byte [ebx+12],0 - je add_values - cmp [error_line],0 - jne add_values - mov eax,[current_line] - mov [error_line],eax - mov [error],invalid_use_of_symbol - add_values: - mov al,[edi+12] - or [ebx+12],al - mov [ebx+16],ecx - mov eax,[edi] - add [ebx],eax - mov eax,[edi+4] - adc [ebx+4],eax - or dx,dx - jz calculation_loop - push esi - mov esi,ebx - lea ebx,[edi+10] - mov cl,[edi+8] - call add_register - lea ebx,[edi+11] - mov cl,[edi+9] - call add_register - pop esi - jmp calculation_loop - add_register: - or cl,cl - jz add_register_done - add_register_start: - cmp [esi+8],cl - jne add_in_second_slot - mov al,[ebx] - add [esi+10],al - jnz add_register_done - mov byte [esi+8],0 - ret - add_in_second_slot: - cmp [esi+9],cl - jne create_in_first_slot - mov al,[ebx] - add [esi+11],al - jnz add_register_done - mov byte [esi+9],0 - ret - create_in_first_slot: - cmp byte [esi+8],0 - jne create_in_second_slot - mov [esi+8],cl - mov al,[ebx] - mov [esi+10],al - ret - create_in_second_slot: - cmp byte [esi+9],0 - jne invalid_expression - mov [esi+9],cl - mov al,[ebx] - mov [esi+11],al - add_register_done: - ret - calculate_sub: - xor ah,ah - mov ah,[ebx+12] - mov al,[edi+12] - or al,al - jz sub_values - cmp al,ah - jne invalid_sub - xor ah,ah - mov ecx,[edi+16] - cmp ecx,[ebx+16] - jne invalid_sub - sub_values: - mov [ebx+12],ah - mov eax,[edi] - sub [ebx],eax - mov eax,[edi+4] - sbb [ebx+4],eax - or dx,dx - jz calculation_loop - push esi - mov esi,ebx - lea ebx,[edi+10] - mov cl,[edi+8] - call sub_register - lea ebx,[edi+11] - mov cl,[edi+9] - call sub_register - pop esi - jmp calculation_loop - invalid_sub: - cmp [error_line],0 - jne sub_values - mov eax,[current_line] - mov [error_line],eax - mov [error],invalid_use_of_symbol - jmp sub_values - sub_register: - or cl,cl - jz add_register_done - neg byte [ebx] - jmp add_register_start - calculate_mul: - or dx,dx - jz mul_start - cmp word [ebx+8],0 - jne mul_start - mov eax,[ebx] - xchg eax,[edi] - mov [ebx],eax - mov eax,[ebx+4] - xchg eax,[edi+4] - mov [ebx+4],eax - mov eax,[ebx+8] - xchg eax,[edi+8] - mov [ebx+8],eax - mov eax,[ebx+12] - xchg eax,[edi+12] - mov [ebx+12],eax - mul_start: - push esi edx - mov esi,ebx - xor bl,bl - bt dword [esi+4],31 - jnc mul_first_sign_ok - not dword [esi] - not dword [esi+4] - add dword [esi],1 - adc dword [esi+4],0 - not bl - mul_first_sign_ok: - bt dword [edi+4],31 - jnc mul_second_sign_ok - not dword [edi] - not dword [edi+4] - add dword [edi],1 - adc dword [edi+4],0 - not bl - mul_second_sign_ok: - cmp dword [esi+4],0 - jz mul_numbers - cmp dword [edi+4],0 - jnz value_out_of_range - mul_numbers: - mov eax,[esi+4] - mul dword [edi] - or edx,edx - jnz value_out_of_range - mov ecx,eax - mov eax,[esi] - mul dword [edi+4] - or edx,edx - jnz value_out_of_range - add ecx,eax - jc value_out_of_range - mov eax,[esi] - mul dword [edi] - add edx,ecx - jc value_out_of_range - test edx,1 shl 31 - jnz value_out_of_range - mov [esi],eax - mov [esi+4],edx - or bl,bl - jz mul_ok - not dword [esi] - not dword [esi+4] - add dword [esi],1 - adc dword [esi+4],0 - mul_ok: - pop edx - or dx,dx - jz mul_calculated - cmp word [edi+8],0 - jne invalid_value - cmp byte [esi+8],0 - je mul_first_register_ok - mov al,[edi] - cbw - cwde - cdq - cmp edx,[edi+4] - jne value_out_of_range - cmp eax,[edi] - jne value_out_of_range - imul byte [esi+10] - mov dl,ah - cbw - cmp ah,dl - jne value_out_of_range - mov [esi+10],al - or al,al - jnz mul_first_register_ok - mov [esi+8],al - mul_first_register_ok: - cmp byte [esi+9],0 - je mul_calculated - mov al,[edi] - cbw - cwde - cdq - cmp edx,[edi+4] - jne value_out_of_range - cmp eax,[edi] - jne value_out_of_range - imul byte [esi+11] - mov dl,ah - cbw - cmp ah,dl - jne value_out_of_range - mov [esi+11],al - or al,al - jnz mul_calculated - mov [esi+9],al - mul_calculated: - pop esi - jmp calculation_loop - calculate_div: - push esi edx - mov esi,ebx - call div_64 - pop edx - or dx,dx - jz div_calculated - cmp byte [esi+8],0 - je div_first_register_ok - mov al,[edi] - cbw - cwde - cdq - cmp edx,[edi+4] - jne value_out_of_range - cmp eax,[edi] - jne value_out_of_range - or al,al - jz value_out_of_range - mov al,[esi+10] - cbw - idiv byte [edi] - or ah,ah - jnz invalid_use_of_symbol - mov [esi+10],al - div_first_register_ok: - cmp byte [esi+9],0 - je div_calculated - mov al,[edi] - cbw - cwde - cdq - cmp edx,[edi+4] - jne value_out_of_range - cmp eax,[edi] - jne value_out_of_range - or al,al - jz value_out_of_range - mov al,[esi+11] - cbw - idiv byte [edi] - or ah,ah - jnz invalid_use_of_symbol - mov [esi+11],al - div_calculated: - pop esi - jmp calculation_loop - calculate_mod: - push esi - mov esi,ebx - call div_64 - mov [esi],eax - mov [esi+4],edx - pop esi - jmp calculation_loop - calculate_and: - mov eax,[edi] - and [ebx],eax - mov eax,[edi+4] - and [ebx+4],eax - jmp calculation_loop - calculate_or: - mov eax,[edi] - or [ebx],eax - mov eax,[edi+4] - or [ebx+4],eax - jmp calculation_loop - calculate_xor: - mov eax,[edi] - xor [ebx],eax - mov eax,[edi+4] - xor [ebx+4],eax - jmp calculation_loop - shr_negative: - not dword [edi] - not dword [edi+4] - add dword [edi],1 - adc dword [edi+4],0 - calculate_shl: - mov eax,dword [edi+4] - bt eax,31 - jc shl_negative - or eax,eax - jnz zero_value - mov ecx,[edi] - cmp ecx,64 - jae zero_value - cmp ecx,32 - jae shl_high - mov edx,[ebx+4] - mov eax,[ebx] - shld edx,eax,cl - shl eax,cl - mov [ebx],eax - mov [ebx+4],edx - jmp calculation_loop - shl_high: - sub cl,32 - mov eax,[ebx] - shl eax,cl - mov [ebx+4],eax - mov dword [ebx],0 - jmp calculation_loop - shl_negative: - not dword [edi] - not dword [edi+4] - add dword [edi],1 - adc dword [edi+4],0 - calculate_shr: - mov eax,dword [edi+4] - bt eax,31 - jc shr_negative - or eax,eax - jnz zero_value - mov ecx,[edi] - cmp ecx,64 - jae zero_value - cmp ecx,32 - jae shr_high - mov edx,[ebx+4] - mov eax,[ebx] - shrd eax,edx,cl - shr edx,cl - mov [ebx],eax - mov [ebx+4],edx - jmp calculation_loop - shr_high: - sub cl,32 - mov eax,[ebx+4] - shr eax,cl - mov [ebx],eax - mov dword [ebx+4],0 - jmp calculation_loop - zero_value: - mov dword [ebx],0 - mov dword [ebx+4],0 - jmp calculation_loop - calculate_not: - cmp word [edi+8],0 - jne invalid_expression - cmp byte [edi+12],0 - je not_ok - cmp [error_line],0 - jne not_ok - mov eax,[current_line] - mov [error_line],eax - mov [error],invalid_use_of_symbol - not_ok: - cmp [value_size],1 - je not_byte - cmp [value_size],2 - je not_word - cmp [value_size],4 - je not_dword - cmp [value_size],6 - je not_pword - not_qword: - not dword [edi] - not dword [edi+4] - add edi,14h - jmp calculation_loop - not_byte: - cmp dword [edi+4],0 - jne not_qword - cmp word [edi+2],0 - jne not_qword - cmp byte [edi+1],0 - jne not_qword - not byte [edi] - add edi,14h - jmp calculation_loop - not_word: - cmp dword [edi+4],0 - jne not_qword - cmp word [edi+2],0 - jne not_qword - not word [edi] - add edi,14h - jmp calculation_loop - not_dword: - cmp dword [edi+4],0 - jne not_qword - not dword [edi] - add edi,14h - jmp calculation_loop - not_pword: - cmp word [edi+6],0 - jne not_qword - not dword [edi] - not word [edi+4] - add edi,14h - jmp calculation_loop - calculate_neg: - cmp word [edi+8],0 - jne invalid_expression - cmp byte [edi+12],0 - je neg_ok - cmp [error_line],0 - jne neg_ok - mov eax,[current_line] - mov [error_line],eax - mov [error],invalid_use_of_symbol - neg_ok: - mov eax,[edi] - mov edx,[edi+4] - mov dword [edi],0 - mov dword [edi+4],0 - sub [edi],eax - sbb [edi+4],edx - add edi,14h - jmp calculation_loop - calculate_rva: - cmp word [edi+8],0 - jne invalid_expression - cmp [output_format],5 - je calculate_gotoff - cmp [output_format],4 - je calculate_coff_rva - cmp [output_format],3 - jne invalid_expression - test [format_flags],8 - jnz pe64_rva - mov al,2 - bt [resolver_flags],0 - jc rva_type_ok - xor al,al - rva_type_ok: - cmp byte [edi+12],al - je rva_ok - cmp [error_line],0 - jne rva_ok - mov eax,[current_line] - mov [error_line],eax - mov [error],invalid_use_of_symbol - rva_ok: - mov byte [edi+12],0 - mov eax,[code_start] - mov eax,[eax+34h] - cdq - sub [edi],eax - sbb [edi+4],edx - add edi,14h - jmp calculation_loop - pe64_rva: - mov al,4 - bt [resolver_flags],0 - jc pe64_rva_type_ok - xor al,al - pe64_rva_type_ok: - cmp byte [edi+12],al - je pe64_rva_ok - cmp [error_line],0 - jne pe64_rva_ok - mov eax,[current_line] - mov [error_line],eax - mov [error],invalid_use_of_symbol - pe64_rva_ok: - mov byte [edi+12],0 - mov eax,[code_start] - mov edx,[eax+34h] - mov eax,[eax+30h] - sub [edi],eax - sbb [edi+4],edx - add edi,14h - jmp calculation_loop - calculate_gotoff: - test [format_flags],8+1 - jnz invalid_expression - calculate_coff_rva: - mov dl,5 - cmp byte [edi+12],2 - je change_value_type - incorrect_change_of_value_type: - cmp [error_line],0 - jne change_value_type - mov eax,[current_line] - mov [error_line],eax - mov [error],invalid_use_of_symbol - change_value_type: - mov byte [edi+12],dl - add edi,14h - jmp calculation_loop - calculate_plt: - cmp word [edi+8],0 - jne invalid_expression - cmp [output_format],5 - jne invalid_expression - test [format_flags],1 - jnz invalid_expression - mov dl,6 - mov dh,2 - test [format_flags],8 - jz check_value_for_plt - mov dh,4 - check_value_for_plt: - mov eax,[edi] - or eax,[edi+4] - jnz incorrect_change_of_value_type - cmp byte [edi+12],dh - jne incorrect_change_of_value_type - mov eax,[edi+16] - cmp byte [eax],80h - jne incorrect_change_of_value_type - jmp change_value_type - div_64: - xor ebx,ebx - cmp dword [edi],0 - jne divider_ok - cmp dword [edi+4],0 - jne divider_ok - cmp [next_pass_needed],0 - je value_out_of_range - jmp div_done - divider_ok: - bt dword [esi+4],31 - jnc div_first_sign_ok - not dword [esi] - not dword [esi+4] - add dword [esi],1 - adc dword [esi+4],0 - not bx - div_first_sign_ok: - bt dword [edi+4],31 - jnc div_second_sign_ok - not dword [edi] - not dword [edi+4] - add dword [edi],1 - adc dword [edi+4],0 - not bl - div_second_sign_ok: - cmp dword [edi+4],0 - jne div_high - mov ecx,[edi] - mov eax,[esi+4] - xor edx,edx - div ecx - mov [esi+4],eax - mov eax,[esi] - div ecx - mov [esi],eax - mov eax,edx - xor edx,edx - jmp div_done - div_high: - mov eax,[esi+4] - xor edx,edx - div dword [edi+4] - mov ebx,[esi] - mov [esi],eax - mov dword [esi+4],0 - mov ecx,edx - mul dword [edi] - div_high_loop: - cmp ecx,edx - ja div_high_done - jb div_high_large_correction - cmp ebx,eax - jae div_high_done - div_high_correction: - dec dword [esi] - sub eax,[edi] - sbb edx,[edi+4] - jnc div_high_loop - div_high_done: - sub ebx,eax - sbb ecx,edx - mov edx,ecx - mov eax,ebx - ret - div_high_large_correction: - push eax edx - mov eax,edx - sub eax,ecx - xor edx,edx - div dword [edi+4] - shr eax,1 - jz div_high_small_correction - sub [esi],eax - push eax - mul dword [edi+4] - sub dword [esp+4],eax - pop eax - mul dword [edi] - sub dword [esp+4],eax - sbb dword [esp],edx - pop edx eax - jmp div_high_loop - div_high_small_correction: - pop edx eax - jmp div_high_correction - div_done: - or bh,bh - jz remainder_ok - not eax - not edx - add eax,1 - adc edx,0 - remainder_ok: - or bl,bl - jz div_ok - not dword [esi] - not dword [esi+4] - add dword [esi],1 - adc dword [esi+4],0 - div_ok: - ret - convert_fp: - inc esi - mov word [edi+8],0 - mov byte [edi+12],0 - mov al,[value_size] - cmp al,4 - je convert_fp_dword - cmp al,8 - je convert_fp_qword - jmp invalid_value - convert_fp_dword: - xor eax,eax - cmp word [esi+8],8000h - je fp_dword_store - mov bx,[esi+8] - mov eax,[esi+4] - shl eax,1 - shr eax,9 - jnc fp_dword_ok - inc eax - bt eax,23 - jnc fp_dword_ok - and eax,1 shl 23 - 1 - inc bx - shr eax,1 - fp_dword_ok: - add bx,7Fh - cmp bx,0FFh - jge value_out_of_range - cmp bx,0 - jg fp_dword_exp_ok - or eax,1 shl 23 - mov cx,bx - neg cx - inc cx - cmp cx,23 - ja value_out_of_range - xor bx,bx - shr eax,cl - jnc fp_dword_exp_ok - inc eax - test eax,1 shl 23 - jz fp_dword_exp_ok - and eax,1 shl 23 - 1 - inc bx - fp_dword_exp_ok: - shl ebx,23 - or eax,ebx - fp_dword_store: - mov bl,[esi+11] - shl ebx,31 - or eax,ebx - mov [edi],eax - xor eax,eax - mov [edi+4],eax - add esi,13 - ret - convert_fp_qword: - xor eax,eax - xor edx,edx - cmp word [esi+8],8000h - je fp_qword_store - mov bx,[esi+8] - mov eax,[esi] - mov edx,[esi+4] - add eax,eax - adc edx,edx - mov ecx,edx - shr edx,12 - shrd eax,ecx,12 - jnc fp_qword_ok - add eax,1 - adc edx,0 - bt edx,20 - jnc fp_qword_ok - and edx,1 shl 20 - 1 - inc bx - shr edx,1 - rcr eax,1 - fp_qword_ok: - add bx,3FFh - cmp bx,7FFh - jge value_out_of_range - cmp bx,0 - jg fp_qword_exp_ok - or edx,1 shl 20 - mov cx,bx - neg cx - inc cx - cmp cx,52 - ja value_out_of_range - cmp cx,32 - jbe fp_qword_small_shift - sub cx,32 - mov eax,edx - xor edx,edx - shr eax,cl - jmp fp_qword_shift_done - fp_qword_small_shift: - mov ebx,edx - shr edx,cl - shrd eax,ebx,cl - fp_qword_shift_done: - mov bx,0 - jnc fp_qword_exp_ok - add eax,1 - adc edx,0 - test edx,1 shl 20 - jz fp_qword_exp_ok - and edx,1 shl 20 - 1 - inc bx - fp_qword_exp_ok: - shl ebx,20 - or edx,ebx - fp_qword_store: - mov bl,[esi+11] - shl ebx,31 - or edx,ebx - mov [edi],eax - mov [edi+4],edx - add esi,13 - ret - get_string_value: - inc esi - lods dword [esi] - mov ecx,eax - cmp ecx,8 - ja value_out_of_range - mov edx,edi - xor eax,eax - stos dword [edi] - stos dword [edi] - mov edi,edx - rep movs byte [edi],[esi] - mov edi,edx - inc esi - mov word [edi+8],0 - mov byte [edi+12],0 - ret - -get_byte_value: - mov [value_size],1 - mov [size_override],-1 - call calculate_expression - mov eax,[edi+16] - mov [symbol_identifier],eax - mov [value_type],0 - cmp word [edi+8],0 - jne invalid_value - cmp byte [edi+12],0 - je check_byte_value - cmp [error_line],0 - jne check_byte_value - mov eax,[current_line] - mov [error_line],eax - mov [error],invalid_use_of_symbol - check_byte_value: - mov eax,[edi] - mov edx,[edi+4] - or edx,edx - jz byte_positive - cmp edx,-1 - jne range_exceeded - cmp eax,-80h - jb range_exceeded - ret - byte_positive: - cmp eax,100h - jae range_exceeded - return_byte_value: - ret - range_exceeded: - xor eax,eax - xor edx,edx - cmp [error_line],0 - jne return_byte_value - mov ecx,[current_line] - mov [error_line],ecx - mov [error],value_out_of_range - ret -get_word_value: - mov [value_size],2 - mov [size_override],-1 - call calculate_expression - cmp word [edi+8],0 - jne invalid_value - mov eax,[edi+16] - mov [symbol_identifier],eax - mov al,[edi+12] - mov [value_type],al - cmp al,2 - jb check_word_value - cmp [error_line],0 - jne check_word_value - mov eax,[current_line] - mov [error_line],eax - mov [error],invalid_use_of_symbol - check_word_value: - mov eax,[edi] - mov edx,[edi+4] - or edx,edx - jz word_positive - cmp edx,-1 - jne range_exceeded - cmp eax,-8000h - jb range_exceeded - ret - word_positive: - cmp eax,10000h - jae range_exceeded - ret -get_dword_value: - mov [value_size],4 - mov [size_override],-1 - call calculate_expression - cmp word [edi+8],0 - jne invalid_value - mov eax,[edi+16] - mov [symbol_identifier],eax - mov al,[edi+12] - mov [value_type],al - cmp al,4 - jne check_dword_value - mov [value_type],2 - mov eax,[edi] - cdq - cmp edx,[edi+4] - jne range_exceeded - ret - check_dword_value: - mov eax,[edi] - mov edx,[edi+4] - or edx,edx - jz dword_positive - cmp edx,-1 - jne range_exceeded - bt eax,31 - jnc range_exceeded - dword_positive: - ret -get_pword_value: - mov [value_size],6 - mov [size_override],-1 - call calculate_expression - mov eax,[edi+16] - mov [symbol_identifier],eax - cmp word [edi+8],0 - jne invalid_value - mov al,[edi+12] - mov [value_type],al - cmp al,4 - jne check_pword_value - cmp [error_line],0 - jne check_pword_value - mov eax,[current_line] - mov [error_line],eax - mov [error],invalid_use_of_symbol - check_pword_value: - mov eax,[edi] - mov edx,[edi+4] - cmp edx,10000h - jge range_exceeded - cmp edx,-8000h - jl range_exceeded - ret -get_qword_value: - mov [value_size],8 - mov [size_override],-1 - call calculate_expression - cmp word [edi+8],0 - jne invalid_value - mov eax,[edi+16] - mov [symbol_identifier],eax - mov al,[edi+12] - mov [value_type],al - check_qword_value: - mov eax,[edi] - mov edx,[edi+4] - ret -get_value: - mov [operand_size],0 - lods byte [esi] - call get_size_operator - cmp al,'(' - jne invalid_value - mov al,[operand_size] - cmp al,1 - je value_byte - cmp al,2 - je value_word - cmp al,4 - je value_dword - cmp al,6 - je value_pword - cmp al,8 - je value_qword - or al,al - jnz invalid_value - value_qword: - call get_qword_value - ret - value_pword: - call get_pword_value - movzx edx,dx - ret - value_dword: - call get_dword_value - xor edx,edx - ret - value_word: - call get_word_value - xor edx,edx - movzx eax,ax - ret - value_byte: - call get_byte_value - xor edx,edx - movzx eax,al - ret -get_address_word_value: - mov [address_size],2 - mov [value_size],2 - jmp calculate_address -get_address_dword_value: - mov [address_size],4 - mov [value_size],4 - jmp calculate_address -get_address_qword_value: - mov [address_size],8 - mov [value_size],8 - jmp calculate_address -get_address_value: - mov [address_size],0 - mov [value_size],8 - calculate_address: - cmp byte [esi],'.' - je invalid_address - call calculate_expression - mov eax,[edi+16] - mov [address_symbol],eax - mov al,[edi+12] - mov [value_type],al - cmp al,6 - je special_address_type_32bit - cmp al,5 - je special_address_type_32bit - ja invalid_use_of_symbol - test al,1 - jnz invalid_use_of_symbol - or al,al - jz address_size_ok - shl al,5 - jmp address_symbol_ok - special_address_type_32bit: - mov al,40h - address_symbol_ok: - mov ah,[address_size] - or [address_size],al - shr al,4 - or ah,ah - jz address_size_ok - cmp al,ah - je address_size_ok - cmp ax,0804h - jne address_sizes_do_not_agree - cmp [value_type],2 - ja value_type_correction_ok - mov [value_type],2 - value_type_correction_ok: - mov eax,[edi] - cdq - cmp edx,[edi+4] - je address_size_ok - cmp [error_line],0 - jne address_size_ok - mov ecx,[current_line] - mov [error_line],ecx - mov [error],value_out_of_range - address_size_ok: - xor ebx,ebx - xor ecx,ecx - mov cl,[value_type] - shl ecx,16 - mov ch,[address_size] - cmp word [edi+8],0 - je check_immediate_address - mov al,[edi+8] - mov dl,[edi+10] - call get_address_register - mov al,[edi+9] - mov dl,[edi+11] - call get_address_register - mov ax,bx - shr ah,4 - shr al,4 - or bh,bh - jz check_address_registers - or bl,bl - jz check_address_registers - cmp al,ah - jne invalid_address - check_address_registers: - or al,ah - mov ah,[address_size] - and ah,0Fh - jz address_registers_sizes_ok - cmp al,ah - jne address_sizes_do_not_match - address_registers_sizes_ok: - cmp al,4 - je sib_allowed - cmp al,8 - je sib_allowed - cmp al,0Fh - je check_ip_relative_address - or cl,cl - jz check_word_value - cmp cl,1 - je check_word_value - jmp invalid_address - address_sizes_do_not_match: - cmp al,0Fh - jne invalid_address - mov al,bh - and al,0Fh - cmp al,ah - jne invalid_address - check_ip_relative_address: - cmp bh,0F4h - je check_dword_value - cmp bh,0F8h - jne invalid_address - mov eax,[edi] - cdq - cmp edx,[edi+4] - jne range_exceeded - ret - get_address_register: - or al,al - jz address_register_ok - cmp dl,1 - jne scaled_register - or bh,bh - jnz scaled_register - mov bh,al - address_register_ok: - ret - scaled_register: - or bl,bl - jnz invalid_address - mov bl,al - mov cl,dl - jmp address_register_ok - sib_allowed: - or bh,bh - jnz check_index_scale - cmp cl,2 - je special_index_scale - cmp cl,3 - je special_index_scale - cmp cl,5 - je special_index_scale - cmp cl,9 - je special_index_scale - check_index_scale: - or cl,cl - jz check_immediate_address - cmp cl,1 - je check_immediate_address - cmp cl,2 - je check_immediate_address - cmp cl,4 - je check_immediate_address - cmp cl,8 - je check_immediate_address - jmp invalid_address - special_index_scale: - mov bh,bl - dec cl - check_immediate_address: - mov al,[address_size] - and al,0Fh - cmp al,2 - je check_word_value - cmp al,4 - je check_dword_value - cmp al,8 - je check_qword_value - or al,al - jnz invalid_value - cmp [code_type],64 - jne check_dword_value - jmp check_qword_value -calculate_relative_offset: - cmp [value_undefined],0 - jne relative_offset_ok - test bh,bh - setne ch - cmp bx,word [org_registers] - je origin_registers_ok - xchg bh,bl - xchg ch,cl - cmp bx,word [org_registers] - jne invalid_value - origin_registers_ok: - cmp cx,word [org_registers+2] - jne invalid_value - add eax,dword [org_origin] - adc edx,dword [org_origin+4] - sub eax,edi - sbb edx,0 - mov bl,[value_type] - or bl,bl - je relative_offset_ok - test bl,1 - jnz invalid_use_of_symbol - mov ecx,[address_symbol] - mov [symbol_identifier],ecx - cmp bl,6 - je plt_relative_offset - cmp bl,[labels_type] - jne invalid_use_of_symbol - mov [value_type],0 - cmp ecx,[org_symbol] - je relative_offset_ok - mov [value_type],3 - relative_offset_ok: - ret - plt_relative_offset: - mov [value_type],7 - ret - -preevaluate_logical_expression: - xor al,al - preevaluate_embedded_logical_expression: - mov [logical_value_wrapping],al - push edi - call preevaluate_logical_value - preevaluation_loop: - cmp al,0FFh - je invalid_logical_expression - mov dl,[esi] - inc esi - cmp dl,'|' - je preevaluate_or - cmp dl,'&' - je preevaluate_and - cmp dl,'}' - je preevaluation_done - or dl,dl - jnz invalid_logical_expression - preevaluation_done: - pop edx - dec esi - ret - preevaluate_or: - cmp al,'1' - je quick_true - cmp al,'0' - je leave_only_following - push edi - mov al,dl - stos byte [edi] - call preevaluate_logical_value - pop ebx - cmp al,'0' - je leave_only_preceding - cmp al,'1' - jne preevaluation_loop - stos byte [edi] - xor al,al - jmp preevaluation_loop - preevaluate_and: - cmp al,'0' - je quick_false - cmp al,'1' - je leave_only_following - push edi - mov al,dl - stos byte [edi] - call preevaluate_logical_value - pop ebx - cmp al,'1' - je leave_only_preceding - cmp al,'0' - jne preevaluation_loop - stos byte [edi] - xor al,al - jmp preevaluation_loop - leave_only_following: - mov edi,[esp] - call preevaluate_logical_value - jmp preevaluation_loop - leave_only_preceding: - mov edi,ebx - xor al,al - jmp preevaluation_loop - quick_true: - call skip_logical_value - jc invalid_logical_expression - mov edi,[esp] - mov al,'1' - jmp preevaluation_loop - quick_false: - call skip_logical_value - jc invalid_logical_expression - mov edi,[esp] - mov al,'0' - jmp preevaluation_loop - invalid_logical_expression: - pop edi - mov esi,edi - mov al,0FFh - stos byte [edi] - ret - skip_logical_value: - cmp byte [esi],'~' - jne negation_skipped - inc esi - jmp skip_logical_value - negation_skipped: - mov al,[esi] - cmp al,'{' - jne skip_simple_logical_value - inc esi - xchg al,[logical_value_wrapping] - push eax - skip_logical_expression: - call skip_logical_value - lods byte [esi] - or al,al - jz wrongly_structured_logical_expression - cmp al,0Fh - je wrongly_structured_logical_expression - cmp al,'|' - je skip_logical_expression - cmp al,'&' - je skip_logical_expression - cmp al,'}' - jne wrongly_structured_logical_expression - pop eax - mov [logical_value_wrapping],al - logical_value_skipped: - clc - ret - wrongly_structured_logical_expression: - pop eax - stc - ret - skip_simple_logical_value: - mov [logical_value_parentheses],0 - find_simple_logical_value_end: - mov al,[esi] - or al,al - jz logical_value_skipped - cmp al,0Fh - je logical_value_skipped - cmp al,'|' - je logical_value_skipped - cmp al,'&' - je logical_value_skipped - cmp al,'{' - je skip_logical_value_internal_parenthesis - cmp al,'}' - jne skip_logical_value_symbol - sub [logical_value_parentheses],1 - jnc skip_logical_value_symbol - cmp [logical_value_wrapping],'{' - jne skip_logical_value_symbol - jmp logical_value_skipped - skip_logical_value_internal_parenthesis: - inc [logical_value_parentheses] - skip_logical_value_symbol: - call skip_symbol - jmp find_simple_logical_value_end - preevaluate_logical_value: - mov ebp,edi - preevaluate_negation: - cmp byte [esi],'~' - jne preevaluate_negation_ok - movs byte [edi],[esi] - jmp preevaluate_negation - preevaluate_negation_ok: - mov ebx,esi - cmp byte [esi],'{' - jne preevaluate_simple_logical_value - lods byte [esi] - stos byte [edi] - push ebp - mov dl,[logical_value_wrapping] - push edx - call preevaluate_embedded_logical_expression - pop edx - mov [logical_value_wrapping],dl - pop ebp - cmp al,0FFh - je invalid_logical_value - cmp byte [esi],'}' - jne invalid_logical_value - or al,al - jnz preevaluated_expression_value - movs byte [edi],[esi] - ret - preevaluated_expression_value: - inc esi - lea edx,[edi-1] - sub edx,ebp - test edx,1 - jz expression_negation_ok - xor al,1 - expression_negation_ok: - mov edi,ebp - ret - invalid_logical_value: - mov edi,ebp - mov al,0FFh - ret - preevaluate_simple_logical_value: - xor edx,edx - mov [logical_value_parentheses],edx - find_logical_value_boundaries: - mov al,[esi] - or al,al - jz logical_value_boundaries_found - cmp al,'{' - je logical_value_internal_parentheses - cmp al,'}' - je logical_value_boundaries_parenthesis_close - cmp al,'|' - je logical_value_boundaries_found - cmp al,'&' - je logical_value_boundaries_found - or edx,edx - jnz next_symbol_in_logical_value - cmp al,0F0h - je preevaluable_logical_operator - cmp al,0F7h - je preevaluable_logical_operator - cmp al,0F6h - jne next_symbol_in_logical_value - preevaluable_logical_operator: - mov edx,esi - next_symbol_in_logical_value: - call skip_symbol - jmp find_logical_value_boundaries - logical_value_internal_parentheses: - inc [logical_value_parentheses] - jmp next_symbol_in_logical_value - logical_value_boundaries_parenthesis_close: - sub [logical_value_parentheses],1 - jnc next_symbol_in_logical_value - cmp [logical_value_wrapping],'{' - jne next_symbol_in_logical_value - logical_value_boundaries_found: - or edx,edx - jz non_preevaluable_logical_value - mov al,[edx] - cmp al,0F0h - je compare_symbols - cmp al,0F7h - je compare_symbol_types - cmp al,0F6h - je scan_symbols_list - non_preevaluable_logical_value: - mov ecx,esi - mov esi,ebx - sub ecx,esi - jz invalid_logical_value - cmp esi,edi - je leave_logical_value_intact - rep movs byte [edi],[esi] - xor al,al - ret - leave_logical_value_intact: - add edi,ecx - add esi,ecx - xor al,al - ret - compare_symbols: - lea ecx,[esi-1] - sub ecx,edx - mov eax,edx - sub eax,ebx - cmp ecx,eax - jne preevaluated_false - push esi edi - mov esi,ebx - lea edi,[edx+1] - repe cmps byte [esi],[edi] - pop edi esi - je preevaluated_true - preevaluated_false: - mov eax,edi - sub eax,ebp - test eax,1 - jnz store_true - store_false: - mov edi,ebp - mov al,'0' - ret - preevaluated_true: - mov eax,edi - sub eax,ebp - test eax,1 - jnz store_false - store_true: - mov edi,ebp - mov al,'1' - ret - compare_symbol_types: - push esi - lea esi,[edx+1] - type_comparison: - cmp esi,[esp] - je types_compared - mov al,[esi] - cmp al,[ebx] - jne different_type - cmp al,'(' - jne equal_type - mov al,[esi+1] - mov ah,[ebx+1] - cmp al,ah - je equal_type - or al,al - jz different_type - or ah,ah - jz different_type - cmp al,'.' - je different_type - cmp ah,'.' - je different_type - equal_type: - call skip_symbol - xchg esi,ebx - call skip_symbol - xchg esi,ebx - jmp type_comparison - types_compared: - pop esi - cmp byte [ebx],0F7h - jne preevaluated_false - jmp preevaluated_true - different_type: - pop esi - jmp preevaluated_false - scan_symbols_list: - push edi esi - lea esi,[edx+1] - sub edx,ebx - lods byte [esi] - cmp al,'<' - jne invalid_symbols_list - get_next_from_list: - mov edi,esi - get_from_list: - cmp byte [esi],',' - je compare_in_list - cmp byte [esi],'>' - je compare_in_list - cmp esi,[esp] - jae invalid_symbols_list - call skip_symbol - jmp get_from_list - compare_in_list: - mov ecx,esi - sub ecx,edi - cmp ecx,edx - jne not_equal_length_in_list - mov esi,ebx - repe cmps byte [esi],[edi] - mov esi,edi - jne not_equal_in_list - skip_rest_of_list: - cmp byte [esi],'>' - je check_list_end - cmp esi,[esp] - jae invalid_symbols_list - call skip_symbol - jmp skip_rest_of_list - check_list_end: - inc esi - cmp esi,[esp] - jne invalid_symbols_list - pop esi edi - jmp preevaluated_true - not_equal_in_list: - add esi,ecx - not_equal_length_in_list: - lods byte [esi] - cmp al,',' - je get_next_from_list - cmp esi,[esp] - jne invalid_symbols_list - pop esi edi - jmp preevaluated_false - invalid_symbols_list: - pop esi edi - jmp invalid_logical_value - -calculate_logical_expression: - xor al,al - calculate_embedded_logical_expression: - mov [logical_value_wrapping],al - call get_logical_value - logical_loop: - cmp byte [esi],'|' - je logical_or - cmp byte [esi],'&' - je logical_and - ret - logical_or: - inc esi - or al,al - jnz logical_value_already_determined - push eax - call get_logical_value - pop ebx - or al,bl - jmp logical_loop - logical_and: - inc esi - or al,al - jz logical_value_already_determined - push eax - call get_logical_value - pop ebx - and al,bl - jmp logical_loop - logical_value_already_determined: - push eax - call skip_logical_value - jc invalid_expression - pop eax - jmp logical_loop - get_logical_value: - xor al,al - check_for_negation: - cmp byte [esi],'~' - jne negation_ok - inc esi - xor al,-1 - jmp check_for_negation - negation_ok: - push eax - mov al,[esi] - cmp al,'{' - je logical_expression - cmp al,0FFh - je invalid_expression - cmp al,88h - je check_for_defined - cmp al,89h - je check_for_used - cmp al,'0' - je given_false - cmp al,'1' - je given_true - call get_value - mov bl,[value_type] - push eax edx ebx - mov al,[esi] - or al,al - jz logical_number - cmp al,0Fh - je logical_number - cmp al,'}' - je logical_number - cmp al,'&' - je logical_number - cmp al,'|' - je logical_number - inc esi - mov [compare_type],al - call get_value - pop ebx - cmp [next_pass_needed],0 - jne values_ok - cmp bl,[value_type] - jne invalid_use_of_symbol - values_ok: - pop ecx ebx - cmp [compare_type],'=' - je check_equal - cmp [compare_type],'>' - je check_greater - cmp [compare_type],'<' - je check_less - cmp [compare_type],0F1h - je check_not_equal - cmp [compare_type],0F2h - je check_not_less - cmp [compare_type],0F3h - je check_not_greater - jmp invalid_expression - check_equal: - cmp eax,ebx - jne return_false - cmp edx,ecx - jne return_false - jmp return_true - check_greater: - cmp edx,ecx - jl return_true - jg return_false - cmp eax,ebx - jb return_true - jae return_false - check_less: - cmp edx,ecx - jl return_false - jg return_true - cmp eax,ebx - jbe return_false - ja return_true - check_not_less: - cmp edx,ecx - jl return_true - jg return_false - cmp eax,ebx - jbe return_true - ja return_false - check_not_greater: - cmp edx,ecx - jl return_false - jg return_true - cmp eax,ebx - jb return_false - jae return_true - check_not_equal: - cmp eax,ebx - jne return_true - cmp edx,ecx - jne return_true - jmp return_false - logical_number: - pop ebx edx eax - or bl,bl - jnz invalid_expression - or eax,edx - jnz return_true - jmp return_false - check_for_defined: - or bl,-1 - lods word [esi] - cmp ah,'(' - jne invalid_expression - check_expression: - lods byte [esi] - or al,al - jz defined_string - cmp al,'.' - je defined_fp_value - cmp al,')' - je expression_checked - cmp al,'!' - je invalid_expression - cmp al,0Fh - je check_expression - cmp al,10h - je defined_register - cmp al,11h - je check_if_symbol_defined - cmp al,80h - jae check_expression - movzx eax,al - add esi,eax - jmp check_expression - defined_register: - inc esi - jmp check_expression - defined_fp_value: - add esi,12 - jmp expression_checked - defined_string: - lods dword [esi] - add esi,eax - inc esi - jmp expression_checked - check_if_symbol_defined: - lods dword [esi] - cmp eax,-1 - je invalid_expression - cmp eax,0Fh - jb check_expression - je reserved_word_used_as_symbol - test byte [eax+8],4 - jnz no_prediction - test byte [eax+8],1 - jz symbol_predicted_undefined - mov cx,[current_pass] - sub cx,[eax+16] - jz check_expression - cmp cx,1 - ja symbol_predicted_undefined - or byte [eax+8],40h+80h - jmp check_expression - no_prediction: - test byte [eax+8],1 - jz symbol_undefined - mov cx,[current_pass] - sub cx,[eax+16] - jz check_expression - jmp symbol_undefined - symbol_predicted_undefined: - or byte [eax+8],40h - and byte [eax+8],not 80h - symbol_undefined: - xor bl,bl - jmp check_expression - expression_checked: - mov al,bl - jmp logical_value_ok - check_for_used: - lods word [esi] - cmp ah,2 - jne invalid_expression - lods dword [esi] - cmp eax,0Fh - jb invalid_use_of_symbol - je reserved_word_used_as_symbol - inc esi - test byte [eax+8],8 - jz not_used - mov cx,[current_pass] - sub cx,[eax+18] - jz return_true - cmp cx,1 - ja not_used - or byte [eax+8],10h+20h - jmp return_true - not_used: - or byte [eax+8],10h - and byte [eax+8],not 20h - jmp return_false - given_false: - inc esi - return_false: - xor al,al - jmp logical_value_ok - given_true: - inc esi - return_true: - or al,-1 - jmp logical_value_ok - logical_expression: - lods byte [esi] - mov dl,[logical_value_wrapping] - push edx - call calculate_embedded_logical_expression - pop edx - mov [logical_value_wrapping],dl - push eax - lods byte [esi] - cmp al,'}' - jne invalid_expression - pop eax - logical_value_ok: - pop ebx - xor al,bl - ret + +; flat assembler core +; Copyright (c) 1999-2011, Tomasz Grysztar. +; All rights reserved. + +calculate_expression: + mov [current_offset],edi + mov [value_undefined],0 + cmp byte [esi],0 + je get_string_value + cmp byte [esi],'.' + je convert_fp + calculation_loop: + lods byte [esi] + cmp al,1 + je get_byte_number + cmp al,2 + je get_word_number + cmp al,4 + je get_dword_number + cmp al,8 + je get_qword_number + cmp al,0Fh + je value_out_of_range + cmp al,10h + je get_register + cmp al,11h + je get_label + cmp al,')' + je expression_calculated + cmp al,']' + je expression_calculated + cmp al,'!' + je invalid_expression + sub edi,14h + mov ebx,edi + sub ebx,14h + cmp al,0E0h + je calculate_rva + cmp al,0E1h + je calculate_plt + cmp al,0D0h + je calculate_not + cmp al,083h + je calculate_neg + mov dx,[ebx+8] + or dx,[edi+8] + cmp al,80h + je calculate_add + cmp al,81h + je calculate_sub + mov ah,[ebx+12] + or ah,[edi+12] + jz absolute_values_calculation + cmp [error_line],0 + jne absolute_values_calculation + mov eax,[current_line] + mov [error_line],eax + mov [error],invalid_use_of_symbol + absolute_values_calculation: + cmp al,90h + je calculate_mul + cmp al,91h + je calculate_div + or dx,dx + jnz invalid_expression + cmp al,0A0h + je calculate_mod + cmp al,0B0h + je calculate_and + cmp al,0B1h + je calculate_or + cmp al,0B2h + je calculate_xor + cmp al,0C0h + je calculate_shl + cmp al,0C1h + je calculate_shr + jmp invalid_expression + expression_calculated: + sub edi,14h + cmp [value_undefined],0 + je expression_value_ok + xor eax,eax + mov [edi],eax + mov [edi+4],eax + mov [edi+12],al + expression_value_ok: + ret + get_byte_number: + xor eax,eax + lods byte [esi] + stos dword [edi] + xor al,al + stos dword [edi] + got_number: + mov word [edi-8+8],0 + mov byte [edi-8+12],0 + mov dword [edi-8+16],0 + add edi,0Ch + jmp calculation_loop + get_word_number: + xor eax,eax + lods word [esi] + stos dword [edi] + xor ax,ax + stos dword [edi] + jmp got_number + get_dword_number: + movs dword [edi],[esi] + xor eax,eax + stos dword [edi] + jmp got_number + get_qword_number: + movs dword [edi],[esi] + movs dword [edi],[esi] + jmp got_number + get_register: + mov byte [edi+9],0 + mov byte [edi+12],0 + lods byte [esi] + mov [edi+8],al + mov byte [edi+10],1 + xor eax,eax + mov [edi+16],eax + stos dword [edi] + stos dword [edi] + add edi,0Ch + jmp calculation_loop + get_label: + xor eax,eax + mov [edi+8],eax + mov [edi+12],al + mov [edi+20],eax + lods dword [esi] + cmp eax,0Fh + jb predefined_label + je reserved_word_used_as_symbol + mov ebx,eax + mov ax,[current_pass] + mov [ebx+18],ax + or byte [ebx+8],8 + test byte [ebx+8],1 + jz label_undefined + cmp ax,[ebx+16] + je label_defined + test byte [ebx+8],4 + jnz label_out_of_scope + test byte [ebx+9],1 + jz label_defined + mov eax,[ebx] + sub eax,dword [adjustment] + stos dword [edi] + mov eax,[ebx+4] + sbb eax,dword [adjustment+4] + stos dword [edi] + mov eax,dword [adjustment] + or eax,dword [adjustment+4] + jz got_label + or [next_pass_needed],-1 + jmp got_label + label_defined: + mov eax,[ebx] + stos dword [edi] + mov eax,[ebx+4] + stos dword [edi] + got_label: + mov al,[ebx+11] + mov [edi-8+12],al + mov eax,[ebx+12] + mov [edi-8+8],eax + mov eax,[ebx+20] + mov [edi-8+16],eax + add edi,0Ch + mov al,[ebx+10] + or al,al + jz calculation_loop + cmp [size_override],-1 + je calculation_loop + cmp [size_override],0 + je check_size + cmp [operand_size],0 + jne calculation_loop + mov [operand_size],al + jmp calculation_loop + check_size: + xchg [operand_size],al + or al,al + jz calculation_loop + cmp al,[operand_size] + jne operand_sizes_do_not_match + jmp calculation_loop + current_offset_label: + mov eax,[current_offset] + make_current_offset_label: + xor edx,edx + sub eax,dword [org_origin] + sbb edx,dword [org_origin+4] + stos dword [edi] + mov eax,edx + stos dword [edi] + mov eax,[org_registers] + stos dword [edi] + mov al,[labels_type] + mov [edi-12+12],al + mov eax,[org_symbol] + mov [edi-12+16],eax + add edi,8 + jmp calculation_loop + org_origin_label: + mov eax,[org_start] + jmp make_current_offset_label + counter_label: + mov eax,[counter] + make_dword_label_value: + stos dword [edi] + xor eax,eax + stos dword [edi] + add edi,0Ch + jmp calculation_loop + timestamp_label: + call make_timestamp + make_qword_label_value: + stos dword [edi] + mov eax,edx + stos dword [edi] + add edi,0Ch + jmp calculation_loop + predefined_label: + or eax,eax + jz current_offset_label + cmp eax,1 + je counter_label + cmp eax,2 + je timestamp_label + cmp eax,3 + je org_origin_label + mov edx,invalid_value + jmp error_undefined + label_out_of_scope: + mov edx,symbol_out_of_scope + cmp [error_line],0 + jne error_undefined + mov [error_info],ebx + jmp error_undefined + label_undefined: + mov edx,undefined_symbol + cmp [error_line],0 + jne error_undefined + mov [error_info],ebx + error_undefined: + cmp [current_pass],1 + ja undefined_value + force_next_pass: + or [next_pass_needed],-1 + undefined_value: + mov byte [edi+12],0 + or [value_undefined],-1 + xor eax,eax + stos dword [edi] + stos dword [edi] + add edi,0Ch + cmp [error_line],0 + jne calculation_loop + mov eax,[current_line] + mov [error_line],eax + mov [error],edx + jmp calculation_loop + calculate_add: + mov ecx,[ebx+16] + cmp byte [edi+12],0 + je add_values + mov ecx,[edi+16] + cmp byte [ebx+12],0 + je add_values + cmp [error_line],0 + jne add_values + mov eax,[current_line] + mov [error_line],eax + mov [error],invalid_use_of_symbol + add_values: + mov al,[edi+12] + or [ebx+12],al + mov [ebx+16],ecx + mov eax,[edi] + add [ebx],eax + mov eax,[edi+4] + adc [ebx+4],eax + or dx,dx + jz calculation_loop + push esi + mov esi,ebx + lea ebx,[edi+10] + mov cl,[edi+8] + call add_register + lea ebx,[edi+11] + mov cl,[edi+9] + call add_register + pop esi + jmp calculation_loop + add_register: + or cl,cl + jz add_register_done + add_register_start: + cmp [esi+8],cl + jne add_in_second_slot + mov al,[ebx] + add [esi+10],al + jnz add_register_done + mov byte [esi+8],0 + ret + add_in_second_slot: + cmp [esi+9],cl + jne create_in_first_slot + mov al,[ebx] + add [esi+11],al + jnz add_register_done + mov byte [esi+9],0 + ret + create_in_first_slot: + cmp byte [esi+8],0 + jne create_in_second_slot + mov [esi+8],cl + mov al,[ebx] + mov [esi+10],al + ret + create_in_second_slot: + cmp byte [esi+9],0 + jne invalid_expression + mov [esi+9],cl + mov al,[ebx] + mov [esi+11],al + add_register_done: + ret + calculate_sub: + xor ah,ah + mov ah,[ebx+12] + mov al,[edi+12] + or al,al + jz sub_values + cmp al,ah + jne invalid_sub + xor ah,ah + mov ecx,[edi+16] + cmp ecx,[ebx+16] + jne invalid_sub + sub_values: + mov [ebx+12],ah + mov eax,[edi] + sub [ebx],eax + mov eax,[edi+4] + sbb [ebx+4],eax + or dx,dx + jz calculation_loop + push esi + mov esi,ebx + lea ebx,[edi+10] + mov cl,[edi+8] + call sub_register + lea ebx,[edi+11] + mov cl,[edi+9] + call sub_register + pop esi + jmp calculation_loop + invalid_sub: + cmp [error_line],0 + jne sub_values + mov eax,[current_line] + mov [error_line],eax + mov [error],invalid_use_of_symbol + jmp sub_values + sub_register: + or cl,cl + jz add_register_done + neg byte [ebx] + jmp add_register_start + calculate_mul: + or dx,dx + jz mul_start + cmp word [ebx+8],0 + jne mul_start + mov eax,[ebx] + xchg eax,[edi] + mov [ebx],eax + mov eax,[ebx+4] + xchg eax,[edi+4] + mov [ebx+4],eax + mov eax,[ebx+8] + xchg eax,[edi+8] + mov [ebx+8],eax + mov eax,[ebx+12] + xchg eax,[edi+12] + mov [ebx+12],eax + mul_start: + push esi edx + mov esi,ebx + xor bl,bl + bt dword [esi+4],31 + jnc mul_first_sign_ok + not dword [esi] + not dword [esi+4] + add dword [esi],1 + adc dword [esi+4],0 + not bl + mul_first_sign_ok: + bt dword [edi+4],31 + jnc mul_second_sign_ok + not dword [edi] + not dword [edi+4] + add dword [edi],1 + adc dword [edi+4],0 + not bl + mul_second_sign_ok: + cmp dword [esi+4],0 + jz mul_numbers + cmp dword [edi+4],0 + jnz value_out_of_range + mul_numbers: + mov eax,[esi+4] + mul dword [edi] + or edx,edx + jnz value_out_of_range + mov ecx,eax + mov eax,[esi] + mul dword [edi+4] + or edx,edx + jnz value_out_of_range + add ecx,eax + jc value_out_of_range + mov eax,[esi] + mul dword [edi] + add edx,ecx + jc value_out_of_range + test edx,1 shl 31 + jnz value_out_of_range + mov [esi],eax + mov [esi+4],edx + or bl,bl + jz mul_ok + not dword [esi] + not dword [esi+4] + add dword [esi],1 + adc dword [esi+4],0 + mul_ok: + pop edx + or dx,dx + jz mul_calculated + cmp word [edi+8],0 + jne invalid_value + cmp byte [esi+8],0 + je mul_first_register_ok + mov al,[edi] + cbw + cwde + cdq + cmp edx,[edi+4] + jne value_out_of_range + cmp eax,[edi] + jne value_out_of_range + imul byte [esi+10] + mov dl,ah + cbw + cmp ah,dl + jne value_out_of_range + mov [esi+10],al + or al,al + jnz mul_first_register_ok + mov [esi+8],al + mul_first_register_ok: + cmp byte [esi+9],0 + je mul_calculated + mov al,[edi] + cbw + cwde + cdq + cmp edx,[edi+4] + jne value_out_of_range + cmp eax,[edi] + jne value_out_of_range + imul byte [esi+11] + mov dl,ah + cbw + cmp ah,dl + jne value_out_of_range + mov [esi+11],al + or al,al + jnz mul_calculated + mov [esi+9],al + mul_calculated: + pop esi + jmp calculation_loop + calculate_div: + push esi edx + mov esi,ebx + call div_64 + pop edx + or dx,dx + jz div_calculated + cmp byte [esi+8],0 + je div_first_register_ok + mov al,[edi] + cbw + cwde + cdq + cmp edx,[edi+4] + jne value_out_of_range + cmp eax,[edi] + jne value_out_of_range + or al,al + jz value_out_of_range + mov al,[esi+10] + cbw + idiv byte [edi] + or ah,ah + jnz invalid_use_of_symbol + mov [esi+10],al + div_first_register_ok: + cmp byte [esi+9],0 + je div_calculated + mov al,[edi] + cbw + cwde + cdq + cmp edx,[edi+4] + jne value_out_of_range + cmp eax,[edi] + jne value_out_of_range + or al,al + jz value_out_of_range + mov al,[esi+11] + cbw + idiv byte [edi] + or ah,ah + jnz invalid_use_of_symbol + mov [esi+11],al + div_calculated: + pop esi + jmp calculation_loop + calculate_mod: + push esi + mov esi,ebx + call div_64 + mov [esi],eax + mov [esi+4],edx + pop esi + jmp calculation_loop + calculate_and: + mov eax,[edi] + and [ebx],eax + mov eax,[edi+4] + and [ebx+4],eax + jmp calculation_loop + calculate_or: + mov eax,[edi] + or [ebx],eax + mov eax,[edi+4] + or [ebx+4],eax + jmp calculation_loop + calculate_xor: + mov eax,[edi] + xor [ebx],eax + mov edx,[edi+4] + xor [ebx+4],edx + cmp [value_size],1 + je xor_byte + cmp [value_size],2 + je xor_word + cmp [value_size],4 + je xor_dword + cmp [value_size],6 + je xor_pword + xor_calculated: + jmp calculation_loop + prepare_xor_check: + cmp edx,-1 + je xor_check_ready + xor edx,[ebx+4] + xor eax,[ebx] + cmp edx,-1 + xor_check_ready: + ret + xor_byte: + call prepare_xor_check + jne xor_calculated + xor edx,[ebx+4] + jnz xor_calculated + cmp eax,0FFFFFF80h + jb xor_calculated + xor eax,[ebx] + cmp eax,0FFh + ja xor_calculated + mov [ebx+4],edx + and dword [ebx],0FFh + jmp xor_calculated + xor_word: + call prepare_xor_check + jne xor_calculated + xor edx,[ebx+4] + jnz xor_calculated + cmp eax,0FFFF8000h + jb xor_calculated + xor eax,[ebx] + cmp eax,0FFFFh + ja xor_calculated + mov [ebx+4],edx + and dword [ebx],0FFFFh + jmp xor_calculated + xor_dword: + call prepare_xor_check + jne xor_calculated + xor edx,[ebx+4] + jnz xor_calculated + cmp eax,80000000h + jb xor_calculated + mov [ebx+4],edx + jmp xor_calculated + xor_pword: + cmp edx,0FFFF8000h + jae xor_pword_check + xor edx,[ebx+4] + xor eax,[ebx] + cmp edx,0FFFF8000h + jb xor_calculated + xor_pword_check: + xor edx,[ebx+4] + cmp edx,0FFFFh + ja xor_calculated + and dword [ebx+4],0FFFFh + jmp xor_calculated + shr_negative: + not dword [edi] + not dword [edi+4] + add dword [edi],1 + adc dword [edi+4],0 + calculate_shl: + mov eax,dword [edi+4] + bt eax,31 + jc shl_negative + or eax,eax + jnz zero_value + mov ecx,[edi] + cmp ecx,64 + jae zero_value + mov edx,[ebx+4] + mov eax,[ebx] + cmp ecx,32 + jae shl_high + shld edx,eax,cl + shl eax,cl + mov [ebx],eax + mov [ebx+4],edx + jmp calculation_loop + shl_high: + sub cl,32 + shl eax,cl + mov [ebx+4],eax + mov dword [ebx],0 + jmp calculation_loop + shl_negative: + not dword [edi] + not dword [edi+4] + add dword [edi],1 + adc dword [edi+4],0 + calculate_shr: + mov eax,dword [edi+4] + bt eax,31 + jc shr_negative + or eax,eax + jnz zero_value + mov ecx,[edi] + cmp ecx,64 + jae zero_value + mov edx,[ebx+4] + mov eax,[ebx] + cmp ecx,32 + jae shr_high + cmp [value_size],1 + je shr_byte + cmp [value_size],2 + je shr_word + cmp [value_size],4 + je shr_dword + cmp [value_size],6 + je shr_pword + shr_regular: + shrd eax,edx,cl + shr edx,cl + mov [ebx],eax + mov [ebx+4],edx + jmp calculation_loop + shr_byte: + cmp edx,-1 + jne shr_regular + cmp eax,0FFFFFF80h + jb shr_regular + and eax,0FFh + xor edx,edx + jmp shr_regular + shr_word: + cmp edx,-1 + jne shr_regular + cmp eax,0FFFF8000h + jb shr_regular + and eax,0FFFFh + xor edx,edx + jmp shr_regular + shr_dword: + cmp edx,-1 + jne shr_regular + cmp eax,80000000h + jb shr_regular + xor edx,edx + jmp shr_regular + shr_pword: + cmp edx,0FFFF8000h + jb shr_regular + and edx,0FFFFh + jmp shr_regular + shr_high: + sub cl,32 + cmp [value_size],1 + je shr_byte_32plus + cmp [value_size],2 + je shr_word_32plus + cmp [value_size],4 + je shr_dword_32plus + cmp [value_size],6 + je shr_pword_32plus + shr_32plus: + shr edx,cl + mov [ebx],edx + mov dword [ebx+4],0 + jmp calculation_loop + shr_byte_32plus: + cmp edx,-1 + jne shr_32plus + cmp eax,-80h + jb shr_32plus + jmp zero_value + shr_word_32plus: + cmp edx,-1 + jne shr_32plus + cmp eax,-8000h + jb shr_32plus + jmp zero_value + shr_dword_32plus: + cmp edx,-1 + jne shr_32plus + cmp eax,-80000000h + jb shr_32plus + jmp zero_value + shr_pword_32plus: + cmp edx,-8000h + jb shr_32plus + and edx,0FFFFh + jmp shr_32plus + zero_value: + mov dword [ebx],0 + mov dword [ebx+4],0 + jmp calculation_loop + calculate_not: + cmp word [edi+8],0 + jne invalid_expression + cmp byte [edi+12],0 + je not_ok + cmp [error_line],0 + jne not_ok + mov eax,[current_line] + mov [error_line],eax + mov [error],invalid_use_of_symbol + not_ok: + cmp [value_size],1 + je not_byte + cmp [value_size],2 + je not_word + cmp [value_size],4 + je not_dword + cmp [value_size],6 + je not_pword + not_qword: + not dword [edi] + not dword [edi+4] + add edi,14h + jmp calculation_loop + not_byte: + cmp dword [edi+4],0 + jne not_qword + cmp word [edi+2],0 + jne not_qword + cmp byte [edi+1],0 + jne not_qword + not byte [edi] + add edi,14h + jmp calculation_loop + not_word: + cmp dword [edi+4],0 + jne not_qword + cmp word [edi+2],0 + jne not_qword + not word [edi] + add edi,14h + jmp calculation_loop + not_dword: + cmp dword [edi+4],0 + jne not_qword + not dword [edi] + add edi,14h + jmp calculation_loop + not_pword: + cmp word [edi+6],0 + jne not_qword + not dword [edi] + not word [edi+4] + add edi,14h + jmp calculation_loop + calculate_neg: + cmp word [edi+8],0 + jne invalid_expression + cmp byte [edi+12],0 + je neg_ok + cmp [error_line],0 + jne neg_ok + mov eax,[current_line] + mov [error_line],eax + mov [error],invalid_use_of_symbol + neg_ok: + mov eax,[edi] + mov edx,[edi+4] + mov dword [edi],0 + mov dword [edi+4],0 + sub [edi],eax + sbb [edi+4],edx + add edi,14h + jmp calculation_loop + calculate_rva: + cmp word [edi+8],0 + jne invalid_expression + cmp [output_format],5 + je calculate_gotoff + cmp [output_format],4 + je calculate_coff_rva + cmp [output_format],3 + jne invalid_expression + test [format_flags],8 + jnz pe64_rva + mov al,2 + bt [resolver_flags],0 + jc rva_type_ok + xor al,al + rva_type_ok: + cmp byte [edi+12],al + je rva_ok + cmp [error_line],0 + jne rva_ok + mov eax,[current_line] + mov [error_line],eax + mov [error],invalid_use_of_symbol + rva_ok: + mov byte [edi+12],0 + mov eax,[code_start] + mov eax,[eax+34h] + cdq + sub [edi],eax + sbb [edi+4],edx + add edi,14h + jmp calculation_loop + pe64_rva: + mov al,4 + bt [resolver_flags],0 + jc pe64_rva_type_ok + xor al,al + pe64_rva_type_ok: + cmp byte [edi+12],al + je pe64_rva_ok + cmp [error_line],0 + jne pe64_rva_ok + mov eax,[current_line] + mov [error_line],eax + mov [error],invalid_use_of_symbol + pe64_rva_ok: + mov byte [edi+12],0 + mov eax,[code_start] + mov edx,[eax+34h] + mov eax,[eax+30h] + sub [edi],eax + sbb [edi+4],edx + add edi,14h + jmp calculation_loop + calculate_gotoff: + test [format_flags],8+1 + jnz invalid_expression + calculate_coff_rva: + mov dl,5 + cmp byte [edi+12],2 + je change_value_type + incorrect_change_of_value_type: + cmp [error_line],0 + jne change_value_type + mov eax,[current_line] + mov [error_line],eax + mov [error],invalid_use_of_symbol + change_value_type: + mov byte [edi+12],dl + add edi,14h + jmp calculation_loop + calculate_plt: + cmp word [edi+8],0 + jne invalid_expression + cmp [output_format],5 + jne invalid_expression + test [format_flags],1 + jnz invalid_expression + mov dl,6 + mov dh,2 + test [format_flags],8 + jz check_value_for_plt + mov dh,4 + check_value_for_plt: + mov eax,[edi] + or eax,[edi+4] + jnz incorrect_change_of_value_type + cmp byte [edi+12],dh + jne incorrect_change_of_value_type + mov eax,[edi+16] + cmp byte [eax],80h + jne incorrect_change_of_value_type + jmp change_value_type + div_64: + xor ebx,ebx + cmp dword [edi],0 + jne divider_ok + cmp dword [edi+4],0 + jne divider_ok + cmp [next_pass_needed],0 + je value_out_of_range + jmp div_done + divider_ok: + bt dword [esi+4],31 + jnc div_first_sign_ok + not dword [esi] + not dword [esi+4] + add dword [esi],1 + adc dword [esi+4],0 + not bx + div_first_sign_ok: + bt dword [edi+4],31 + jnc div_second_sign_ok + not dword [edi] + not dword [edi+4] + add dword [edi],1 + adc dword [edi+4],0 + not bl + div_second_sign_ok: + cmp dword [edi+4],0 + jne div_high + mov ecx,[edi] + mov eax,[esi+4] + xor edx,edx + div ecx + mov [esi+4],eax + mov eax,[esi] + div ecx + mov [esi],eax + mov eax,edx + xor edx,edx + jmp div_done + div_high: + mov eax,[esi+4] + xor edx,edx + div dword [edi+4] + mov ebx,[esi] + mov [esi],eax + mov dword [esi+4],0 + mov ecx,edx + mul dword [edi] + div_high_loop: + cmp ecx,edx + ja div_high_done + jb div_high_large_correction + cmp ebx,eax + jae div_high_done + div_high_correction: + dec dword [esi] + sub eax,[edi] + sbb edx,[edi+4] + jnc div_high_loop + div_high_done: + sub ebx,eax + sbb ecx,edx + mov edx,ecx + mov eax,ebx + ret + div_high_large_correction: + push eax edx + mov eax,edx + sub eax,ecx + xor edx,edx + div dword [edi+4] + shr eax,1 + jz div_high_small_correction + sub [esi],eax + push eax + mul dword [edi+4] + sub dword [esp+4],eax + pop eax + mul dword [edi] + sub dword [esp+4],eax + sbb dword [esp],edx + pop edx eax + jmp div_high_loop + div_high_small_correction: + pop edx eax + jmp div_high_correction + div_done: + or bh,bh + jz remainder_ok + not eax + not edx + add eax,1 + adc edx,0 + remainder_ok: + or bl,bl + jz div_ok + not dword [esi] + not dword [esi+4] + add dword [esi],1 + adc dword [esi+4],0 + div_ok: + ret + convert_fp: + inc esi + mov word [edi+8],0 + mov byte [edi+12],0 + mov al,[value_size] + cmp al,2 + je convert_fp_word + cmp al,4 + je convert_fp_dword + cmp al,8 + je convert_fp_qword + jmp invalid_value + convert_fp_word: + xor eax,eax + cmp word [esi+8],8000h + je fp_word_store + mov bx,[esi+8] + mov ax,[esi+6] + shl ax,1 + shr ax,6 + jnc fp_word_ok + inc ax + bt ax,10 + jnc fp_word_ok + and ax,1 shl 10 - 1 + inc bx + shr ax,1 + fp_word_ok: + add bx,0Fh + cmp bx,01Fh + jge value_out_of_range + cmp bx,0 + jg fp_word_exp_ok + or ax,1 shl 10 + mov cx,bx + neg cx + inc cx + cmp cx,10 + ja value_out_of_range + xor bx,bx + shr ax,cl + jnc fp_word_exp_ok + inc ax + test ax,1 shl 10 + jz fp_word_exp_ok + and ax,1 shl 10 - 1 + inc bx + fp_word_exp_ok: + shl bx,10 + or ax,bx + fp_word_store: + mov bl,[esi+11] + shl bx,15 + or ax,bx + mov [edi],eax + xor eax,eax + mov [edi+4],eax + add esi,13 + ret + convert_fp_dword: + xor eax,eax + cmp word [esi+8],8000h + je fp_dword_store + mov bx,[esi+8] + mov eax,[esi+4] + shl eax,1 + shr eax,9 + jnc fp_dword_ok + inc eax + bt eax,23 + jnc fp_dword_ok + and eax,1 shl 23 - 1 + inc bx + shr eax,1 + fp_dword_ok: + add bx,7Fh + cmp bx,0FFh + jge value_out_of_range + cmp bx,0 + jg fp_dword_exp_ok + or eax,1 shl 23 + mov cx,bx + neg cx + inc cx + cmp cx,23 + ja value_out_of_range + xor bx,bx + shr eax,cl + jnc fp_dword_exp_ok + inc eax + test eax,1 shl 23 + jz fp_dword_exp_ok + and eax,1 shl 23 - 1 + inc bx + fp_dword_exp_ok: + shl ebx,23 + or eax,ebx + fp_dword_store: + mov bl,[esi+11] + shl ebx,31 + or eax,ebx + mov [edi],eax + xor eax,eax + mov [edi+4],eax + add esi,13 + ret + convert_fp_qword: + xor eax,eax + xor edx,edx + cmp word [esi+8],8000h + je fp_qword_store + mov bx,[esi+8] + mov eax,[esi] + mov edx,[esi+4] + add eax,eax + adc edx,edx + mov ecx,edx + shr edx,12 + shrd eax,ecx,12 + jnc fp_qword_ok + add eax,1 + adc edx,0 + bt edx,20 + jnc fp_qword_ok + and edx,1 shl 20 - 1 + inc bx + shr edx,1 + rcr eax,1 + fp_qword_ok: + add bx,3FFh + cmp bx,7FFh + jge value_out_of_range + cmp bx,0 + jg fp_qword_exp_ok + or edx,1 shl 20 + mov cx,bx + neg cx + inc cx + cmp cx,52 + ja value_out_of_range + cmp cx,32 + jbe fp_qword_small_shift + sub cx,32 + mov eax,edx + xor edx,edx + shr eax,cl + jmp fp_qword_shift_done + fp_qword_small_shift: + mov ebx,edx + shr edx,cl + shrd eax,ebx,cl + fp_qword_shift_done: + mov bx,0 + jnc fp_qword_exp_ok + add eax,1 + adc edx,0 + test edx,1 shl 20 + jz fp_qword_exp_ok + and edx,1 shl 20 - 1 + inc bx + fp_qword_exp_ok: + shl ebx,20 + or edx,ebx + fp_qword_store: + mov bl,[esi+11] + shl ebx,31 + or edx,ebx + mov [edi],eax + mov [edi+4],edx + add esi,13 + ret + get_string_value: + inc esi + lods dword [esi] + mov ecx,eax + cmp ecx,8 + ja value_out_of_range + mov edx,edi + xor eax,eax + stos dword [edi] + stos dword [edi] + mov edi,edx + rep movs byte [edi],[esi] + mov edi,edx + inc esi + mov word [edi+8],0 + mov byte [edi+12],0 + ret + +get_byte_value: + mov [value_size],1 + mov [size_override],-1 + call calculate_expression + mov eax,[edi+16] + mov [symbol_identifier],eax + mov [value_type],0 + cmp word [edi+8],0 + jne invalid_value + cmp byte [edi+12],0 + je check_byte_value + cmp [error_line],0 + jne check_byte_value + mov eax,[current_line] + mov [error_line],eax + mov [error],invalid_use_of_symbol + check_byte_value: + mov eax,[edi] + mov edx,[edi+4] + or edx,edx + jz byte_positive + cmp edx,-1 + jne range_exceeded + cmp eax,-80h + jb range_exceeded + ret + byte_positive: + cmp eax,100h + jae range_exceeded + return_byte_value: + ret + range_exceeded: + xor eax,eax + xor edx,edx + cmp [error_line],0 + jne return_byte_value + mov ecx,[current_line] + mov [error_line],ecx + mov [error],value_out_of_range + ret +get_word_value: + mov [value_size],2 + mov [size_override],-1 + call calculate_expression + cmp word [edi+8],0 + jne invalid_value + mov eax,[edi+16] + mov [symbol_identifier],eax + mov al,[edi+12] + mov [value_type],al + cmp al,2 + jb check_word_value + cmp [error_line],0 + jne check_word_value + mov eax,[current_line] + mov [error_line],eax + mov [error],invalid_use_of_symbol + check_word_value: + mov eax,[edi] + mov edx,[edi+4] + or edx,edx + jz word_positive + cmp edx,-1 + jne range_exceeded + cmp eax,-8000h + jb range_exceeded + ret + word_positive: + cmp eax,10000h + jae range_exceeded + ret +get_dword_value: + mov [value_size],4 + mov [size_override],-1 + call calculate_expression + cmp word [edi+8],0 + jne invalid_value + mov eax,[edi+16] + mov [symbol_identifier],eax + mov al,[edi+12] + mov [value_type],al + cmp al,4 + jne check_dword_value + mov [value_type],2 + mov eax,[edi] + cdq + cmp edx,[edi+4] + jne range_exceeded + ret + check_dword_value: + mov eax,[edi] + mov edx,[edi+4] + or edx,edx + jz dword_positive + cmp edx,-1 + jne range_exceeded + bt eax,31 + jnc range_exceeded + dword_positive: + ret +get_pword_value: + mov [value_size],6 + mov [size_override],-1 + call calculate_expression + mov eax,[edi+16] + mov [symbol_identifier],eax + cmp word [edi+8],0 + jne invalid_value + mov al,[edi+12] + mov [value_type],al + cmp al,4 + jne check_pword_value + cmp [error_line],0 + jne check_pword_value + mov eax,[current_line] + mov [error_line],eax + mov [error],invalid_use_of_symbol + check_pword_value: + mov eax,[edi] + mov edx,[edi+4] + cmp edx,10000h + jge range_exceeded + cmp edx,-8000h + jl range_exceeded + ret +get_qword_value: + mov [value_size],8 + mov [size_override],-1 + call calculate_expression + cmp word [edi+8],0 + jne invalid_value + mov eax,[edi+16] + mov [symbol_identifier],eax + mov al,[edi+12] + mov [value_type],al + check_qword_value: + mov eax,[edi] + mov edx,[edi+4] + ret +get_count_value: + mov [value_size],8 + mov [size_override],-1 + call calculate_expression + cmp word [edi+8],0 + jne invalid_value + mov al,[edi+12] + or al,al + jz check_count_value + cmp [error_line],0 + jne check_count_value + mov eax,[current_line] + mov [error_line],eax + mov [error],invalid_use_of_symbol + check_count_value: + mov eax,[edi] + mov edx,[edi+4] + or edx,edx + jnz invalid_count_value + ret + invalid_count_value: + cmp [error_line],0 + jne zero_count + mov eax,[current_line] + mov [error_line],eax + mov [error],invalid_value + zero_count: + xor eax,eax + ret +get_value: + mov [operand_size],0 + lods byte [esi] + call get_size_operator + cmp al,'(' + jne invalid_value + mov al,[operand_size] + cmp al,1 + je value_byte + cmp al,2 + je value_word + cmp al,4 + je value_dword + cmp al,6 + je value_pword + cmp al,8 + je value_qword + or al,al + jnz invalid_value + value_qword: + call get_qword_value + ret + value_pword: + call get_pword_value + movzx edx,dx + ret + value_dword: + call get_dword_value + xor edx,edx + ret + value_word: + call get_word_value + xor edx,edx + movzx eax,ax + ret + value_byte: + call get_byte_value + xor edx,edx + movzx eax,al + ret +get_address_word_value: + mov [address_size],2 + mov [value_size],2 + jmp calculate_address +get_address_dword_value: + mov [address_size],4 + mov [value_size],4 + jmp calculate_address +get_address_qword_value: + mov [address_size],8 + mov [value_size],8 + jmp calculate_address +get_address_value: + mov [address_size],0 + mov [value_size],8 + calculate_address: + cmp byte [esi],'.' + je invalid_address + call calculate_expression + mov eax,[edi+16] + mov [address_symbol],eax + mov al,[edi+12] + mov [value_type],al + cmp al,6 + je special_address_type_32bit + cmp al,5 + je special_address_type_32bit + ja invalid_use_of_symbol + test al,1 + jnz invalid_use_of_symbol + or al,al + jz address_size_ok + shl al,5 + jmp address_symbol_ok + special_address_type_32bit: + mov al,40h + address_symbol_ok: + mov ah,[address_size] + or [address_size],al + shr al,4 + or ah,ah + jz address_size_ok + cmp al,ah + je address_size_ok + cmp ax,0804h + jne address_sizes_do_not_agree + cmp [value_type],2 + ja value_type_correction_ok + mov [value_type],2 + value_type_correction_ok: + mov eax,[edi] + cdq + cmp edx,[edi+4] + je address_size_ok + cmp [error_line],0 + jne address_size_ok + mov ecx,[current_line] + mov [error_line],ecx + mov [error],value_out_of_range + address_size_ok: + xor ebx,ebx + xor ecx,ecx + mov cl,[value_type] + shl ecx,16 + mov ch,[address_size] + cmp word [edi+8],0 + je check_immediate_address + mov al,[edi+8] + mov dl,[edi+10] + call get_address_register + mov al,[edi+9] + mov dl,[edi+11] + call get_address_register + mov ax,bx + shr ah,4 + shr al,4 + or bh,bh + jz check_address_registers + or bl,bl + jz check_address_registers + cmp al,ah + jne invalid_address + check_address_registers: + or al,ah + mov ah,[address_size] + and ah,0Fh + jz address_registers_sizes_ok + cmp al,ah + jne address_sizes_do_not_match + address_registers_sizes_ok: + cmp al,4 + je sib_allowed + cmp al,8 + je sib_allowed + cmp al,0Fh + je check_ip_relative_address + or cl,cl + jz check_word_value + cmp cl,1 + je check_word_value + jmp invalid_address + address_sizes_do_not_match: + cmp al,0Fh + jne invalid_address + mov al,bh + and al,0Fh + cmp al,ah + jne invalid_address + check_ip_relative_address: + cmp bh,0F4h + je check_dword_value + cmp bh,0F8h + jne invalid_address + mov eax,[edi] + cdq + cmp edx,[edi+4] + jne range_exceeded + ret + get_address_register: + or al,al + jz address_register_ok + cmp dl,1 + jne scaled_register + or bh,bh + jnz scaled_register + mov bh,al + address_register_ok: + ret + scaled_register: + or bl,bl + jnz invalid_address + mov bl,al + mov cl,dl + jmp address_register_ok + sib_allowed: + or bh,bh + jnz check_index_with_base + cmp cl,3 + je special_index_scale + cmp cl,5 + je special_index_scale + cmp cl,9 + je special_index_scale + cmp cl,2 + jne check_index_scale + cmp bl,45h + jne special_index_scale + cmp [code_type],64 + je special_index_scale + cmp [segment_register],4 + jne special_index_scale + cmp [value_type],0 + jne check_index_scale + mov al,[edi] + cbw + cwde + cmp eax,[edi] + jne check_index_scale + cdq + cmp edx,[edi+4] + jne check_immediate_address + special_index_scale: + mov bh,bl + dec cl + check_immediate_address: + mov al,[address_size] + and al,0Fh + cmp al,2 + je check_word_value + cmp al,4 + je check_dword_value + cmp al,8 + je check_qword_value + or al,al + jnz invalid_value + cmp [code_type],64 + jne check_dword_value + jmp check_qword_value + check_index_with_base: + cmp cl,1 + jne check_index_scale + cmp bl,44h + je swap_base_with_index + cmp bl,84h + je swap_base_with_index + cmp [code_type],64 + je check_for_rbp_base + cmp bl,45h + jne check_for_ebp_base + cmp [segment_register],3 + je swap_base_with_index + jmp check_immediate_address + check_for_ebp_base: + cmp bh,45h + jne check_immediate_address + cmp [segment_register],4 + jne check_immediate_address + swap_base_with_index: + xchg bl,bh + jmp check_immediate_address + check_for_rbp_base: + cmp bh,45h + je swap_base_with_index + cmp bh,85h + je swap_base_with_index + jmp check_immediate_address + check_index_scale: + test cl,not 1111b + jnz invalid_address + mov al,cl + dec al + and al,cl + jz check_immediate_address + jmp invalid_address +calculate_relative_offset: + cmp [value_undefined],0 + jne relative_offset_ok + test bh,bh + setne ch + cmp bx,word [org_registers] + je origin_registers_ok + xchg bh,bl + xchg ch,cl + cmp bx,word [org_registers] + jne invalid_value + origin_registers_ok: + cmp cx,word [org_registers+2] + jne invalid_value + add eax,dword [org_origin] + adc edx,dword [org_origin+4] + sub eax,edi + sbb edx,0 + mov bl,[value_type] + or bl,bl + je relative_offset_ok + test bl,1 + jnz invalid_use_of_symbol + mov ecx,[address_symbol] + mov [symbol_identifier],ecx + cmp bl,6 + je plt_relative_offset + cmp bl,[labels_type] + jne invalid_use_of_symbol + mov [value_type],0 + cmp ecx,[org_symbol] + je relative_offset_ok + mov [value_type],3 + relative_offset_ok: + ret + plt_relative_offset: + mov [value_type],7 + ret + +calculate_logical_expression: + xor al,al + calculate_embedded_logical_expression: + mov [logical_value_wrapping],al + call get_logical_value + logical_loop: + cmp byte [esi],'|' + je logical_or + cmp byte [esi],'&' + je logical_and + ret + logical_or: + inc esi + or al,al + jnz logical_value_already_determined + push eax + call get_logical_value + pop ebx + or al,bl + jmp logical_loop + logical_and: + inc esi + or al,al + jz logical_value_already_determined + push eax + call get_logical_value + pop ebx + and al,bl + jmp logical_loop + logical_value_already_determined: + push eax + call skip_logical_value + jc invalid_expression + pop eax + jmp logical_loop + get_logical_value: + xor al,al + check_for_negation: + cmp byte [esi],'~' + jne negation_ok + inc esi + xor al,-1 + jmp check_for_negation + negation_ok: + push eax + mov al,[esi] + cmp al,'{' + je logical_expression + cmp al,0FFh + je invalid_expression + cmp al,88h + je check_for_defined + cmp al,89h + je check_for_used + cmp al,'0' + je given_false + cmp al,'1' + je given_true + call get_value + mov bl,[value_type] + push eax edx ebx + mov al,[esi] + or al,al + jz logical_number + cmp al,0Fh + je logical_number + cmp al,'}' + je logical_number + cmp al,'&' + je logical_number + cmp al,'|' + je logical_number + inc esi + mov [compare_type],al + call get_value + pop ebx + cmp [next_pass_needed],0 + jne values_ok + cmp bl,[value_type] + jne invalid_use_of_symbol + values_ok: + pop ecx ebx + cmp [compare_type],'=' + je check_equal + cmp [compare_type],'>' + je check_greater + cmp [compare_type],'<' + je check_less + cmp [compare_type],0F1h + je check_not_equal + cmp [compare_type],0F2h + je check_not_less + cmp [compare_type],0F3h + je check_not_greater + jmp invalid_expression + check_equal: + cmp eax,ebx + jne return_false + cmp edx,ecx + jne return_false + jmp return_true + check_greater: + cmp edx,ecx + jl return_true + jg return_false + cmp eax,ebx + jb return_true + jae return_false + check_less: + cmp edx,ecx + jl return_false + jg return_true + cmp eax,ebx + jbe return_false + ja return_true + check_not_less: + cmp edx,ecx + jl return_true + jg return_false + cmp eax,ebx + jbe return_true + ja return_false + check_not_greater: + cmp edx,ecx + jl return_false + jg return_true + cmp eax,ebx + jb return_false + jae return_true + check_not_equal: + cmp eax,ebx + jne return_true + cmp edx,ecx + jne return_true + jmp return_false + logical_number: + pop ebx edx eax + or bl,bl + jnz invalid_expression + or eax,edx + jnz return_true + jmp return_false + check_for_defined: + or bl,-1 + lods word [esi] + cmp ah,'(' + jne invalid_expression + check_expression: + lods byte [esi] + or al,al + jz defined_string + cmp al,'.' + je defined_fp_value + cmp al,')' + je expression_checked + cmp al,'!' + je invalid_expression + cmp al,0Fh + je check_expression + cmp al,10h + je defined_register + cmp al,11h + je check_if_symbol_defined + cmp al,80h + jae check_expression + movzx eax,al + add esi,eax + jmp check_expression + defined_register: + inc esi + jmp check_expression + defined_fp_value: + add esi,12 + jmp expression_checked + defined_string: + lods dword [esi] + add esi,eax + inc esi + jmp expression_checked + check_if_symbol_defined: + lods dword [esi] + cmp eax,-1 + je invalid_expression + cmp eax,0Fh + jb check_expression + je reserved_word_used_as_symbol + test byte [eax+8],4 + jnz no_prediction + test byte [eax+8],1 + jz symbol_predicted_undefined + mov cx,[current_pass] + sub cx,[eax+16] + jz check_expression + cmp cx,1 + ja symbol_predicted_undefined + or byte [eax+8],40h+80h + jmp check_expression + no_prediction: + test byte [eax+8],1 + jz symbol_undefined + mov cx,[current_pass] + sub cx,[eax+16] + jz check_expression + jmp symbol_undefined + symbol_predicted_undefined: + or byte [eax+8],40h + and byte [eax+8],not 80h + symbol_undefined: + xor bl,bl + jmp check_expression + expression_checked: + mov al,bl + jmp logical_value_ok + check_for_used: + lods word [esi] + cmp ah,2 + jne invalid_expression + lods dword [esi] + cmp eax,0Fh + jb invalid_use_of_symbol + je reserved_word_used_as_symbol + inc esi + test byte [eax+8],8 + jz not_used + mov cx,[current_pass] + sub cx,[eax+18] + jz return_true + cmp cx,1 + ja not_used + or byte [eax+8],10h+20h + jmp return_true + not_used: + or byte [eax+8],10h + and byte [eax+8],not 20h + jmp return_false + given_false: + inc esi + return_false: + xor al,al + jmp logical_value_ok + given_true: + inc esi + return_true: + or al,-1 + jmp logical_value_ok + logical_expression: + lods byte [esi] + mov dl,[logical_value_wrapping] + push edx + call calculate_embedded_logical_expression + pop edx + mov [logical_value_wrapping],dl + push eax + lods byte [esi] + cmp al,'}' + jne invalid_expression + pop eax + logical_value_ok: + pop ebx + xor al,bl + ret + +skip_symbol: + lods byte [esi] + or al,al + jz nothing_to_skip + cmp al,0Fh + je nothing_to_skip + cmp al,1 + je skip_instruction + cmp al,2 + je skip_label + cmp al,3 + je skip_label + cmp al,20h + jb skip_assembler_symbol + cmp al,'(' + je skip_expression + cmp al,'[' + je skip_address + skip_done: + clc + ret + skip_label: + add esi,2 + skip_instruction: + add esi,2 + skip_assembler_symbol: + inc esi + jmp skip_done + skip_address: + mov al,[esi] + and al,11110000b + cmp al,60h + jb skip_expression + cmp al,70h + ja skip_expression + inc esi + jmp skip_address + skip_expression: + lods byte [esi] + or al,al + jz skip_string + cmp al,'.' + je skip_fp_value + cmp al,')' + je skip_done + cmp al,']' + je skip_done + cmp al,'!' + je skip_expression + cmp al,0Fh + je skip_expression + cmp al,10h + je skip_register + cmp al,11h + je skip_label_value + cmp al,80h + jae skip_expression + movzx eax,al + add esi,eax + jmp skip_expression + skip_label_value: + add esi,3 + skip_register: + inc esi + jmp skip_expression + skip_fp_value: + add esi,12 + jmp skip_done + skip_string: + lods dword [esi] + add esi,eax + inc esi + jmp skip_done + nothing_to_skip: + dec esi + stc + ret diff --git a/programs/develop/fasm/trunk/exprpars.inc b/programs/develop/fasm/trunk/exprpars.inc new file mode 100644 index 000000000..e3c0c03e1 --- /dev/null +++ b/programs/develop/fasm/trunk/exprpars.inc @@ -0,0 +1,1232 @@ + +; flat assembler core +; Copyright (c) 1999-2011, Tomasz Grysztar. +; All rights reserved. + +convert_expression: + push ebp + call get_fp_value + jnc fp_expression + mov [current_offset],esp + expression_loop: + push edi + mov edi,single_operand_operators + call get_operator + pop edi + or al,al + jz expression_element + push eax + jmp expression_loop + expression_element: + mov al,[esi] + cmp al,1Ah + je expression_number + cmp al,22h + je expression_number + cmp al,'(' + je expression_number + mov al,'!' + stos byte [edi] + jmp expression_operator + expression_number: + call convert_number + expression_operator: + push edi + mov edi,operators + call get_operator + pop edi + or al,al + jz expression_end + operators_loop: + cmp esp,[current_offset] + je push_operator + mov bl,al + and bl,0F0h + mov bh,byte [esp] + and bh,0F0h + cmp bl,bh + ja push_operator + pop ebx + mov byte [edi],bl + inc edi + jmp operators_loop + push_operator: + push eax + jmp expression_loop + expression_end: + cmp esp,[current_offset] + je expression_converted + pop eax + stos byte [edi] + jmp expression_end + expression_converted: + pop ebp + ret + fp_expression: + mov al,'.' + stos byte [edi] + mov eax,[fp_value] + stos dword [edi] + mov eax,[fp_value+4] + stos dword [edi] + mov eax,[fp_value+8] + stos dword [edi] + pop ebp + ret + +convert_number: + lea eax,[edi-10h] + mov edx,[memory_end] + cmp [source_start],0 + je check_memory_for_number + mov edx,[labels_list] + check_memory_for_number: + cmp eax,edx + jae out_of_memory + mov eax,esp + sub eax,100h + jc stack_overflow + cmp eax,[stack_limit] + jb stack_overflow + cmp byte [esi],'(' + je expression_value + inc edi + call get_number + jc symbol_value + or ebp,ebp + jz valid_number + mov byte [edi-1],0Fh + ret + valid_number: + cmp dword [edi+4],0 + jne qword_number + cmp word [edi+2],0 + jne dword_number + cmp byte [edi+1],0 + jne word_number + byte_number: + mov byte [edi-1],1 + inc edi + ret + qword_number: + mov byte [edi-1],8 + add edi,8 + ret + dword_number: + mov byte [edi-1],4 + scas dword [edi] + ret + word_number: + mov byte [edi-1],2 + scas word [edi] + ret + expression_value: + inc esi + push [current_offset] + call convert_expression + pop [current_offset] + lods byte [esi] + cmp al,')' + jne invalid_expression + ret + symbol_value: + cmp [source_start],0 + je preprocessor_value + push edi + mov edi,address_registers + call get_operator + or al,al + jnz register_value + mov edi,directive_operators + call get_operator + pop edi + or al,al + jnz broken_value + lods byte [esi] + cmp al,1Ah + jne invalid_value + lods byte [esi] + movzx ecx,al + call get_label_id + store_label_value: + mov byte [edi-1],11h + stos dword [edi] + ret + broken_value: + mov eax,0Fh + jmp store_label_value + register_value: + pop edi + mov byte [edi-1],10h + stos byte [edi] + ret + preprocessor_value: + dec edi + cmp [hash_tree],0 + je invalid_value + lods byte [esi] + cmp al,1Ah + jne invalid_value + lods byte [esi] + mov cl,al + mov ch,10b + call get_preprocessor_symbol + jc invalid_value + push esi + mov esi,[edx+8] + push [current_offset] + call convert_expression + pop [current_offset] + pop esi + ret + +get_number: + xor ebp,ebp + lods byte [esi] + cmp al,22h + je get_text_number + cmp al,1Ah + jne not_number + lods byte [esi] + movzx ecx,al + mov [number_start],esi + mov al,[esi] + cmp al,'$' + je number_begin + sub al,30h + cmp al,9 + ja invalid_number + number_begin: + mov ebx,esi + add esi,ecx + push esi + dec esi + mov dword [edi],0 + mov dword [edi+4],0 + cmp byte [ebx],'$' + je pascal_hex_number + cmp word [ebx],'0x' + je get_hex_number + mov al,[esi] + dec esi + cmp al,'h' + je get_hex_number + cmp al,'b' + je get_bin_number + cmp al,'d' + je get_dec_number + cmp al,'o' + je get_oct_number + cmp al,'H' + je get_hex_number + cmp al,'B' + je get_bin_number + cmp al,'D' + je get_dec_number + cmp al,'O' + je get_oct_number + inc esi + get_dec_number: + mov ebx,esi + mov esi,[number_start] + get_dec_digit: + cmp esi,ebx + ja number_ok + cmp byte [esi],27h + je next_dec_digit + xor edx,edx + mov eax,[edi] + shld edx,eax,2 + shl eax,2 + add eax,[edi] + adc edx,0 + add eax,eax + adc edx,edx + mov [edi],eax + mov eax,[edi+4] + add eax,eax + jc dec_out_of_range + add eax,eax + jc dec_out_of_range + add eax,[edi+4] + jc dec_out_of_range + add eax,eax + jc dec_out_of_range + add eax,edx + jc dec_out_of_range + mov [edi+4],eax + movzx eax,byte [esi] + sub al,30h + jc bad_number + cmp al,9 + ja bad_number + add [edi],eax + adc dword [edi+4],0 + jc dec_out_of_range + next_dec_digit: + inc esi + jmp get_dec_digit + dec_out_of_range: + cmp esi,ebx + ja dec_out_of_range_finished + lods byte [esi] + cmp al,27h + je bad_number + sub al,30h + jc bad_number + cmp al,9 + ja bad_number + jmp dec_out_of_range + dec_out_of_range_finished: + or ebp,-1 + jmp number_ok + bad_number: + pop eax + invalid_number: + mov esi,[number_start] + dec esi + not_number: + dec esi + stc + ret + get_bin_number: + xor bl,bl + get_bin_digit: + cmp esi,[number_start] + jb number_ok + movzx eax,byte [esi] + cmp al,27h + je bin_digit_skip + sub al,30h + cmp al,1 + ja bad_number + xor edx,edx + mov cl,bl + dec esi + cmp bl,64 + je bin_out_of_range + inc bl + cmp cl,32 + jae bin_digit_high + shl eax,cl + or dword [edi],eax + jmp get_bin_digit + bin_digit_high: + sub cl,32 + shl eax,cl + or dword [edi+4],eax + jmp get_bin_digit + bin_out_of_range: + or al,al + jz get_bin_digit + or ebp,-1 + jmp get_bin_digit + bin_digit_skip: + dec esi + jmp get_bin_digit + pascal_hex_number: + cmp cl,1 + je bad_number + get_hex_number: + xor bl,bl + get_hex_digit: + cmp esi,[number_start] + jb number_ok + movzx eax,byte [esi] + cmp al,27h + je hex_digit_skip + cmp al,'x' + je hex_number_ok + cmp al,'$' + je pascal_hex_ok + sub al,30h + cmp al,9 + jbe hex_digit_ok + sub al,7 + cmp al,15 + jbe hex_letter_digit_ok + sub al,20h + cmp al,15 + ja bad_number + hex_letter_digit_ok: + cmp al,10 + jb bad_number + hex_digit_ok: + xor edx,edx + mov cl,bl + dec esi + cmp bl,64 + je hex_out_of_range + add bl,4 + cmp cl,32 + jae hex_digit_high + shl eax,cl + or dword [edi],eax + jmp get_hex_digit + hex_digit_high: + sub cl,32 + shl eax,cl + or dword [edi+4],eax + jmp get_hex_digit + hex_out_of_range: + or al,al + jz get_hex_digit + or ebp,-1 + jmp get_hex_digit + hex_digit_skip: + dec esi + jmp get_hex_digit + get_oct_number: + xor bl,bl + get_oct_digit: + cmp esi,[number_start] + jb number_ok + movzx eax,byte [esi] + cmp al,27h + je oct_digit_skip + sub al,30h + cmp al,7 + ja bad_number + oct_digit_ok: + xor edx,edx + mov cl,bl + dec esi + cmp bl,64 + jae oct_out_of_range + add bl,3 + cmp cl,30 + je oct_digit_wrap + ja oct_digit_high + shl eax,cl + or dword [edi],eax + jmp get_oct_digit + oct_digit_wrap: + shl eax,cl + adc dword [edi+4],0 + or dword [edi],eax + jmp get_oct_digit + oct_digit_high: + sub cl,32 + shl eax,cl + or dword [edi+4],eax + jmp get_oct_digit + oct_digit_skip: + dec esi + jmp get_oct_digit + oct_out_of_range: + or al,al + jz get_oct_digit + or ebp,-1 + jmp get_oct_digit + hex_number_ok: + dec esi + pascal_hex_ok: + cmp esi,[number_start] + jne bad_number + number_ok: + pop esi + number_done: + clc + ret + get_text_number: + lods dword [esi] + mov edx,eax + xor bl,bl + mov dword [edi],0 + mov dword [edi+4],0 + get_text_character: + sub edx,1 + jc number_done + movzx eax,byte [esi] + inc esi + mov cl,bl + cmp bl,64 + je text_out_of_range + add bl,8 + cmp cl,32 + jae text_character_high + shl eax,cl + or dword [edi],eax + jmp get_text_character + text_character_high: + sub cl,32 + shl eax,cl + or dword [edi+4],eax + jmp get_text_character + text_out_of_range: + or ebp,-1 + jmp get_text_character + +get_fp_value: + push edi esi + lods byte [esi] + cmp al,1Ah + je fp_value_start + cmp al,'-' + je fp_sign_ok + cmp al,'+' + jne not_fp_value + fp_sign_ok: + lods byte [esi] + cmp al,1Ah + jne not_fp_value + fp_value_start: + lods byte [esi] + movzx ecx,al + cmp cl,1 + jbe not_fp_value + lea edx,[esi+1] + xor ah,ah + check_fp_value: + lods byte [esi] + cmp al,'.' + je fp_character_dot + cmp al,'E' + je fp_character_exp + cmp al,'e' + je fp_character_exp + cmp al,'F' + je fp_last_character + cmp al,'f' + je fp_last_character + digit_expected: + cmp al,'0' + jb not_fp_value + cmp al,'9' + ja not_fp_value + jmp fp_character_ok + fp_character_dot: + cmp esi,edx + je not_fp_value + or ah,ah + jnz not_fp_value + or ah,1 + lods byte [esi] + loop digit_expected + not_fp_value: + pop esi edi + stc + ret + fp_last_character: + cmp cl,1 + jne not_fp_value + or ah,4 + jmp fp_character_ok + fp_character_exp: + cmp esi,edx + je not_fp_value + cmp ah,1 + ja not_fp_value + or ah,2 + cmp ecx,1 + jne fp_character_ok + cmp byte [esi],'+' + je fp_exp_sign + cmp byte [esi],'-' + jne fp_character_ok + fp_exp_sign: + inc esi + cmp byte [esi],1Ah + jne not_fp_value + inc esi + lods byte [esi] + movzx ecx,al + inc ecx + fp_character_ok: + dec ecx + jnz check_fp_value + or ah,ah + jz not_fp_value + pop esi + lods byte [esi] + mov [fp_sign],0 + cmp al,1Ah + je fp_get + inc esi + cmp al,'+' + je fp_get + mov [fp_sign],1 + fp_get: + lods byte [esi] + movzx ecx,al + xor edx,edx + mov edi,fp_value + mov [edi],edx + mov [edi+4],edx + mov [edi+12],edx + call fp_optimize + mov [fp_format],0 + mov al,[esi] + fp_before_dot: + lods byte [esi] + cmp al,'.' + je fp_dot + cmp al,'E' + je fp_exponent + cmp al,'e' + je fp_exponent + cmp al,'F' + je fp_done + cmp al,'f' + je fp_done + sub al,30h + mov edi,fp_value+16 + xor edx,edx + mov dword [edi+12],edx + mov dword [edi],edx + mov dword [edi+4],edx + mov [edi+7],al + mov dl,7 + mov dword [edi+8],edx + call fp_optimize + mov edi,fp_value + push ecx + mov ecx,10 + call fp_mul + pop ecx + mov ebx,fp_value+16 + call fp_add + loop fp_before_dot + fp_dot: + mov edi,fp_value+16 + xor edx,edx + mov [edi],edx + mov [edi+4],edx + mov byte [edi+7],80h + mov [edi+8],edx + mov dword [edi+12],edx + dec ecx + jz fp_done + fp_after_dot: + lods byte [esi] + cmp al,'E' + je fp_exponent + cmp al,'e' + je fp_exponent + cmp al,'F' + je fp_done + cmp al,'f' + je fp_done + inc [fp_format] + cmp [fp_format],80h + jne fp_counter_ok + mov [fp_format],7Fh + fp_counter_ok: + dec esi + mov edi,fp_value+16 + push ecx + mov ecx,10 + call fp_div + push dword [edi] + push dword [edi+4] + push dword [edi+8] + push dword [edi+12] + lods byte [esi] + sub al,30h + movzx ecx,al + call fp_mul + mov ebx,edi + mov edi,fp_value + call fp_add + mov edi,fp_value+16 + pop dword [edi+12] + pop dword [edi+8] + pop dword [edi+4] + pop dword [edi] + pop ecx + dec ecx + jnz fp_after_dot + jmp fp_done + fp_exponent: + or [fp_format],80h + xor edx,edx + xor ebp,ebp + dec ecx + jnz get_exponent + cmp byte [esi],'+' + je fp_exponent_sign + cmp byte [esi],'-' + jne fp_done + not ebp + fp_exponent_sign: + add esi,2 + lods byte [esi] + movzx ecx,al + get_exponent: + movzx eax,byte [esi] + inc esi + sub al,30h + cmp al,10 + jae exponent_ok + imul edx,10 + cmp edx,8000h + jae value_out_of_range + add edx,eax + loop get_exponent + exponent_ok: + mov edi,fp_value + or edx,edx + jz fp_done + mov ecx,edx + or ebp,ebp + jnz fp_negative_power + fp_power: + push ecx + mov ecx,10 + call fp_mul + pop ecx + loop fp_power + jmp fp_done + fp_negative_power: + push ecx + mov ecx,10 + call fp_div + pop ecx + loop fp_negative_power + fp_done: + mov edi,fp_value + mov al,[fp_format] + mov [edi+10],al + mov al,[fp_sign] + mov [edi+11],al + test byte [edi+15],80h + jz fp_ok + add dword [edi],1 + adc dword [edi+4],0 + jnc fp_ok + mov eax,[edi+4] + shrd [edi],eax,1 + shr eax,1 + or eax,80000000h + mov [edi+4],eax + inc word [edi+8] + fp_ok: + pop edi + clc + ret + fp_mul: + or ecx,ecx + jz fp_zero + mov eax,[edi+12] + mul ecx + mov [edi+12],eax + mov ebx,edx + mov eax,[edi] + mul ecx + add eax,ebx + adc edx,0 + mov [edi],eax + mov ebx,edx + mov eax,[edi+4] + mul ecx + add eax,ebx + adc edx,0 + mov [edi+4],eax + .loop: + or edx,edx + jz .done + mov eax,[edi] + shrd [edi+12],eax,1 + mov eax,[edi+4] + shrd [edi],eax,1 + shrd eax,edx,1 + mov [edi+4],eax + shr edx,1 + inc dword [edi+8] + cmp dword [edi+8],8000h + jge value_out_of_range + jmp .loop + .done: + ret + fp_div: + mov eax,[edi+4] + xor edx,edx + div ecx + mov [edi+4],eax + mov eax,[edi] + div ecx + mov [edi],eax + mov eax,[edi+12] + div ecx + mov [edi+12],eax + mov ebx,eax + or ebx,[edi] + or ebx,[edi+4] + jz fp_zero + .loop: + test byte [edi+7],80h + jnz .exp_ok + mov eax,[edi] + shld [edi+4],eax,1 + mov eax,[edi+12] + shld [edi],eax,1 + add eax,eax + mov [edi+12],eax + dec dword [edi+8] + add edx,edx + jmp .loop + .exp_ok: + mov eax,edx + xor edx,edx + div ecx + add [edi+12],eax + adc dword [edi],0 + adc dword [edi+4],0 + jnc .done + mov eax,[edi+4] + mov ebx,[edi] + shrd [edi],eax,1 + shrd [edi+12],ebx,1 + shr eax,1 + or eax,80000000h + mov [edi+4],eax + inc dword [edi+8] + .done: + ret + fp_add: + cmp dword [ebx+8],8000h + je .done + cmp dword [edi+8],8000h + je .copy + mov eax,[ebx+8] + cmp eax,[edi+8] + jge .exp_ok + mov eax,[edi+8] + .exp_ok: + call .change_exp + xchg ebx,edi + call .change_exp + xchg ebx,edi + mov edx,[ebx+12] + mov eax,[ebx] + mov ebx,[ebx+4] + add [edi+12],edx + adc [edi],eax + adc [edi+4],ebx + jnc .done + mov eax,[edi] + shrd [edi+12],eax,1 + mov eax,[edi+4] + shrd [edi],eax,1 + shr eax,1 + or eax,80000000h + mov [edi+4],eax + inc dword [edi+8] + .done: + ret + .copy: + mov eax,[ebx] + mov [edi],eax + mov eax,[ebx+4] + mov [edi+4],eax + mov eax,[ebx+8] + mov [edi+8],eax + mov eax,[ebx+12] + mov [edi+12],eax + ret + .change_exp: + push ecx + mov ecx,eax + sub ecx,[ebx+8] + mov edx,[ebx+4] + jecxz .exp_done + .exp_loop: + mov ebp,[ebx] + shrd [ebx+12],ebp,1 + shrd [ebx],edx,1 + shr edx,1 + inc dword [ebx+8] + loop .exp_loop + .exp_done: + mov [ebx+4],edx + pop ecx + ret + fp_optimize: + mov eax,[edi] + mov ebp,[edi+4] + or ebp,[edi] + or ebp,[edi+12] + jz fp_zero + .loop: + test byte [edi+7],80h + jnz .done + shld [edi+4],eax,1 + mov ebp,[edi+12] + shld eax,ebp,1 + mov [edi],eax + shl dword [edi+12],1 + dec dword [edi+8] + jmp .loop + .done: + ret + fp_zero: + mov dword [edi+8],8000h + ret + +preevaluate_logical_expression: + xor al,al + preevaluate_embedded_logical_expression: + mov [logical_value_wrapping],al + push edi + call preevaluate_logical_value + preevaluation_loop: + cmp al,0FFh + je invalid_logical_expression + mov dl,[esi] + inc esi + cmp dl,'|' + je preevaluate_or + cmp dl,'&' + je preevaluate_and + cmp dl,'}' + je preevaluation_done + or dl,dl + jnz invalid_logical_expression + preevaluation_done: + pop edx + dec esi + ret + preevaluate_or: + cmp al,'1' + je quick_true + cmp al,'0' + je leave_only_following + push edi + mov al,dl + stos byte [edi] + call preevaluate_logical_value + pop ebx + cmp al,'0' + je leave_only_preceding + cmp al,'1' + jne preevaluation_loop + stos byte [edi] + xor al,al + jmp preevaluation_loop + preevaluate_and: + cmp al,'0' + je quick_false + cmp al,'1' + je leave_only_following + push edi + mov al,dl + stos byte [edi] + call preevaluate_logical_value + pop ebx + cmp al,'1' + je leave_only_preceding + cmp al,'0' + jne preevaluation_loop + stos byte [edi] + xor al,al + jmp preevaluation_loop + leave_only_following: + mov edi,[esp] + call preevaluate_logical_value + jmp preevaluation_loop + leave_only_preceding: + mov edi,ebx + xor al,al + jmp preevaluation_loop + quick_true: + call skip_logical_value + jc invalid_logical_expression + mov edi,[esp] + mov al,'1' + jmp preevaluation_loop + quick_false: + call skip_logical_value + jc invalid_logical_expression + mov edi,[esp] + mov al,'0' + jmp preevaluation_loop + invalid_logical_expression: + pop edi + mov esi,edi + mov al,0FFh + stos byte [edi] + ret + skip_logical_value: + cmp byte [esi],'~' + jne negation_skipped + inc esi + jmp skip_logical_value + negation_skipped: + mov al,[esi] + cmp al,'{' + jne skip_simple_logical_value + inc esi + xchg al,[logical_value_wrapping] + push eax + skip_logical_expression: + call skip_logical_value + lods byte [esi] + or al,al + jz wrongly_structured_logical_expression + cmp al,0Fh + je wrongly_structured_logical_expression + cmp al,'|' + je skip_logical_expression + cmp al,'&' + je skip_logical_expression + cmp al,'}' + jne wrongly_structured_logical_expression + pop eax + mov [logical_value_wrapping],al + logical_value_skipped: + clc + ret + wrongly_structured_logical_expression: + pop eax + stc + ret + skip_simple_logical_value: + mov [logical_value_parentheses],0 + find_simple_logical_value_end: + mov al,[esi] + or al,al + jz logical_value_skipped + cmp al,0Fh + je logical_value_skipped + cmp al,'|' + je logical_value_skipped + cmp al,'&' + je logical_value_skipped + cmp al,'{' + je skip_logical_value_internal_parenthesis + cmp al,'}' + jne skip_logical_value_symbol + sub [logical_value_parentheses],1 + jnc skip_logical_value_symbol + cmp [logical_value_wrapping],'{' + jne skip_logical_value_symbol + jmp logical_value_skipped + skip_logical_value_internal_parenthesis: + inc [logical_value_parentheses] + skip_logical_value_symbol: + call skip_symbol + jmp find_simple_logical_value_end + preevaluate_logical_value: + mov ebp,edi + preevaluate_negation: + cmp byte [esi],'~' + jne preevaluate_negation_ok + movs byte [edi],[esi] + jmp preevaluate_negation + preevaluate_negation_ok: + mov ebx,esi + cmp byte [esi],'{' + jne preevaluate_simple_logical_value + lods byte [esi] + stos byte [edi] + push ebp + mov dl,[logical_value_wrapping] + push edx + call preevaluate_embedded_logical_expression + pop edx + mov [logical_value_wrapping],dl + pop ebp + cmp al,0FFh + je invalid_logical_value + cmp byte [esi],'}' + jne invalid_logical_value + or al,al + jnz preevaluated_expression_value + movs byte [edi],[esi] + ret + preevaluated_expression_value: + inc esi + lea edx,[edi-1] + sub edx,ebp + test edx,1 + jz expression_negation_ok + xor al,1 + expression_negation_ok: + mov edi,ebp + ret + invalid_logical_value: + mov edi,ebp + mov al,0FFh + ret + preevaluate_simple_logical_value: + xor edx,edx + mov [logical_value_parentheses],edx + find_logical_value_boundaries: + mov al,[esi] + or al,al + jz logical_value_boundaries_found + cmp al,'{' + je logical_value_internal_parentheses + cmp al,'}' + je logical_value_boundaries_parenthesis_close + cmp al,'|' + je logical_value_boundaries_found + cmp al,'&' + je logical_value_boundaries_found + or edx,edx + jnz next_symbol_in_logical_value + cmp al,0F0h + je preevaluable_logical_operator + cmp al,0F7h + je preevaluable_logical_operator + cmp al,0F6h + jne next_symbol_in_logical_value + preevaluable_logical_operator: + mov edx,esi + next_symbol_in_logical_value: + call skip_symbol + jmp find_logical_value_boundaries + logical_value_internal_parentheses: + inc [logical_value_parentheses] + jmp next_symbol_in_logical_value + logical_value_boundaries_parenthesis_close: + sub [logical_value_parentheses],1 + jnc next_symbol_in_logical_value + cmp [logical_value_wrapping],'{' + jne next_symbol_in_logical_value + logical_value_boundaries_found: + or edx,edx + jz non_preevaluable_logical_value + mov al,[edx] + cmp al,0F0h + je compare_symbols + cmp al,0F7h + je compare_symbol_types + cmp al,0F6h + je scan_symbols_list + non_preevaluable_logical_value: + mov ecx,esi + mov esi,ebx + sub ecx,esi + jz invalid_logical_value + cmp esi,edi + je leave_logical_value_intact + rep movs byte [edi],[esi] + xor al,al + ret + leave_logical_value_intact: + add edi,ecx + add esi,ecx + xor al,al + ret + compare_symbols: + lea ecx,[esi-1] + sub ecx,edx + mov eax,edx + sub eax,ebx + cmp ecx,eax + jne preevaluated_false + push esi edi + mov esi,ebx + lea edi,[edx+1] + repe cmps byte [esi],[edi] + pop edi esi + je preevaluated_true + preevaluated_false: + mov eax,edi + sub eax,ebp + test eax,1 + jnz store_true + store_false: + mov edi,ebp + mov al,'0' + ret + preevaluated_true: + mov eax,edi + sub eax,ebp + test eax,1 + jnz store_false + store_true: + mov edi,ebp + mov al,'1' + ret + compare_symbol_types: + push esi + lea esi,[edx+1] + type_comparison: + cmp esi,[esp] + je types_compared + mov al,[esi] + cmp al,[ebx] + jne different_type + cmp al,'(' + jne equal_type + mov al,[esi+1] + mov ah,[ebx+1] + cmp al,ah + je equal_type + or al,al + jz different_type + or ah,ah + jz different_type + cmp al,'.' + je different_type + cmp ah,'.' + je different_type + equal_type: + call skip_symbol + xchg esi,ebx + call skip_symbol + xchg esi,ebx + jmp type_comparison + types_compared: + pop esi + cmp byte [ebx],0F7h + jne preevaluated_false + jmp preevaluated_true + different_type: + pop esi + jmp preevaluated_false + scan_symbols_list: + push edi esi + lea esi,[edx+1] + sub edx,ebx + lods byte [esi] + cmp al,'<' + jne invalid_symbols_list + get_next_from_list: + mov edi,esi + get_from_list: + cmp byte [esi],',' + je compare_in_list + cmp byte [esi],'>' + je compare_in_list + cmp esi,[esp] + jae invalid_symbols_list + call skip_symbol + jmp get_from_list + compare_in_list: + mov ecx,esi + sub ecx,edi + cmp ecx,edx + jne not_equal_length_in_list + mov esi,ebx + repe cmps byte [esi],[edi] + mov esi,edi + jne not_equal_in_list + skip_rest_of_list: + cmp byte [esi],'>' + je check_list_end + cmp esi,[esp] + jae invalid_symbols_list + call skip_symbol + jmp skip_rest_of_list + check_list_end: + inc esi + cmp esi,[esp] + jne invalid_symbols_list + pop esi edi + jmp preevaluated_true + not_equal_in_list: + add esi,ecx + not_equal_length_in_list: + lods byte [esi] + cmp al,',' + je get_next_from_list + cmp esi,[esp] + jne invalid_symbols_list + pop esi edi + jmp preevaluated_false + invalid_symbols_list: + pop esi edi + jmp invalid_logical_value diff --git a/programs/develop/fasm/trunk/fasm.asm b/programs/develop/fasm/trunk/fasm.asm index cee5853dd..8778c31db 100644 --- a/programs/develop/fasm/trunk/fasm.asm +++ b/programs/develop/fasm/trunk/fasm.asm @@ -622,14 +622,16 @@ display_bytes_count: include 'system.inc' include 'version.inc' include 'errors.inc' -include 'expressi.inc' +include 'symbdump.inc' include 'preproce.inc' include 'parser.inc' +include 'exprpars.inc' include 'assemble.inc' +include 'exprcalc.inc' include 'formats.inc' include 'x86_64.inc' +include 'avx.inc' include 'tables.inc' -include 'symbdump.inc' include 'messages.inc' ;--------------------------------------------------------------------- title db appname,VERSION_STRING,0 diff --git a/programs/develop/fasm/trunk/formats.inc b/programs/develop/fasm/trunk/formats.inc index 4aad3f133..bf87d2ed0 100644 --- a/programs/develop/fasm/trunk/formats.inc +++ b/programs/develop/fasm/trunk/formats.inc @@ -1,6 +1,6 @@ ; flat assembler core -; Copyright (c) 1999-2009, Tomasz Grysztar. +; Copyright (c) 1999-2011, Tomasz Grysztar. ; All rights reserved. formatter: @@ -204,7 +204,7 @@ format_directive: cmp [output_format],0 jne unexpected_instruction lods byte [esi] - cmp al,17h + cmp al,1Ch je format_prefix cmp al,18h jne invalid_argument @@ -834,11 +834,11 @@ format_pe: mov [subsystem],3 mov [subsystem_version],3 + 10 shl 16 mov [image_base],400000h + mov [image_base_high],0 test [format_flags],8 jz pe_settings mov [machine],8664h mov [subsystem_version],5 + 0 shl 16 - mov [image_base_high],0 pe_settings: cmp byte [esi],84h je get_stub_name @@ -854,6 +854,10 @@ format_pe: je dll_flag cmp al,81h je wdm_flag + cmp al,82h + je large_flag + cmp al,83h + je nx_flag jmp pe_settings dll_flag: bts [format_flags],8 @@ -863,6 +867,16 @@ format_pe: bts [format_flags],9 jc setting_already_specified jmp pe_settings + large_flag: + bts [format_flags],11 + jc setting_already_specified + test [format_flags],8 + jnz invalid_argument + jmp pe_settings + nx_flag: + bts [format_flags],12 + jc setting_already_specified + jmp pe_settings subsystem_setting: bts [format_flags],7 jc setting_already_specified @@ -870,7 +884,7 @@ format_pe: mov [subsystem],ax cmp ax,10 jb subsystem_type_ok - or [format_flags],8 + or [format_flags],4 subsystem_type_ok: cmp byte [esi],'(' jne pe_settings @@ -924,7 +938,7 @@ format_pe: je invalid_value push edx edi add edi,[stub_size] - test [format_flags],8 + test [format_flags],4 jnz get_peplus_base call get_dword_value mov [image_base],eax @@ -966,7 +980,7 @@ format_pe: pe_stub_ok: mov edx,edi mov ecx,18h+0E0h - test [format_flags],8 + test [format_flags],4 jz zero_pe_header add ecx,10h zero_pe_header: @@ -991,10 +1005,10 @@ format_pe: mov dword [edx+3Ch],eax pe_alignment_ok: mov word [edx+1Ah],VERSION_MAJOR + VERSION_MINOR shl 8 - test [format_flags],8 + test [format_flags],4 jnz init_peplus_specific mov byte [edx+14h],0E0h ; size of optional header - mov dword [edx+16h],10B010Eh; flags and magic value + mov dword [edx+16h],10B010Fh; flags and magic value mov eax,[image_base] mov [edx+34h],eax mov byte [edx+60h+1],10h ; stack reserve @@ -1004,7 +1018,7 @@ format_pe: jmp pe_header_ok init_peplus_specific: mov byte [edx+14h],0F0h ; size of optional header - mov dword [edx+16h],20B002Eh; flags and magic value + mov dword [edx+16h],20B002Fh; flags and magic value mov eax,[image_base] mov [edx+30h],eax mov eax,[image_base_high] @@ -1063,19 +1077,24 @@ format_pe: adc ecx,0 add eax,edi adc ecx,0 - test [format_flags],8 + test [format_flags],4 jnz peplus_org sub eax,[edx+34h] sbb ecx,0 - mov bl,2 - mov [code_type],32 jmp pe_org_ok peplus_org: sub eax,[edx+30h] sbb ecx,[edx+34h] + pe_org_ok: + test [format_flags],8 + jnz pe64_code + mov bl,2 + mov [code_type],32 + jmp pe_code_type_ok + pe64_code: mov bl,4 mov [code_type],64 - pe_org_ok: + pe_code_type_ok: bt [resolver_flags],0 jc pe_labels_type_ok xor bl,bl @@ -1093,6 +1112,14 @@ format_pe: jnc wdm_flag_ok or byte [edx+5Eh+1],20h wdm_flag_ok: + bt [format_flags],11 + jnc large_flag_ok + or byte [edx+16h],20h + large_flag_ok: + bt [format_flags],12 + jnc nx_ok + or byte [edx+5Eh+1],1 + nx_ok: jmp format_defined pe_section: call close_pe_section @@ -1135,12 +1162,17 @@ pe_section: xor ecx,ecx sub eax,[ebx+0Ch] sbb ecx,0 + mov [labels_type],2 + mov [code_type],32 test [format_flags],8 + jz pe_section_code_type_ok + mov [labels_type],4 + mov [code_type],64 + pe_section_code_type_ok: + test [format_flags],4 jnz peplus_section_org sub eax,[edx+34h] sbb ecx,0 - mov [labels_type],2 - mov [code_type],32 bt [resolver_flags],0 jc pe_section_org_ok mov [labels_type],0 @@ -1148,8 +1180,6 @@ pe_section: peplus_section_org: sub eax,[edx+30h] sbb ecx,[edx+34h] - mov [labels_type],4 - mov [code_type],64 bt [resolver_flags],0 jc pe_section_org_ok mov [labels_type],0 @@ -1170,7 +1200,7 @@ pe_section: movzx eax,byte [esi] inc esi mov ecx,ebx - test [format_flags],8 + test [format_flags],4 jnz peplus_directory xchg ecx,[edx+78h+eax*8] mov dword [edx+78h+eax*8+4],-1 @@ -1244,7 +1274,7 @@ pe_section: test byte [ebx+24h],40h jz pe_data_sum_ok add [edx+20h],ecx - test [format_flags],8 + test [format_flags],4 jnz pe_data_sum_ok cmp dword [edx+30h],0 jne pe_data_sum_ok @@ -1291,7 +1321,7 @@ data_directive: sub ecx,[ebx+14h] add ecx,[ebx+0Ch] mov edx,[code_start] - test [format_flags],8 + test [format_flags],4 jnz peplus_data xchg ecx,[edx+78h+eax*8] jmp init_pe_data @@ -1318,7 +1348,7 @@ data_directive: sub ecx,[edx+14h] add ecx,[edx+0Ch] mov edx,[code_start] - test [format_flags],8 + test [format_flags],4 jnz end_peplus_data sub ecx,[edx+78h+eax*8] mov [edx+78h+eax*8+4],ecx @@ -1334,7 +1364,7 @@ pe_entry: cmp byte [esi],'.' je invalid_value test [format_flags],8 - jnz peplus_entry + jnz pe64_entry call get_dword_value mov bl,2 bt [resolver_flags],0 @@ -1349,33 +1379,36 @@ pe_entry: mov [error_line],edx mov [error],invalid_address pe_entry_ok: + cdq + test [format_flags],4 + jnz pe64_entry_type_ok mov edx,[code_start] sub eax,[edx+34h] mov [edx+28h],eax jmp instruction_assembled - peplus_entry: + pe64_entry: call get_qword_value mov bl,4 bt [resolver_flags],0 - jc check_peplus_entry_label_type + jc check_pe64_entry_label_type xor bl,bl - check_peplus_entry_label_type: + check_pe64_entry_label_type: cmp [value_type],bl - je peplus_entry_type_ok + je pe64_entry_type_ok cmp [error_line],0 - jne peplus_entry_type_ok + jne pe64_entry_type_ok mov edx,[current_line] mov [error_line],edx mov [error],invalid_address - peplus_entry_type_ok: + pe64_entry_type_ok: mov ecx,[code_start] sub eax,[ecx+30h] sbb edx,[ecx+34h] - jz peplus_entry_range_ok + jz pe64_entry_range_ok mov edx,[current_line] mov [error_line],edx mov [error],value_out_of_range - peplus_entry_range_ok: + pe64_entry_range_ok: mov [ecx+28h],eax jmp instruction_assembled pe_stack: @@ -1384,11 +1417,9 @@ pe_stack: jne invalid_argument cmp byte [esi],'.' je invalid_value - test [format_flags],8 + test [format_flags],4 jnz peplus_stack - call get_dword_value - cmp [value_type],0 - jne invalid_use_of_symbol + call get_count_value mov edx,[code_start] mov [edx+60h],eax cmp byte [esi],',' @@ -1399,9 +1430,7 @@ pe_stack: jne invalid_argument cmp byte [esi],'.' je invalid_value - call get_dword_value - cmp [value_type],0 - jne invalid_use_of_symbol + call get_count_value mov edx,[code_start] mov [edx+64h],eax cmp eax,[edx+60h] @@ -1456,11 +1485,9 @@ pe_heap: jne invalid_argument cmp byte [esi],'.' je invalid_value - test [format_flags],8 + test [format_flags],4 jnz peplus_heap - call get_dword_value - cmp [value_type],0 - jne invalid_use_of_symbol + call get_count_value mov edx,[code_start] mov [edx+68h],eax cmp byte [esi],',' @@ -1471,9 +1498,7 @@ pe_heap: jne invalid_argument cmp byte [esi],'.' je invalid_value - call get_dword_value - cmp [value_type],0 - jne invalid_use_of_symbol + call get_count_value mov edx,[code_start] mov [edx+6Ch],eax cmp eax,[edx+68h] @@ -1508,11 +1533,11 @@ pe_heap: jmp instruction_assembled mark_pe_relocation: push eax ebx - test [format_flags],8 - jz check_pe32_relocation_type + test [format_flags],4 + jz check_standard_pe_relocation_type cmp [value_type],4 je pe_relocation_type_ok - check_pe32_relocation_type: + check_standard_pe_relocation_type: cmp [value_type],2 je pe_relocation_type_ok cmp [error_line],0 @@ -1527,7 +1552,6 @@ mark_pe_relocation: add eax,[ebx+0Ch] mov ebx,[free_additional_memory] inc [number_of_relocations] - jz invalid_use_of_symbol add ebx,5 cmp ebx,[structures_buffer] jae out_of_memory @@ -1549,20 +1573,36 @@ generate_pe_data: je make_pe_fixups ret make_pe_fixups: + mov edx,[code_start] + and byte [edx+16h],not 1 + or byte [edx+5Eh],40h bts [resolver_flags],0 - jc pe_relocatable_ok + jc fixups_ready or [next_pass_needed],-1 - pe_relocatable_ok: + fixups_ready: + mov [last_fixup_base],0 + call make_fixups + xchg eax,[actual_fixups_size] + sub eax,[actual_fixups_size] + ja reserve_forward_fixups + xor eax,eax + reserve_forward_fixups: + mov [reserved_fixups],edi + add edi,eax + mov [reserved_fixups_size],eax + ret + make_fixups: push esi - mov ecx,[number_of_relocations] + xor ecx,ecx + xchg ecx,[number_of_relocations] mov esi,[free_additional_memory] lea eax,[ecx*5] sub esi,eax mov [free_additional_memory],esi - or [number_of_relocations],-1 - xor edx,edx + mov edx,[last_fixup_base] mov ebp,edi - make_fixups: + jecxz fixups_done + make_fixup: cmp [esi],edx jb store_fixup mov eax,edi @@ -1582,7 +1622,6 @@ make_pe_fixups: mov eax,8 stos dword [edi] store_fixup: - jecxz fixups_done add dword [ebx],2 mov ah,[esi+1] and ah,0Fh @@ -1592,9 +1631,12 @@ make_pe_fixups: mov al,[esi] stos word [edi] add esi,5 - loop make_fixups + loop make_fixup fixups_done: + mov [last_fixup_base],edx pop esi + mov eax,edi + sub eax,ebp ret make_pe_resource: cmp byte [esi],82h @@ -2169,15 +2211,6 @@ close_pe: call make_timestamp mov edx,[code_start] mov [edx+8],eax - mov eax,[number_of_relocations] - cmp eax,-1 - je pe_relocations_ok - shl eax,2 - sub [free_additional_memory],eax - btr [resolver_flags],0 - jnc pe_relocations_ok - or [next_pass_needed],-1 - pe_relocations_ok: mov eax,[number_of_sections] mov [edx+6],ax imul eax,28h @@ -2195,7 +2228,7 @@ close_pe: pe_sections_ok: xor ecx,ecx add edx,78h - test [format_flags],8 + test [format_flags],4 jz process_directories add edx,10h process_directories: @@ -2214,6 +2247,25 @@ close_pe: inc cl cmp cl,10h jb process_directories + cmp dword [edx+5*8],0 + jne finish_pe_relocations + mov eax,[number_of_relocations] + shl eax,2 + sub [free_additional_memory],eax + btr [resolver_flags],0 + jnc pe_relocations_ok + or [next_pass_needed],-1 + jmp pe_relocations_ok + finish_pe_relocations: + push edi + mov edi,[reserved_fixups] + call make_fixups + pop edi + add [actual_fixups_size],eax + cmp eax,[reserved_fixups_size] + je pe_relocations_ok + or [next_pass_needed],-1 + pe_relocations_ok: mov ebx,[code_start] sub ebx,[stub_size] mov ecx,edi @@ -2303,7 +2355,7 @@ coff_section: cmp ecx,8 ja name_too_long coff_section_flags: - cmp byte [esi],1Ch + cmp byte [esi],8Ch je coff_section_alignment cmp byte [esi],19h jne coff_section_settings_ok @@ -2326,18 +2378,13 @@ coff_section: jnc invalid_argument inc esi lods byte [esi] - or al,al - jnz invalid_argument - lods byte [esi] cmp al,'(' jne invalid_argument cmp byte [esi],'.' je invalid_value push ebx - call get_dword_value + call get_count_value pop ebx - cmp [value_type],0 - jne invalid_use_of_symbol mov edx,eax dec edx test eax,edx @@ -2742,7 +2789,6 @@ coff_formatter: je public_symbol_type_ok jmp invalid_use_of_symbol undefined_coff_public: - mov eax,[eax+24] mov [error_info],eax jmp undefined_symbol check_64bit_public_symbol: @@ -2952,7 +2998,7 @@ elf_section: mov ecx,[esi] lea esi,[esi+4+ecx+1] elf_section_flags: - cmp byte [esi],1Ch + cmp byte [esi],8Ch je elf_section_alignment cmp byte [esi],19h jne elf_section_settings_ok @@ -2972,18 +3018,13 @@ elf_section: elf_section_alignment: inc esi lods byte [esi] - or al,al - jnz invalid_argument - lods byte [esi] cmp al,'(' jne invalid_argument cmp byte [esi],'.' je invalid_value push ebx - call get_dword_value + call get_count_value pop ebx - cmp [value_type],0 - jne invalid_use_of_symbol mov edx,eax dec edx test eax,edx @@ -4007,7 +4048,6 @@ elf_segment: elf64_segment_position_ok: and eax,not 0FFFh ret - close_elf_exe: test [format_flags],8 jnz close_elf64_exe @@ -4038,299 +4078,3 @@ close_elf_exe: or [next_pass_needed],-1 elf64_exe_ok: ret - -dump_symbols: - mov ebx,[code_start] - mov dword [ebx],'fas'+1Ah shl 24 - mov dword [ebx+4],VERSION_MAJOR + VERSION_MINOR shl 8 + 38h shl 16 - add ebx,38h - mov edi,ebx - mov dword [ebx-38h+10h],38h - mov dword [ebx-38h+8],0 - mov esi,[input_file] - call copy_asciiz - cmp edi,[display_buffer] - jae out_of_memory - mov eax,edi - sub eax,ebx - mov [ebx-38h+0Ch],eax - mov esi,[output_file] - call copy_asciiz - cmp edi,[display_buffer] - jae out_of_memory - mov edx,[symbols_stream] - mov ebp,[free_additional_memory] - mov [number_of_sections],0 - cmp [output_format],4 - je prepare_strings_table - cmp [output_format],5 - jne strings_table_ready - bt [format_flags],0 - jc strings_table_ready - prepare_strings_table: - cmp edx,ebp - je strings_table_ready - mov al,[edx] - test al,al - jz prepare_string - cmp al,80h - je prepare_string - add edx,0Ch - cmp al,0C0h - jb prepare_strings_table - add edx,4 - jmp prepare_strings_table - prepare_string: - mov esi,edi - sub esi,ebx - xchg esi,[edx+4] - test al,al - jz prepare_section_string - or dword [edx+4],1 shl 31 - add edx,0Ch - prepare_external_string: - mov ecx,[esi] - add esi,4 - rep movs byte [edi],[esi] - mov byte [edi],0 - inc edi - cmp edi,[display_buffer] - jae out_of_memory - jmp prepare_strings_table - prepare_section_string: - mov ecx,[number_of_sections] - mov eax,ecx - inc eax - mov [number_of_sections],eax - xchg eax,[edx+4] - shl ecx,2 - add ecx,[free_additional_memory] - mov [ecx],eax - add edx,20h - test esi,esi - jz prepare_default_section_string - cmp [output_format],5 - jne prepare_external_string - bt [format_flags],0 - jc prepare_external_string - mov esi,[esi] - add esi,[resource_data] - copy_elf_section_name: - lods byte [esi] - cmp edi,[display_buffer] - jae out_of_memory - stos byte [edi] - test al,al - jnz copy_elf_section_name - jmp prepare_strings_table - prepare_default_section_string: - mov eax,'.fla' - stos dword [edi] - mov ax,'t' - stos word [edi] - cmp edi,[display_buffer] - jae out_of_memory - jmp prepare_strings_table - strings_table_ready: - mov edx,[display_buffer] - mov ebp,[memory_end] - sub ebp,[labels_list] - add ebp,edx - prepare_labels_dump: - cmp edx,ebp - je labels_dump_ok - mov eax,[edx+24] - test eax,eax - jz label_dump_name_ok - cmp eax,[memory_start] - jb label_name_outside_source - cmp eax,[source_start] - ja label_name_outside_source - sub eax,[memory_start] - dec eax - mov [edx+24],eax - jmp label_dump_name_ok - label_name_outside_source: - mov esi,eax - mov eax,edi - sub eax,ebx - or eax,1 shl 31 - mov [edx+24],eax - movzx ecx,byte [esi-1] - lea eax,[edi+ecx+1] - cmp edi,[display_buffer] - jae out_of_memory - rep movsb - xor al,al - stosb - label_dump_name_ok: - mov eax,[edx+28] - test eax,eax - jz label_dump_line_ok - sub eax,[memory_start] - mov [edx+28],eax - label_dump_line_ok: - mov eax,[edx+20] - test eax,eax - jz base_symbol_for_label_ok - cmp eax,[symbols_stream] - mov eax,[eax+4] - jae base_symbol_for_label_ok - xor eax,eax - base_symbol_for_label_ok: - mov [edx+20],eax - add edx,LABEL_STRUCTURE_SIZE - jmp prepare_labels_dump - labels_dump_ok: - mov eax,edi - sub eax,ebx - mov [ebx-38h+14h],eax - add eax,38h - mov [ebx-38h+18h],eax - mov ecx,[memory_end] - sub ecx,[labels_list] - mov [ebx-38h+1Ch],ecx - add eax,ecx - mov [ebx-38h+20h],eax - mov ecx,[source_start] - sub ecx,[memory_start] - mov [ebx-38h+24h],ecx - add eax,ecx - mov [ebx-38h+28h],eax - mov eax,[number_of_sections] - shl eax,2 - mov [ebx-38h+34h],eax - mov esi,[memory_start] - prepare_preprocessed_source: - cmp esi,[source_start] - jae preprocessed_source_ok - mov eax,[memory_start] - mov edx,[input_file] - cmp [esi],edx - jne line_not_from_main_input - mov [esi],eax - line_not_from_main_input: - sub [esi],eax - test byte [esi+7],1 shl 7 - jz prepare_next_preprocessed_line - sub [esi+8],eax - sub [esi+12],eax - prepare_next_preprocessed_line: - add esi,16 - skip_preprocessed_line: - lods byte [esi] - cmp al,1Ah - je skip_preprocessed_symbol - cmp al,3Bh - je skip_preprocessed_symbol - cmp al,22h - je skip_preprocessed_string - or al,al - jnz skip_preprocessed_line - jmp prepare_preprocessed_source - skip_preprocessed_string: - lods dword [esi] - add esi,eax - jmp skip_preprocessed_line - skip_preprocessed_symbol: - lods byte [esi] - movzx eax,al - add esi,eax - jmp skip_preprocessed_line - preprocessed_source_ok: - mov esi,[labels_list] - mov ebp,edi - make_lines_dump: - cmp esi,[display_buffer] - je lines_dump_ok - mov eax,[esi-4] - mov ecx,[esi-8] - sub esi,8 - sub esi,ecx - cmp eax,1 - jne make_lines_dump - mov eax,[esi+4] - sub eax,[code_start] - add eax,[headers_size] - cmp byte [esi+1Ah],0 - je store_offset - xor eax,eax - store_offset: - stos dword [edi] - mov eax,[esi] - sub eax,[memory_start] - stos dword [edi] - mov eax,[esi+4] - xor edx,edx - sub eax,[esi+8] - sbb edx,[esi+8+4] - stos dword [edi] - mov eax,edx - stos dword [edi] - mov eax,[esi+10h] - stos dword [edi] - mov eax,[esi+14h] - test eax,eax - jz base_symbol_for_line_ok - cmp eax,[symbols_stream] - mov eax,[eax+4] - jae base_symbol_for_line_ok - xor eax,eax - base_symbol_for_line_ok: - stos dword [edi] - mov eax,[esi+18h] - and eax,001FFFFh - stos dword [edi] - jmp make_lines_dump - lines_dump_ok: - mov edx,edi - mov eax,[current_offset] - sub eax,[code_start] - add eax,[headers_size] - stos dword [edi] - mov ecx,edi - sub ecx,ebx - sub ecx,[ebx-38h+14h] - mov [ebx-38h+2Ch],ecx - add ecx,[ebx-38h+28h] - mov [ebx-38h+30h],ecx - find_inexisting_offsets: - sub edx,1Ch - cmp edx,ebp - jb write_symbols - test byte [edx+1Ah],1 - jnz find_inexisting_offsets - cmp eax,[edx] - jb correct_inexisting_offset - mov eax,[edx] - jmp find_inexisting_offsets - correct_inexisting_offset: - mov dword [edx],0 - or byte [edx+1Ah],2 - jmp find_inexisting_offsets - write_symbols: - mov edx,[symbols_file] - call create - jc write_failed - mov edx,[code_start] - mov ecx,[edx+14h] - add ecx,38h - call write - mov edx,[display_buffer] - mov ecx,[memory_end] - sub ecx,[labels_list] - call write - mov edx,[memory_start] - mov ecx,[source_start] - sub ecx,edx - call write - mov edx,ebp - mov ecx,edi - sub ecx,edx - call write - mov edx,[free_additional_memory] - mov ecx,[number_of_sections] - shl ecx,2 - call write - call close - ret diff --git a/programs/develop/fasm/trunk/messages.inc b/programs/develop/fasm/trunk/messages.inc index 4665ff819..9b3ff43e7 100644 --- a/programs/develop/fasm/trunk/messages.inc +++ b/programs/develop/fasm/trunk/messages.inc @@ -1,6 +1,6 @@ ; flat assembler core -; Copyright (c) 1999-2009, Tomasz Grysztar. +; Copyright (c) 1999-2011, Tomasz Grysztar. ; All rights reserved. _out_of_memory db 'out of memory',0 diff --git a/programs/develop/fasm/trunk/parser.inc b/programs/develop/fasm/trunk/parser.inc index 684a7b18b..ed5620a15 100644 --- a/programs/develop/fasm/trunk/parser.inc +++ b/programs/develop/fasm/trunk/parser.inc @@ -1,6 +1,6 @@ ; flat assembler core -; Copyright (c) 1999-2009, Tomasz Grysztar. +; Copyright (c) 1999-2011, Tomasz Grysztar. ; All rights reserved. parser: @@ -33,6 +33,7 @@ parser: inc [parsed_lines] add esi,16 parse_line: + mov [formatter_symbols_allowed],0 cmp byte [esi],1Ah jne empty_instruction push edi @@ -461,13 +462,22 @@ parse_line_contents: cmp bx,label_directive-instruction_handler je parse_label_directive cmp bx,segment_directive-instruction_handler - je parse_label_directive + je parse_segment_directive cmp bx,load_directive-instruction_handler je parse_load_directive cmp bx,extrn_directive-instruction_handler je parse_extrn_directive cmp bx,public_directive-instruction_handler je parse_public_directive + cmp bx,section_directive-instruction_handler + je parse_formatter_argument + cmp bx,format_directive-instruction_handler + je parse_formatter_argument + cmp bx,data_directive-instruction_handler + je parse_formatter_argument + jmp parse_argument + parse_formatter_argument: + or [formatter_symbols_allowed],-1 parse_argument: lea eax,[edi+100h] cmp eax,[labels_list] @@ -536,6 +546,8 @@ parse_line_contents: stos byte [edi] cmp al,80h je forced_expression + cmp al,8Ch + je forced_expression cmp al,81h je forced_parenthesis cmp al,82h @@ -577,6 +589,8 @@ parse_line_contents: jne allow_embedded_instruction movs byte [edi],[esi] jmp allow_embedded_instruction + parse_segment_directive: + or [formatter_symbols_allowed],-1 parse_label_directive: cmp byte [esi],1Ah jne argument_parsed @@ -623,7 +637,9 @@ parse_line_contents: inc esi push esi ecx push edi + or [formatter_symbols_allowed],-1 call get_symbol + mov [formatter_symbols_allowed],0 pop edi jc parse_public_label cmp al,1Dh @@ -787,11 +803,16 @@ parse_line_contents: stos byte [edi] jmp expression_parsed forced_expression: + xor al,al + xchg al,[formatter_symbols_allowed] + push eax mov al,'(' stos byte [edi] call convert_expression mov al,')' stos byte [edi] + pop eax + mov [formatter_symbols_allowed],al jmp argument_parsed address_argument: call parse_address @@ -1009,9 +1030,16 @@ get_symbol: repe cmps byte [esi],[edi] ja symbols_up jb symbols_down + mov ax,[edi] + + cmp al,18h + jb symbol_ok + cmp [formatter_symbols_allowed],0 + je no_symbol + + symbol_ok: pop esi add esi,ebp - mov ax,[edi] clc ret no_symbol: @@ -1047,7 +1075,7 @@ get_instruction: mov ebp,ecx call lower_case mov ecx,ebp - cmp cl,11 + cmp cl,16 ja no_instruction sub cl,2 jc no_instruction @@ -1157,9 +1185,13 @@ get_label_id: ret anonymous_back: mov eax,[anonymous_reverse] - or eax,eax - jz new_anonymous add esi,2 + or eax,eax + jz bogus_anonymous + jmp anonymous_ok + bogus_anonymous: + call allocate_label + mov [anonymous_reverse],eax jmp anonymous_ok new_anonymous: add esi,2 @@ -1175,7 +1207,15 @@ get_label_id: cmp byte [esi],'%' je get_predefined_id cmp byte [esi],'$' + je current_address_label + cmp byte [esi],'?' jne find_label + cmp ecx,1 + jne find_label + inc esi + mov eax,0Fh + ret + current_address_label: cmp ecx,2 ja find_label inc esi diff --git a/programs/develop/fasm/trunk/preproce.inc b/programs/develop/fasm/trunk/preproce.inc index 59f0fe0b1..ab2fedd40 100644 --- a/programs/develop/fasm/trunk/preproce.inc +++ b/programs/develop/fasm/trunk/preproce.inc @@ -1,6 +1,6 @@ ; flat assembler core -; Copyright (c) 1999-2009, Tomasz Grysztar. +; Copyright (c) 1999-2011, Tomasz Grysztar. ; All rights reserved. preprocessor: @@ -96,6 +96,8 @@ preprocess_file: call preprocess_line pop edx ebx next_line: + cmp byte [esi-1],0 + je file_end cmp byte [esi-1],1Ah jne preprocess_source file_end: @@ -219,6 +221,8 @@ convert_line: je concatenate_lines cmp al,1Ah je unexpected_end_of_file + or al,al + jz unexpected_end_of_file cmp al,0Ah je concatenate_lf cmp al,0Dh @@ -241,6 +245,8 @@ convert_line: backslashed_symbol: cmp al,1Ah je unexpected_end_of_file + or al,al + jz unexpected_end_of_file cmp al,0Ah je extra_characters_on_line cmp al,0Dh @@ -283,6 +289,8 @@ convert_line: je concatenate_lines cmp al,1Ah je unexpected_end_of_file + or al,al + jz unexpected_end_of_file cmp al,0Ah je concatenate_lf cmp al,0Dh @@ -1594,6 +1602,7 @@ use_instant_macro: stosb push esi mov esi,[esp+4] + mov [value_size],8 call calculate_expression mov eax,[edi] mov ecx,[edi+4] @@ -1887,6 +1896,12 @@ process_macro: je process_macro_line inc [counter] process_macro_line: + lods byte [esi] + or al,al + jz process_next_line + cmp al,'}' + je macro_block_processed + dec esi mov [current_line],edi lea eax,[edi+10h] cmp eax,[memory_end] diff --git a/programs/develop/fasm/trunk/symbdump.inc b/programs/develop/fasm/trunk/symbdump.inc index 2daa1cc49..806242ae6 100644 --- a/programs/develop/fasm/trunk/symbdump.inc +++ b/programs/develop/fasm/trunk/symbdump.inc @@ -1,110 +1,390 @@ -symbol_dump: - push edi - mov edx,[memory_end] - symb_dump: - cmp edx,[labels_list] - jbe symbols_dumped - sub edx,LABEL_STRUCTURE_SIZE - cmp dword [edx+24],0 - je symb_dump ; do not dump anonymous symbols - test byte [edx+8],1 - jz symb_dump ; do not dump symbols that didn't get defined +; flat assembler core +; Copyright (c) 1999-2011, Tomasz Grysztar. +; All rights reserved. + +dump_symbols: + mov edi,[code_start] + call setup_dump_header + mov esi,[input_file] + call copy_asciiz + cmp edi,[display_buffer] + jae out_of_memory + mov eax,edi + sub eax,ebx + mov [ebx-38h+0Ch],eax + mov esi,[output_file] + call copy_asciiz + cmp edi,[display_buffer] + jae out_of_memory + mov edx,[symbols_stream] + mov ebp,[free_additional_memory] + mov [number_of_sections],0 + cmp [output_format],4 + je prepare_strings_table + cmp [output_format],5 + jne strings_table_ready + bt [format_flags],0 + jc strings_table_ready + prepare_strings_table: + cmp edx,ebp + je strings_table_ready + mov al,[edx] + test al,al + jz prepare_string + cmp al,80h + je prepare_string + add edx,0Ch + cmp al,0C0h + jb prepare_strings_table + add edx,4 + jmp prepare_strings_table + prepare_string: + mov esi,edi + sub esi,ebx + xchg esi,[edx+4] + test al,al + jz prepare_section_string + or dword [edx+4],1 shl 31 + add edx,0Ch + prepare_external_string: + mov ecx,[esi] + add esi,4 + rep movs byte [edi],[esi] + mov byte [edi],0 + inc edi + cmp edi,[display_buffer] + jae out_of_memory + jmp prepare_strings_table + prepare_section_string: + mov ecx,[number_of_sections] + mov eax,ecx + inc eax + mov [number_of_sections],eax + xchg eax,[edx+4] + shl ecx,2 + add ecx,[free_additional_memory] + mov [ecx],eax + add edx,20h + test esi,esi + jz prepare_default_section_string + cmp [output_format],5 + jne prepare_external_string + bt [format_flags],0 + jc prepare_external_string + mov esi,[esi] + add esi,[resource_data] + copy_elf_section_name: + lods byte [esi] + cmp edi,[display_buffer] + jae out_of_memory + stos byte [edi] + test al,al + jnz copy_elf_section_name + jmp prepare_strings_table + prepare_default_section_string: + mov eax,'.fla' + stos dword [edi] + mov ax,'t' + stos word [edi] + cmp edi,[display_buffer] + jae out_of_memory + jmp prepare_strings_table + strings_table_ready: + mov edx,[display_buffer] + mov ebp,[memory_end] + sub ebp,[labels_list] + add ebp,edx + prepare_labels_dump: + cmp edx,ebp + je labels_dump_ok + mov eax,[edx+24] + test eax,eax + jz label_dump_name_ok + cmp eax,[memory_start] + jb label_name_outside_source + cmp eax,[source_start] + ja label_name_outside_source + sub eax,[memory_start] + dec eax + mov [edx+24],eax + jmp label_dump_name_ok + label_name_outside_source: + mov esi,eax + mov eax,edi + sub eax,ebx + or eax,1 shl 31 + mov [edx+24],eax + movzx ecx,byte [esi-1] + lea eax,[edi+ecx+1] + cmp edi,[display_buffer] + jae out_of_memory + rep movsb + xor al,al + stosb + label_dump_name_ok: + mov eax,[edx+28] + test eax,eax + jz label_dump_line_ok + sub eax,[memory_start] + mov [edx+28],eax + label_dump_line_ok: + mov eax,[edx+20] + test eax,eax + jz base_symbol_for_label_ok + cmp eax,[symbols_stream] + mov eax,[eax+4] + jae base_symbol_for_label_ok + xor eax,eax + base_symbol_for_label_ok: + mov [edx+20],eax mov ax,[current_pass] cmp ax,[edx+16] - jne symb_dump - test byte [edx+8],4 or 2 - jnz symb_dump ; do not dump assembly-time variables - ; do not dump variables defined with '=' - cmp word [edx+12], 0 - jnz symb_dump ; do not dump register-based variables - - mov al, '0' - stosb - mov al, 'x' - stosb - mov eax, [edx+4] - mov ecx, 8 -@@: - rol eax, 4 - test al, 0xF - loopz @b - jz .nohigh - inc ecx -@@: - push eax - and al, 0xF - cmp al, 10 - sbb al, 69h - das - stosb - pop eax - rol eax, 4 - loop @b - mov eax, [edx] - mov ecx, 8 - jmp .low -.nohigh: - mov eax, [edx] - mov ecx, 8 -@@: - rol eax, 4 - test al, 0xF - loopz @b - inc ecx -.low: - push eax - and al, 0xF - cmp al, 10 - sbb al, 69h - das - stosb - pop eax - rol eax, 4 - loop .low - - mov al, ' ' - stosb - - mov esi,[edx+24] - movzx ecx,byte [esi-1] - rep movsb - - mov ax,0A0Dh - stosw - - jmp symb_dump - - symbols_dumped: - mov edx,dbgfilename - push esi edi - mov esi, outfile - mov edi, edx -@@: - lodsb - stosb - test al, al - jnz @b - lea ecx, [edi-1] -@@: - dec edi - cmp edi, edx - jb @f - cmp byte [edi], '/' - jz @f - cmp byte [edi], '.' - jnz @b - mov ecx, edi -@@: - mov dword [ecx], '.dbg' - mov byte [ecx+4], 0 - pop edi esi + je label_defined_flag_ok + and byte [edx+8],not 1 + label_defined_flag_ok: + cmp ax,[edx+18] + je label_used_flag_ok + and byte [edx+8],not 8 + label_used_flag_ok: + add edx,LABEL_STRUCTURE_SIZE + jmp prepare_labels_dump + labels_dump_ok: + mov eax,edi + sub eax,ebx + mov [ebx-38h+14h],eax + add eax,38h + mov [ebx-38h+18h],eax + mov ecx,[memory_end] + sub ecx,[labels_list] + mov [ebx-38h+1Ch],ecx + add eax,ecx + mov [ebx-38h+20h],eax + mov ecx,[source_start] + sub ecx,[memory_start] + mov [ebx-38h+24h],ecx + add eax,ecx + mov [ebx-38h+28h],eax + mov eax,[number_of_sections] + shl eax,2 + mov [ebx-38h+34h],eax + call prepare_preprocessed_source + mov esi,[labels_list] + mov ebp,edi + make_lines_dump: + cmp esi,[display_buffer] + je lines_dump_ok + mov eax,[esi-4] + mov ecx,[esi-8] + sub esi,8 + sub esi,ecx + cmp eax,1 + jne make_lines_dump + mov eax,[esi+4] + sub eax,[code_start] + add eax,[headers_size] + cmp byte [esi+1Ah],0 + je store_offset + xor eax,eax + store_offset: + stos dword [edi] + mov eax,[esi] + sub eax,[memory_start] + stos dword [edi] + mov eax,[esi+4] + xor edx,edx + sub eax,[esi+8] + sbb edx,[esi+8+4] + stos dword [edi] + mov eax,edx + stos dword [edi] + mov eax,[esi+10h] + stos dword [edi] + mov eax,[esi+14h] + test eax,eax + jz base_symbol_for_line_ok + cmp eax,[symbols_stream] + mov eax,[eax+4] + jae base_symbol_for_line_ok + xor eax,eax + base_symbol_for_line_ok: + stos dword [edi] + mov eax,[esi+18h] + and eax,001FFFFh + stos dword [edi] + cmp edi,[display_buffer] + jae out_of_memory + jmp make_lines_dump + lines_dump_ok: + mov edx,edi + mov eax,[current_offset] + sub eax,[code_start] + add eax,[headers_size] + stos dword [edi] + mov ecx,edi + sub ecx,ebx + sub ecx,[ebx-38h+14h] + mov [ebx-38h+2Ch],ecx + add ecx,[ebx-38h+28h] + mov [ebx-38h+30h],ecx + find_inexisting_offsets: + sub edx,1Ch + cmp edx,ebp + jb write_symbols + test byte [edx+1Ah],1 + jnz find_inexisting_offsets + cmp eax,[edx] + jb correct_inexisting_offset + mov eax,[edx] + jmp find_inexisting_offsets + correct_inexisting_offset: + mov dword [edx],0 + or byte [edx+1Ah],2 + jmp find_inexisting_offsets + write_symbols: + mov edx,[symbols_file] call create - mov edx,[esp] + jc write_failed + mov edx,[code_start] + mov ecx,[edx+14h] + add ecx,38h + call write + jc write_failed + mov edx,[display_buffer] + mov ecx,[memory_end] + sub ecx,[labels_list] + call write + jc write_failed + mov edx,[memory_start] + mov ecx,[source_start] + sub ecx,edx + call write + jc write_failed + mov edx,ebp mov ecx,edi sub ecx,edx call write + jc write_failed + mov edx,[free_additional_memory] + mov ecx,[number_of_sections] + shl ecx,2 + call write + jc write_failed call close - pop edi - ret + setup_dump_header: + xor eax,eax + mov ecx,38h shr 2 + rep stos dword [edi] + mov ebx,edi + mov dword [ebx-38h],'fas'+1Ah shl 24 + mov dword [ebx-38h+4],VERSION_MAJOR + VERSION_MINOR shl 8 + 38h shl 16 + mov dword [ebx-38h+10h],38h + ret +prepare_preprocessed_source: + mov esi,[memory_start] + mov ebp,[source_start] + test ebp,ebp + jnz prepare_preprocessed_line + mov ebp,[current_line] + inc ebp + prepare_preprocessed_line: + cmp esi,ebp + jae preprocessed_source_ok + mov eax,[memory_start] + mov edx,[input_file] + cmp [esi],edx + jne line_not_from_main_input + mov [esi],eax + line_not_from_main_input: + sub [esi],eax + test byte [esi+7],1 shl 7 + jz prepare_next_preprocessed_line + sub [esi+8],eax + sub [esi+12],eax + prepare_next_preprocessed_line: + call skip_preprocessed_line + jmp prepare_preprocessed_line + preprocessed_source_ok: + ret + skip_preprocessed_line: + add esi,16 + skip_preprocessed_line_content: + lods byte [esi] + cmp al,1Ah + je skip_preprocessed_symbol + cmp al,3Bh + je skip_preprocessed_symbol + cmp al,22h + je skip_preprocessed_string + or al,al + jnz skip_preprocessed_line_content + ret + skip_preprocessed_string: + lods dword [esi] + add esi,eax + jmp skip_preprocessed_line_content + skip_preprocessed_symbol: + lods byte [esi] + movzx eax,al + add esi,eax + jmp skip_preprocessed_line_content +restore_preprocessed_source: + mov esi,[memory_start] + mov ebp,[source_start] + test ebp,ebp + jnz restore_preprocessed_line + mov ebp,[current_line] + inc ebp + restore_preprocessed_line: + cmp esi,ebp + jae preprocessed_source_restored + mov eax,[memory_start] + add [esi],eax + cmp [esi],eax + jne preprocessed_line_source_restored + mov edx,[input_file] + mov [esi],edx + preprocessed_line_source_restored: + test byte [esi+7],1 shl 7 + jz restore_next_preprocessed_line + add [esi+8],eax + add [esi+12],eax + restore_next_preprocessed_line: + call skip_preprocessed_line + jmp restore_preprocessed_line + preprocessed_source_restored: + ret +dump_preprocessed_source: + mov edi,[free_additional_memory] + call setup_dump_header + mov esi,[input_file] + call copy_asciiz + cmp edi,[additional_memory_end] + jae out_of_memory + mov eax,edi + sub eax,ebx + dec eax + mov [ebx-38h+0Ch],eax + mov eax,edi + sub eax,ebx + mov [ebx-38h+14h],eax + add eax,38h + mov [ebx-38h+20h],eax + call prepare_preprocessed_source + sub esi,[memory_start] + mov [ebx-38h+24h],esi + mov edx,[symbols_file] + call create + jc write_failed + mov edx,[free_additional_memory] + mov ecx,[edx+14h] + add ecx,38h + call write + jc write_failed + mov edx,[memory_start] + mov ecx,esi + call write + jc write_failed + call close + ret \ No newline at end of file diff --git a/programs/develop/fasm/trunk/system.inc b/programs/develop/fasm/trunk/system.inc index 6cda27ac0..d98d59d7a 100644 --- a/programs/develop/fasm/trunk/system.inc +++ b/programs/develop/fasm/trunk/system.inc @@ -98,6 +98,117 @@ make_timestamp: pop ebx ret +symbol_dump: + + push edi + mov edx,[memory_end] + symb_dump: + cmp edx,[labels_list] + jbe symbols_dumped + sub edx,LABEL_STRUCTURE_SIZE + cmp dword [edx+24],0 + je symb_dump ; do not dump anonymous symbols + test byte [edx+8],1 + jz symb_dump ; do not dump symbols that didn't get defined + mov ax,[current_pass] + cmp ax,[edx+16] + jne symb_dump + test byte [edx+8],4 or 2 + jnz symb_dump ; do not dump assembly-time variables + ; do not dump variables defined with '=' + cmp word [edx+12], 0 + jnz symb_dump ; do not dump register-based variables + + mov al, '0' + stosb + mov al, 'x' + stosb + mov eax, [edx+4] + mov ecx, 8 +@@: + rol eax, 4 + test al, 0xF + loopz @b + jz .nohigh + inc ecx +@@: + push eax + and al, 0xF + cmp al, 10 + sbb al, 69h + das + stosb + pop eax + rol eax, 4 + loop @b + mov eax, [edx] + mov ecx, 8 + jmp .low +.nohigh: + mov eax, [edx] + mov ecx, 8 +@@: + rol eax, 4 + test al, 0xF + loopz @b + inc ecx +.low: + push eax + and al, 0xF + cmp al, 10 + sbb al, 69h + das + stosb + pop eax + rol eax, 4 + loop .low + + mov al, ' ' + stosb + + mov esi,[edx+24] + movzx ecx,byte [esi-1] + rep movsb + + mov ax,0A0Dh + stosw + + jmp symb_dump + + symbols_dumped: + mov edx,dbgfilename + push esi edi + mov esi, outfile + mov edi, edx +@@: + lodsb + stosb + test al, al + jnz @b + lea ecx, [edi-1] +@@: + dec edi + cmp edi, edx + jb @f + cmp byte [edi], '/' + jz @f + cmp byte [edi], '.' + jnz @b + mov ecx, edi +@@: + mov dword [ecx], '.dbg' + mov byte [ecx+4], 0 + pop edi esi + call create + mov edx,[esp] + mov ecx,edi + sub ecx,edx + call write + call close + pop edi + + ret + get_environment_variable: mov ecx,[memory_end] sub ecx,edi diff --git a/programs/develop/fasm/trunk/tables.inc b/programs/develop/fasm/trunk/tables.inc index aa160ef79..90f7d3e0a 100644 --- a/programs/develop/fasm/trunk/tables.inc +++ b/programs/develop/fasm/trunk/tables.inc @@ -1,6 +1,6 @@ ; flat assembler core -; Copyright (c) 1999-2009, Tomasz Grysztar. +; Copyright (c) 1999-2011, Tomasz Grysztar. ; All rights reserved. include_variable db 'INCLUDE',0 @@ -66,6 +66,7 @@ single_operand_operators: db 0 directive_operators: + db 5,'align',8Ch db 2,'as',86h db 2,'at',80h db 7,'defined',88h @@ -159,8 +160,9 @@ symbols_2: db 'es',10h,61h db 'fs',10h,65h db 'gs',10h,66h - db 'ms',17h,41h + db 'ms',1Ch,41h db 'mz',18h,20h + db 'nx',1Bh,83h db 'pe',18h,30h db 'r8',10h,88h db 'r9',10h,89h @@ -272,10 +274,10 @@ symbols_4: db 'dr13',10h,7Dh db 'dr14',10h,7Eh db 'dr15',10h,7Fh - db 'ms64',17h,49h + db 'ms64',1Ch,49h db 'near',12h,2 db 'note',1Eh,4 - db 'pe64',18h,38h + db 'pe64',18h,3Ch db 'r10b',10h,1Ah db 'r10d',10h,4Ah db 'r10l',10h,1Ah @@ -311,11 +313,21 @@ symbols_4: db 'xmm7',10h,0C7h db 'xmm8',10h,0C8h db 'xmm9',10h,0C9h + db 'ymm0',10h,0D0h + db 'ymm1',10h,0D1h + db 'ymm2',10h,0D2h + db 'ymm3',10h,0D3h + db 'ymm4',10h,0D4h + db 'ymm5',10h,0D5h + db 'ymm6',10h,0D6h + db 'ymm7',10h,0D7h + db 'ymm8',10h,0D8h + db 'ymm9',10h,0D9h symbols_5: - db 'align',1Ch,0 db 'dword',11h,4 db 'elf64',18h,58h db 'fword',11h,6 + db 'large',1Bh,82h db 'pword',11h,6 db 'qword',11h,8 db 'short',12h,1 @@ -330,6 +342,14 @@ symbols_5: db 'xmm13',10h,0CDh db 'xmm14',10h,0CEh db 'xmm15',10h,0CFh + db 'xword',11h,16 + db 'ymm10',10h,0DAh + db 'ymm11',10h,0DBh + db 'ymm12',10h,0DCh + db 'ymm13',10h,0DDh + db 'ymm14',10h,0DEh + db 'ymm15',10h,0DFh + db 'yword',11h,32 symbols_6: db 'binary',18h,10h db 'dqword',11h,16 @@ -337,6 +357,7 @@ symbols_6: db 'fixups',1Ah,5 db 'import',1Ah,1 db 'native',1Bh,1 + db 'qqword',11h,32 db 'static',1Dh,1 symbols_7: db 'console',1Bh,3 @@ -370,7 +391,12 @@ instructions: dw instructions_8-instructions,(instructions_9-instructions_8)/(8+3) dw instructions_9-instructions,(instructions_10-instructions_9)/(9+3) dw instructions_10-instructions,(instructions_11-instructions_10)/(10+3) - dw instructions_11-instructions,(instructions_end-instructions_11)/(11+3) + dw instructions_11-instructions,(instructions_12-instructions_11)/(11+3) + dw instructions_12-instructions,(instructions_13-instructions_12)/(12+3) + dw instructions_13-instructions,(instructions_14-instructions_13)/(13+3) + dw instructions_14-instructions,(instructions_15-instructions_14)/(14+3) + dw instructions_15-instructions,(instructions_16-instructions_15)/(15+3) + dw instructions_16-instructions,(instructions_end-instructions_16)/(16+3) instructions_2: db 'bt',4 @@ -781,6 +807,8 @@ instructions_4: dw pm_word_instruction-instruction_handler db 'verw',5 dw pm_word_instruction-instruction_handler + db 'vpor',0EBh + dw avx_128bit_instruction-instruction_handler db 'wait',9Bh dw simple_instruction-instruction_handler db 'xadd',0C0h @@ -830,18 +858,18 @@ instructions_5: dw cmov_instruction-instruction_handler db 'cmovz',44h dw cmov_instruction-instruction_handler - db 'cmppd',0 - dw cmppd_instruction-instruction_handler - db 'cmpps',0 - dw cmpps_instruction-instruction_handler + db 'cmppd',-1 + dw cmp_pd_instruction-instruction_handler + db 'cmpps',-1 + dw cmp_ps_instruction-instruction_handler db 'cmpsb',0A6h dw simple_instruction-instruction_handler - db 'cmpsd',0 + db 'cmpsd',-1 dw cmpsd_instruction-instruction_handler db 'cmpsq',0A7h dw simple_instruction_64bit-instruction_handler - db 'cmpss',0 - dw cmpss_instruction-instruction_handler + db 'cmpss',-1 + dw cmp_ss_instruction-instruction_handler db 'cmpsw',0A7h dw simple_instruction_16bit-instruction_handler db 'cpuid',0A2h @@ -1071,21 +1099,21 @@ instructions_5: db 'popfw',9Dh dw simple_instruction_16bit-instruction_handler db 'pslld',0F2h - dw mmx_ps_instruction-instruction_handler + dw mmx_bit_shift_instruction-instruction_handler db 'psllq',0F3h - dw mmx_ps_instruction-instruction_handler + dw mmx_bit_shift_instruction-instruction_handler db 'psllw',0F1h - dw mmx_ps_instruction-instruction_handler + dw mmx_bit_shift_instruction-instruction_handler db 'psrad',0E2h - dw mmx_ps_instruction-instruction_handler + dw mmx_bit_shift_instruction-instruction_handler db 'psraw',0E1h - dw mmx_ps_instruction-instruction_handler + dw mmx_bit_shift_instruction-instruction_handler db 'psrld',0D2h - dw mmx_ps_instruction-instruction_handler + dw mmx_bit_shift_instruction-instruction_handler db 'psrlq',0D3h - dw mmx_ps_instruction-instruction_handler + dw mmx_bit_shift_instruction-instruction_handler db 'psrlw',0D1h - dw mmx_ps_instruction-instruction_handler + dw mmx_bit_shift_instruction-instruction_handler db 'psubb',0F8h dw basic_mmx_instruction-instruction_handler db 'psubd',0FAh @@ -1194,10 +1222,26 @@ instructions_5: dw sse_ss_instruction-instruction_handler db 'times',0 dw times_directive-instruction_handler + db 'vdppd',41h + dw avx_128bit_instruction_3a_imm8-instruction_handler + db 'vdpps',40h + dw avx_instruction_3a_imm8-instruction_handler + db 'vmovd',0 + dw avx_movd_instruction-instruction_handler + db 'vmovq',0 + dw avx_movq_instruction-instruction_handler db 'vmrun',0D8h dw simple_svm_instruction-instruction_handler db 'vmxon',6 dw vmxon_instruction-instruction_handler + db 'vorpd',56h + dw avx_pd_instruction-instruction_handler + db 'vorps',56h + dw avx_ps_instruction-instruction_handler + db 'vpand',0DBh + dw avx_128bit_instruction-instruction_handler + db 'vpxor',0EFh + dw avx_128bit_instruction-instruction_handler db 'while',0 dw while_directive-instruction_handler db 'wrmsr',30h @@ -1208,7 +1252,15 @@ instructions_5: dw sse_pd_instruction-instruction_handler db 'xorps',57h dw sse_ps_instruction-instruction_handler + db 'xsave',100b + dw fxsave_instruction-instruction_handler instructions_6: + db 'aesdec',0DEh + dw sse4_instruction_38-instruction_handler + db 'aesenc',0DCh + dw sse4_instruction_38-instruction_handler + db 'aesimc',0DBh + dw sse4_instruction_38-instruction_handler db 'andnpd',55h dw sse_pd_instruction-instruction_handler db 'andnps',55h @@ -1462,9 +1514,9 @@ instructions_6: db 'psignw',9 dw ssse3_instruction-instruction_handler db 'pslldq',111b - dw ps_dq_instruction-instruction_handler + dw pslldq_instruction-instruction_handler db 'psrldq',011b - dw ps_dq_instruction-instruction_handler + dw pslldq_instruction-instruction_handler db 'psubsb',0E8h dw basic_mmx_instruction-instruction_handler db 'psubsw',0E9h @@ -1485,8 +1537,10 @@ instructions_6: dw simple_instruction_16bit-instruction_handler db 'rdmsrq',32h dw simple_extended_instruction_64bit-instruction_handler + db 'rdrand',110b + dw rdrand_instruction-instruction_handler db 'rdtscp',1 - dw swapgs_instruction-instruction_handler + dw rdtscp_instruction-instruction_handler db 'repeat',0 dw repeat_directive-instruction_handler db 'setalc',0D6h @@ -1519,20 +1573,182 @@ instructions_6: dw swapgs_instruction-instruction_handler db 'sysret',07h dw simple_extended_instruction-instruction_handler + db 'vaddpd',58h + dw avx_pd_instruction-instruction_handler + db 'vaddps',58h + dw avx_ps_instruction-instruction_handler + db 'vaddsd',58h + dw avx_sd_instruction-instruction_handler + db 'vaddss',58h + dw avx_ss_instruction-instruction_handler + db 'vandpd',54h + dw avx_pd_instruction-instruction_handler + db 'vandps',54h + dw avx_ps_instruction-instruction_handler + db 'vcmppd',-1 + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpps',-1 + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpsd',-1 + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpss',-1 + dw avx_cmp_ss_instruction-instruction_handler + db 'vdivpd',5Eh + dw avx_pd_instruction-instruction_handler + db 'vdivps',5Eh + dw avx_ps_instruction-instruction_handler + db 'vdivsd',5Eh + dw avx_sd_instruction-instruction_handler + db 'vdivss',5Eh + dw avx_ss_instruction-instruction_handler + db 'vlddqu',0F0h + dw avx_lddqu_instruction-instruction_handler + db 'vmaxpd',5Fh + dw avx_pd_instruction-instruction_handler + db 'vmaxps',5Fh + dw avx_ps_instruction-instruction_handler + db 'vmaxsd',5Fh + dw avx_sd_instruction-instruction_handler + db 'vmaxss',5Fh + dw avx_ss_instruction-instruction_handler db 'vmcall',0C1h dw simple_vmx_instruction-instruction_handler + db 'vminpd',5Dh + dw avx_pd_instruction-instruction_handler + db 'vminps',5Dh + dw avx_ps_instruction-instruction_handler + db 'vminsd',5Dh + dw avx_sd_instruction-instruction_handler + db 'vminss',5Dh + dw avx_ss_instruction-instruction_handler db 'vmload',0DAh dw simple_svm_instruction-instruction_handler + db 'vmovsd',0 + dw avx_movsd_instruction-instruction_handler + db 'vmovss',0 + dw avx_movss_instruction-instruction_handler db 'vmread',0 dw vmread_instruction-instruction_handler db 'vmsave',0DBh dw simple_svm_instruction-instruction_handler + db 'vmulpd',59h + dw avx_pd_instruction-instruction_handler + db 'vmulps',59h + dw avx_ps_instruction-instruction_handler + db 'vmulsd',59h + dw avx_sd_instruction-instruction_handler + db 'vmulss',59h + dw avx_ss_instruction-instruction_handler db 'vmxoff',0C4h dw simple_vmx_instruction-instruction_handler + db 'vpabsb',1Ch + dw avx_single_source_128bit_instruction_38-instruction_handler + db 'vpabsd',1Eh + dw avx_single_source_128bit_instruction_38-instruction_handler + db 'vpabsw',1Dh + dw avx_single_source_128bit_instruction_38-instruction_handler + db 'vpaddb',0FCh + dw avx_128bit_instruction-instruction_handler + db 'vpaddd',0FEh + dw avx_128bit_instruction-instruction_handler + db 'vpaddq',0D4h + dw avx_128bit_instruction-instruction_handler + db 'vpaddw',0FDh + dw avx_128bit_instruction-instruction_handler + db 'vpandn',0DFh + dw avx_128bit_instruction-instruction_handler + db 'vpavgb',0E0h + dw avx_128bit_instruction-instruction_handler + db 'vpavgw',0E3h + dw avx_128bit_instruction-instruction_handler + db 'vpcmov',0A2h + dw vpcmov_instruction-instruction_handler + db 'vpcomb',-1 + dw xop_pcom_b_instruction-instruction_handler + db 'vpcomd',-1 + dw xop_pcom_d_instruction-instruction_handler + db 'vpcomq',-1 + dw xop_pcom_q_instruction-instruction_handler + db 'vpcomw',-1 + dw xop_pcom_w_instruction-instruction_handler + db 'vpperm',0A3h + dw xop_128bit_instruction-instruction_handler + db 'vprotb',90h + dw xop_shift_instruction-instruction_handler + db 'vprotd',92h + dw xop_shift_instruction-instruction_handler + db 'vprotq',93h + dw xop_shift_instruction-instruction_handler + db 'vprotw',91h + dw xop_shift_instruction-instruction_handler + db 'vpshab',98h + dw xop_shift_instruction-instruction_handler + db 'vpshad',9Ah + dw xop_shift_instruction-instruction_handler + db 'vpshaq',9Bh + dw xop_shift_instruction-instruction_handler + db 'vpshaw',99h + dw xop_shift_instruction-instruction_handler + db 'vpshlb',94h + dw xop_shift_instruction-instruction_handler + db 'vpshld',96h + dw xop_shift_instruction-instruction_handler + db 'vpshlq',97h + dw xop_shift_instruction-instruction_handler + db 'vpshlw',95h + dw xop_shift_instruction-instruction_handler + db 'vpslld',0F2h + dw avx_bit_shift_instruction-instruction_handler + db 'vpsllq',0F3h + dw avx_bit_shift_instruction-instruction_handler + db 'vpsllw',0F1h + dw avx_bit_shift_instruction-instruction_handler + db 'vpsrad',0E2h + dw avx_bit_shift_instruction-instruction_handler + db 'vpsraw',0E1h + dw avx_bit_shift_instruction-instruction_handler + db 'vpsrld',0D2h + dw avx_bit_shift_instruction-instruction_handler + db 'vpsrlq',0D3h + dw avx_bit_shift_instruction-instruction_handler + db 'vpsrlw',0D1h + dw avx_bit_shift_instruction-instruction_handler + db 'vpsubb',0F8h + dw avx_128bit_instruction-instruction_handler + db 'vpsubd',0FAh + dw avx_128bit_instruction-instruction_handler + db 'vpsubq',0FBh + dw avx_128bit_instruction-instruction_handler + db 'vpsubw',0F9h + dw avx_128bit_instruction-instruction_handler + db 'vptest',17h + dw avx_single_source_instruction_38-instruction_handler + db 'vrcpps',53h + dw avx_single_source_ps_instruction-instruction_handler + db 'vrcpss',53h + dw avx_ss_instruction-instruction_handler + db 'vsubpd',5Ch + dw avx_pd_instruction-instruction_handler + db 'vsubps',5Ch + dw avx_ps_instruction-instruction_handler + db 'vsubsd',5Ch + dw avx_sd_instruction-instruction_handler + db 'vsubss',5Ch + dw avx_ss_instruction-instruction_handler + db 'vxorpd',57h + dw avx_pd_instruction-instruction_handler + db 'vxorps',57h + dw avx_ps_instruction-instruction_handler db 'wbinvd',9 dw simple_extended_instruction-instruction_handler db 'wrmsrq',30h dw simple_extended_instruction_64bit-instruction_handler + db 'xgetbv',0D0h + dw simple_vmx_instruction-instruction_handler + db 'xrstor',101b + dw fxsave_instruction-instruction_handler + db 'xsetbv',0D1h + dw simple_vmx_instruction-instruction_handler instructions_7: db 'blendpd',0Dh dw sse4_instruction_3a_imm8-instruction_handler @@ -1591,7 +1807,7 @@ instructions_7: db 'fldenvd',4 dw fldenv_instruction_32bit-instruction_handler db 'fldenvw',4 - dw fldenv_instruction_32bit-instruction_handler + dw fldenv_instruction_16bit-instruction_handler db 'fnsaved',6 dw fnsave_instruction_32bit-instruction_handler db 'fnsavew',6 @@ -1651,9 +1867,9 @@ instructions_7: db 'movlhps',16h dw movhlps_instruction-instruction_handler db 'movntdq',0E7h - dw movntdq_instruction-instruction_handler + dw movntpd_instruction-instruction_handler db 'movntpd',2Bh - dw movntdq_instruction-instruction_handler + dw movntpd_instruction-instruction_handler db 'movntps',2Bh dw movntps_instruction-instruction_handler db 'movntsd',2Bh @@ -1748,18 +1964,174 @@ instructions_7: dw comisd_instruction-instruction_handler db 'ucomiss',2Eh dw comiss_instruction-instruction_handler + db 'vaesdec',0DEh + dw avx_128bit_instruction_38-instruction_handler + db 'vaesenc',0DCh + dw avx_128bit_instruction_38-instruction_handler + db 'vaesimc',0DBh + dw avx_single_source_128bit_instruction_38-instruction_handler + db 'vandnpd',55h + dw avx_pd_instruction-instruction_handler + db 'vandnps',55h + dw avx_ps_instruction-instruction_handler + db 'vcomisd',2Fh + dw avx_comisd_instruction-instruction_handler + db 'vcomiss',2Fh + dw avx_comiss_instruction-instruction_handler + db 'vfrczpd',81h + dw xop_single_source_instruction-instruction_handler + db 'vfrczps',80h + dw xop_single_source_instruction-instruction_handler + db 'vfrczsd',83h + dw xop_single_source_sd_instruction-instruction_handler + db 'vfrczss',82h + dw xop_single_source_ss_instruction-instruction_handler + db 'vhaddpd',07Ch + dw avx_pd_instruction-instruction_handler + db 'vhaddps',07Ch + dw avx_haddps_instruction-instruction_handler + db 'vhsubpd',07Dh + dw avx_pd_instruction-instruction_handler + db 'vhsubps',07Dh + dw avx_haddps_instruction-instruction_handler db 'virtual',0 dw virtual_directive-instruction_handler db 'vmclear',6 dw vmclear_instruction-instruction_handler db 'vmmcall',0D9h dw simple_vmx_instruction-instruction_handler + db 'vmovapd',28h + dw avx_movpd_instruction-instruction_handler + db 'vmovaps',28h + dw avx_movps_instruction-instruction_handler + db 'vmovdqa',6Fh + dw avx_movpd_instruction-instruction_handler + db 'vmovdqu',6Fh + dw avx_movdqu_instruction-instruction_handler + db 'vmovhpd',16h + dw avx_movlpd_instruction-instruction_handler + db 'vmovhps',16h + dw avx_movlps_instruction-instruction_handler + db 'vmovlpd',12h + dw avx_movlpd_instruction-instruction_handler + db 'vmovlps',12h + dw avx_movlps_instruction-instruction_handler + db 'vmovupd',10h + dw avx_movpd_instruction-instruction_handler + db 'vmovups',10h + dw avx_movps_instruction-instruction_handler db 'vmptrld',6 dw vmx_instruction-instruction_handler db 'vmptrst',7 dw vmx_instruction-instruction_handler db 'vmwrite',0 dw vmwrite_instruction-instruction_handler + db 'vpaddsb',0ECh + dw avx_128bit_instruction-instruction_handler + db 'vpaddsw',0EDh + dw avx_128bit_instruction-instruction_handler + db 'vpcomub',-1 + dw xop_pcom_ub_instruction-instruction_handler + db 'vpcomud',-1 + dw xop_pcom_ud_instruction-instruction_handler + db 'vpcomuq',-1 + dw xop_pcom_uq_instruction-instruction_handler + db 'vpcomuw',-1 + dw xop_pcom_uw_instruction-instruction_handler + db 'vpextrb',14h + dw avx_pextrb_instruction-instruction_handler + db 'vpextrd',16h + dw avx_pextrd_instruction-instruction_handler + db 'vpextrq',16h + dw avx_pextrq_instruction-instruction_handler + db 'vpextrw',15h + dw avx_pextrw_instruction-instruction_handler + db 'vphaddd',2 + dw avx_128bit_instruction_38-instruction_handler + db 'vphaddw',1 + dw avx_128bit_instruction_38-instruction_handler + db 'vphsubd',6 + dw avx_128bit_instruction_38-instruction_handler + db 'vphsubw',5 + dw avx_128bit_instruction_38-instruction_handler + db 'vpinsrb',20h + dw avx_pinsrb_instruction-instruction_handler + db 'vpinsrd',22h + dw avx_pinsrd_instruction-instruction_handler + db 'vpinsrq',22h + dw avx_pinsrq_instruction-instruction_handler + db 'vpinsrw',0C4h + dw avx_pinsrw_instruction-instruction_handler + db 'vpmaxsb',3Ch + dw avx_128bit_instruction_38-instruction_handler + db 'vpmaxsd',3Dh + dw avx_128bit_instruction_38-instruction_handler + db 'vpmaxsw',0EEh + dw avx_128bit_instruction-instruction_handler + db 'vpmaxub',0DEh + dw avx_128bit_instruction-instruction_handler + db 'vpmaxud',3Fh + dw avx_128bit_instruction_38-instruction_handler + db 'vpmaxuw',3Eh + dw avx_128bit_instruction_38-instruction_handler + db 'vpminsb',38h + dw avx_128bit_instruction_38-instruction_handler + db 'vpminsd',39h + dw avx_128bit_instruction_38-instruction_handler + db 'vpminsw',0EAh + dw avx_128bit_instruction-instruction_handler + db 'vpminub',0DAh + dw avx_128bit_instruction-instruction_handler + db 'vpminud',3Bh + dw avx_128bit_instruction_38-instruction_handler + db 'vpminuw',3Ah + dw avx_128bit_instruction_38-instruction_handler + db 'vpmuldq',28h + dw avx_128bit_instruction_38-instruction_handler + db 'vpmulhw',0E5h + dw avx_128bit_instruction-instruction_handler + db 'vpmulld',40h + dw avx_128bit_instruction_38-instruction_handler + db 'vpmullw',0D5h + dw avx_128bit_instruction-instruction_handler + db 'vpsadbw',0F6h + dw avx_128bit_instruction-instruction_handler + db 'vpshufb',0 + dw avx_128bit_instruction_38-instruction_handler + db 'vpshufd',66h + dw avx_pshufd_instruction-instruction_handler + db 'vpsignb',8 + dw avx_128bit_instruction_38-instruction_handler + db 'vpsignd',0Ah + dw avx_128bit_instruction_38-instruction_handler + db 'vpsignw',9 + dw avx_128bit_instruction_38-instruction_handler + db 'vpslldq',111b + dw avx_pslldq_instruction-instruction_handler + db 'vpsrldq',011b + dw avx_pslldq_instruction-instruction_handler + db 'vpsubsb',0E8h + dw avx_128bit_instruction-instruction_handler + db 'vpsubsw',0E9h + dw avx_128bit_instruction-instruction_handler + db 'vshufpd',0C6h + dw avx_pd_instruction_imm8-instruction_handler + db 'vshufps',0C6h + dw avx_ps_instruction_imm8-instruction_handler + db 'vsqrtpd',51h + dw avx_single_source_pd_instruction-instruction_handler + db 'vsqrtps',51h + dw avx_single_source_ps_instruction-instruction_handler + db 'vsqrtsd',51h + dw avx_sd_instruction-instruction_handler + db 'vsqrtss',51h + dw avx_ss_instruction-instruction_handler + db 'vtestpd',0Fh + dw avx_single_source_instruction_38-instruction_handler + db 'vtestps',0Eh + dw avx_single_source_instruction_38-instruction_handler + db 'xsave64',100b + dw fxsave_instruction_64bit-instruction_handler instructions_8: db 'addsubpd',0D0h dw sse_pd_instruction-instruction_handler @@ -1850,9 +2222,9 @@ instructions_8: db 'movntdqa',0 dw movntdqa_instruction-instruction_handler db 'movshdup',16h - dw cvtdq2pd_instruction-instruction_handler + dw movshdup_instruction-instruction_handler db 'movsldup',12h - dw cvtdq2pd_instruction-instruction_handler + dw movshdup_instruction-instruction_handler db 'packssdw',6Bh dw basic_mmx_instruction-instruction_handler db 'packsswb',63h @@ -1899,6 +2271,10 @@ instructions_8: dw ssse3_instruction-instruction_handler db 'prefetch',0 dw amd_prefetch_instruction-instruction_handler + db 'rdfsbase',0 + dw rdfsbase_instruction-instruction_handler + db 'rdgsbase',1 + dw rdfsbase_instruction-instruction_handler db 'sysenter',34h dw simple_extended_instruction-instruction_handler db 'sysexitq',35h @@ -1911,10 +2287,220 @@ instructions_8: dw sse_pd_instruction-instruction_handler db 'unpcklps',14h dw sse_ps_instruction-instruction_handler + db 'vblendpd',0Dh + dw avx_instruction_3a_imm8-instruction_handler + db 'vblendps',0Ch + dw avx_instruction_3a_imm8-instruction_handler + db 'vcmpeqpd',0 + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpeqps',0 + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpeqsd',0 + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpeqss',0 + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpgepd',0Dh + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpgeps',0Dh + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpgesd',0Dh + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpgess',0Dh + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpgtpd',0Eh + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpgtps',0Eh + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpgtsd',0Eh + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpgtss',0Eh + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmplepd',2 + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpleps',2 + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmplesd',2 + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpless',2 + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpltpd',1 + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpltps',1 + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpltsd',1 + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpltss',1 + dw avx_cmp_ss_instruction-instruction_handler + db 'vfmaddpd',69h + dw fma4_instruction_p-instruction_handler + db 'vfmaddps',68h + dw fma4_instruction_p-instruction_handler + db 'vfmaddsd',6Bh + dw fma4_instruction_sd-instruction_handler + db 'vfmaddss',6Ah + dw fma4_instruction_ss-instruction_handler + db 'vfmsubpd',6Dh + dw fma4_instruction_p-instruction_handler + db 'vfmsubps',6Ch + dw fma4_instruction_p-instruction_handler + db 'vfmsubsd',6Fh + dw fma4_instruction_sd-instruction_handler + db 'vfmsubss',6Eh + dw fma4_instruction_ss-instruction_handler + db 'vldmxcsr',10b + dw vldmxcsr_instruction-instruction_handler db 'vmlaunch',0C2h dw simple_vmx_instruction-instruction_handler + db 'vmovddup',12h + dw avx_movddup_instruction-instruction_handler + db 'vmovhlps',12h + dw avx_movhlps_instruction-instruction_handler + db 'vmovlhps',16h + dw avx_movhlps_instruction-instruction_handler + db 'vmovntdq',0E7h + dw avx_movntpd_instruction-instruction_handler + db 'vmovntpd',2Bh + dw avx_movntpd_instruction-instruction_handler + db 'vmovntps',2Bh + dw avx_movntps_instruction-instruction_handler + db 'vmpsadbw',42h + dw avx_128bit_instruction_3a_imm8-instruction_handler db 'vmresume',0C3h dw simple_vmx_instruction-instruction_handler + db 'vpaddusb',0DCh + dw avx_128bit_instruction-instruction_handler + db 'vpaddusw',0DDh + dw avx_128bit_instruction-instruction_handler + db 'vpalignr',0Fh + dw avx_128bit_instruction_3a_imm8-instruction_handler + db 'vpblendw',0Eh + dw avx_128bit_instruction_3a_imm8-instruction_handler + db 'vpcmpeqb',74h + dw avx_128bit_instruction-instruction_handler + db 'vpcmpeqd',76h + dw avx_128bit_instruction-instruction_handler + db 'vpcmpeqq',29h + dw avx_128bit_instruction_38-instruction_handler + db 'vpcmpeqw',75h + dw avx_128bit_instruction-instruction_handler + db 'vpcmpgtb',64h + dw avx_128bit_instruction-instruction_handler + db 'vpcmpgtd',66h + dw avx_128bit_instruction-instruction_handler + db 'vpcmpgtq',37h + dw avx_128bit_instruction_38-instruction_handler + db 'vpcmpgtw',65h + dw avx_128bit_instruction-instruction_handler + db 'vpcomeqb',4 + dw xop_pcom_b_instruction-instruction_handler + db 'vpcomeqd',4 + dw xop_pcom_d_instruction-instruction_handler + db 'vpcomeqq',4 + dw xop_pcom_q_instruction-instruction_handler + db 'vpcomeqw',4 + dw xop_pcom_w_instruction-instruction_handler + db 'vpcomgeb',3 + dw xop_pcom_b_instruction-instruction_handler + db 'vpcomged',3 + dw xop_pcom_d_instruction-instruction_handler + db 'vpcomgeq',3 + dw xop_pcom_q_instruction-instruction_handler + db 'vpcomgew',3 + dw xop_pcom_w_instruction-instruction_handler + db 'vpcomgtb',2 + dw xop_pcom_b_instruction-instruction_handler + db 'vpcomgtd',2 + dw xop_pcom_d_instruction-instruction_handler + db 'vpcomgtq',2 + dw xop_pcom_q_instruction-instruction_handler + db 'vpcomgtw',2 + dw xop_pcom_w_instruction-instruction_handler + db 'vpcomleb',1 + dw xop_pcom_b_instruction-instruction_handler + db 'vpcomled',1 + dw xop_pcom_d_instruction-instruction_handler + db 'vpcomleq',1 + dw xop_pcom_q_instruction-instruction_handler + db 'vpcomlew',1 + dw xop_pcom_w_instruction-instruction_handler + db 'vpcomltb',0 + dw xop_pcom_b_instruction-instruction_handler + db 'vpcomltd',0 + dw xop_pcom_d_instruction-instruction_handler + db 'vpcomltq',0 + dw xop_pcom_q_instruction-instruction_handler + db 'vpcomltw',0 + dw xop_pcom_w_instruction-instruction_handler + db 'vphaddbd',0C2h + dw xop_single_source_128bit_instruction-instruction_handler + db 'vphaddbq',0C3h + dw xop_single_source_128bit_instruction-instruction_handler + db 'vphaddbw',0C1h + dw xop_single_source_128bit_instruction-instruction_handler + db 'vphadddq',0CBh + dw xop_single_source_128bit_instruction-instruction_handler + db 'vphaddsw',3 + dw avx_128bit_instruction_38-instruction_handler + db 'vphaddwd',0C6h + dw xop_single_source_128bit_instruction-instruction_handler + db 'vphaddwq',0C7h + dw xop_single_source_128bit_instruction-instruction_handler + db 'vphsubbw',0E1h + dw xop_single_source_128bit_instruction-instruction_handler + db 'vphsubdq',0E3h + dw xop_single_source_128bit_instruction-instruction_handler + db 'vphsubsw',7 + dw avx_128bit_instruction_38-instruction_handler + db 'vphsubwd',0E2h + dw xop_single_source_128bit_instruction-instruction_handler + db 'vpmacsdd',9Eh + dw xop_triple_source_128bit_instruction-instruction_handler + db 'vpmacswd',96h + dw xop_triple_source_128bit_instruction-instruction_handler + db 'vpmacsww',95h + dw xop_triple_source_128bit_instruction-instruction_handler + db 'vpmaddwd',0F5h + dw avx_128bit_instruction-instruction_handler + db 'vpmulhuw',0E4h + dw avx_128bit_instruction-instruction_handler + db 'vpmuludq',0F4h + dw avx_128bit_instruction-instruction_handler + db 'vpshufhw',0F3h + dw avx_pshufd_instruction-instruction_handler + db 'vpshuflw',0F2h + dw avx_pshufd_instruction-instruction_handler + db 'vpsubusb',0D8h + dw avx_128bit_instruction-instruction_handler + db 'vpsubusw',0D9h + dw avx_128bit_instruction-instruction_handler + db 'vroundpd',9 + dw avx_single_source_instruction_3a_imm8-instruction_handler + db 'vroundps',8 + dw avx_single_source_instruction_3a_imm8-instruction_handler + db 'vroundsd',0Bh + dw avx_sd_instruction_3a_imm8-instruction_handler + db 'vroundss',0Ah + dw avx_ss_instruction_3a_imm8-instruction_handler + db 'vrsqrtps',52h + dw avx_single_source_ps_instruction-instruction_handler + db 'vrsqrtss',52h + dw avx_ss_instruction-instruction_handler + db 'vstmxcsr',11b + dw vldmxcsr_instruction-instruction_handler + db 'vucomisd',2Eh + dw avx_comisd_instruction-instruction_handler + db 'vucomiss',2Eh + dw avx_comiss_instruction-instruction_handler + db 'vzeroall',77h + dw vzeroall_instruction-instruction_handler + db 'wrfsbase',2 + dw rdfsbase_instruction-instruction_handler + db 'wrgsbase',3 + dw rdfsbase_instruction-instruction_handler + db 'xrstor64',101b + dw fxsave_instruction_64bit-instruction_handler + db 'xsaveopt',110b + dw fxsave_instruction-instruction_handler instructions_9: db 'cmpxchg8b',8 dw cmpxchgx_instruction-instruction_handler @@ -1923,7 +2509,7 @@ instructions_9: db 'cvttpd2pi',2Ch dw cvtpd2pi_instruction-instruction_handler db 'cvttps2dq',5Bh - dw cvtdq2pd_instruction-instruction_handler + dw movshdup_instruction-instruction_handler db 'cvttps2pi',2Ch dw cvtps2pi_instruction-instruction_handler db 'cvttsd2si',2Ch @@ -1932,6 +2518,8 @@ instructions_9: dw cvtss2si_instruction-instruction_handler db 'extractps',0 dw extractps_instruction-instruction_handler + db 'pclmulqdq',-1 + dw pclmulqdq_instruction-instruction_handler db 'pcmpestri',61h dw sse4_instruction_3a_imm8-instruction_handler db 'pcmpestrm',60h @@ -1956,7 +2544,245 @@ instructions_9: dw basic_mmx_instruction-instruction_handler db 'punpcklwd',61h dw basic_mmx_instruction-instruction_handler + db 'vaddsubpd',0D0h + dw avx_pd_instruction-instruction_handler + db 'vaddsubps',0D0h + dw avx_haddps_instruction-instruction_handler + db 'vblendvpd',4Bh + dw avx_triple_source_instruction_3a-instruction_handler + db 'vblendvps',4Ah + dw avx_triple_source_instruction_3a-instruction_handler + db 'vcmpneqpd',4 + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpneqps',4 + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpneqsd',4 + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpneqss',4 + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpngepd',9 + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpngeps',9 + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpngesd',9 + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpngess',9 + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpngtpd',0Ah + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpngtps',0Ah + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpngtsd',0Ah + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpngtss',0Ah + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpnlepd',6 + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpnleps',6 + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpnlesd',6 + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpnless',6 + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpnltpd',5 + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpnltps',5 + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpnltsd',5 + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpnltss',5 + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpordpd',7 + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpordps',7 + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpordsd',7 + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpordss',7 + dw avx_cmp_ss_instruction-instruction_handler + db 'vcvtdq2pd',0E6h + dw avx_cvtdq2pd_instruction-instruction_handler + db 'vcvtdq2ps',5Bh + dw avx_single_source_ps_instruction-instruction_handler + db 'vcvtpd2dq',0E6h + dw avx_cvtpd2dq_instruction-instruction_handler + db 'vcvtpd2ps',5Ah + dw avx_cvtpd2ps_instruction-instruction_handler + db 'vcvtph2ps',13h + dw vcvtph2ps_instruction-instruction_handler + db 'vcvtps2dq',5Bh + dw avx_single_source_pd_instruction-instruction_handler + db 'vcvtps2pd',5Ah + dw avx_cvtps2pd_instruction-instruction_handler + db 'vcvtps2ph',1Dh + dw vcvtps2ph_instruction-instruction_handler + db 'vcvtsd2si',2Dh + dw avx_cvtsd2si_instruction-instruction_handler + db 'vcvtsd2ss',5Ah + dw avx_sd_instruction-instruction_handler + db 'vcvtsi2sd',2Ah + dw avx_cvtsi2sd_instruction-instruction_handler + db 'vcvtsi2ss',2Ah + dw avx_cvtsi2ss_instruction-instruction_handler + db 'vcvtss2sd',5Ah + dw avx_ss_instruction-instruction_handler + db 'vcvtss2si',2Dh + dw avx_cvtss2si_instruction-instruction_handler + db 'vfnmaddpd',79h + dw fma4_instruction_p-instruction_handler + db 'vfnmaddps',78h + dw fma4_instruction_p-instruction_handler + db 'vfnmaddsd',7Bh + dw fma4_instruction_sd-instruction_handler + db 'vfnmaddss',7Ah + dw fma4_instruction_ss-instruction_handler + db 'vfnmsubpd',7Dh + dw fma4_instruction_p-instruction_handler + db 'vfnmsubps',7Ch + dw fma4_instruction_p-instruction_handler + db 'vfnmsubsd',7Fh + dw fma4_instruction_sd-instruction_handler + db 'vfnmsubss',7Eh + dw fma4_instruction_ss-instruction_handler + db 'vinsertps',0 + dw avx_insertps_instruction-instruction_handler + db 'vmovmskpd',0 + dw avx_movmskpd_instruction-instruction_handler + db 'vmovmskps',0 + dw avx_movmskps_instruction-instruction_handler + db 'vmovntdqa',0 + dw avx_movntdqa_instruction-instruction_handler + db 'vmovshdup',16h + dw avx_movshdup_instruction-instruction_handler + db 'vmovsldup',12h + dw avx_movshdup_instruction-instruction_handler + db 'vpackssdw',6Bh + dw avx_128bit_instruction-instruction_handler + db 'vpacksswb',63h + dw avx_128bit_instruction-instruction_handler + db 'vpackusdw',2Bh + dw avx_128bit_instruction_38-instruction_handler + db 'vpackuswb',67h + dw avx_128bit_instruction-instruction_handler + db 'vpblendvb',4Ch + dw avx_triple_source_128bit_instruction_3a-instruction_handler + db 'vpcomequb',4 + dw xop_pcom_ub_instruction-instruction_handler + db 'vpcomequd',4 + dw xop_pcom_ud_instruction-instruction_handler + db 'vpcomequq',4 + dw xop_pcom_uq_instruction-instruction_handler + db 'vpcomequw',4 + dw xop_pcom_uw_instruction-instruction_handler + db 'vpcomgeub',3 + dw xop_pcom_ub_instruction-instruction_handler + db 'vpcomgeud',3 + dw xop_pcom_ud_instruction-instruction_handler + db 'vpcomgeuq',3 + dw xop_pcom_uq_instruction-instruction_handler + db 'vpcomgeuw',3 + dw xop_pcom_uw_instruction-instruction_handler + db 'vpcomgtub',2 + dw xop_pcom_ub_instruction-instruction_handler + db 'vpcomgtud',2 + dw xop_pcom_ud_instruction-instruction_handler + db 'vpcomgtuq',2 + dw xop_pcom_uq_instruction-instruction_handler + db 'vpcomgtuw',2 + dw xop_pcom_uw_instruction-instruction_handler + db 'vpcomleub',1 + dw xop_pcom_ub_instruction-instruction_handler + db 'vpcomleud',1 + dw xop_pcom_ud_instruction-instruction_handler + db 'vpcomleuq',1 + dw xop_pcom_uq_instruction-instruction_handler + db 'vpcomleuw',1 + dw xop_pcom_uw_instruction-instruction_handler + db 'vpcomltub',0 + dw xop_pcom_ub_instruction-instruction_handler + db 'vpcomltud',0 + dw xop_pcom_ud_instruction-instruction_handler + db 'vpcomltuq',0 + dw xop_pcom_uq_instruction-instruction_handler + db 'vpcomltuw',0 + dw xop_pcom_uw_instruction-instruction_handler + db 'vpcomneqb',5 + dw xop_pcom_b_instruction-instruction_handler + db 'vpcomneqd',5 + dw xop_pcom_d_instruction-instruction_handler + db 'vpcomneqq',5 + dw xop_pcom_q_instruction-instruction_handler + db 'vpcomneqw',5 + dw xop_pcom_w_instruction-instruction_handler + db 'vpermilpd',5 + dw avx_permil_instruction-instruction_handler + db 'vpermilps',4 + dw avx_permil_instruction-instruction_handler + db 'vphaddubd',0D2h + dw xop_single_source_128bit_instruction-instruction_handler + db 'vphaddubq',0D3h + dw xop_single_source_128bit_instruction-instruction_handler + db 'vphaddubw',0D1h + dw xop_single_source_128bit_instruction-instruction_handler + db 'vphaddudq',0DBh + dw xop_single_source_128bit_instruction-instruction_handler + db 'vphadduwd',0D6h + dw xop_single_source_128bit_instruction-instruction_handler + db 'vphadduwq',0D7h + dw xop_single_source_128bit_instruction-instruction_handler + db 'vpmacsdqh',9Fh + dw xop_triple_source_128bit_instruction-instruction_handler + db 'vpmacsdql',97h + dw xop_triple_source_128bit_instruction-instruction_handler + db 'vpmacssdd',8Eh + dw xop_triple_source_128bit_instruction-instruction_handler + db 'vpmacsswd',86h + dw xop_triple_source_128bit_instruction-instruction_handler + db 'vpmacssww',85h + dw xop_triple_source_128bit_instruction-instruction_handler + db 'vpmadcswd',0B6h + dw xop_triple_source_128bit_instruction-instruction_handler + db 'vpmovmskb',0D7h + dw avx_pmovmskb_instruction-instruction_handler + db 'vpmovsxbd',21h + dw avx_pmovsxbd_instruction-instruction_handler + db 'vpmovsxbq',22h + dw avx_pmovsxbq_instruction-instruction_handler + db 'vpmovsxbw',20h + dw avx_pmovsxbw_instruction-instruction_handler + db 'vpmovsxdq',25h + dw avx_pmovsxdq_instruction-instruction_handler + db 'vpmovsxwd',23h + dw avx_pmovsxwd_instruction-instruction_handler + db 'vpmovsxwq',24h + dw avx_pmovsxwq_instruction-instruction_handler + db 'vpmovzxbd',31h + dw avx_pmovsxbd_instruction-instruction_handler + db 'vpmovzxbq',32h + dw avx_pmovsxbq_instruction-instruction_handler + db 'vpmovzxbw',30h + dw avx_pmovsxbw_instruction-instruction_handler + db 'vpmovzxdq',35h + dw avx_pmovsxdq_instruction-instruction_handler + db 'vpmovzxwd',33h + dw avx_pmovsxwd_instruction-instruction_handler + db 'vpmovzxwq',34h + dw avx_pmovsxwq_instruction-instruction_handler + db 'vpmulhrsw',0Bh + dw avx_128bit_instruction_38-instruction_handler + db 'vunpckhpd',15h + dw avx_pd_instruction-instruction_handler + db 'vunpckhps',15h + dw avx_instruction-instruction_handler + db 'vunpcklpd',14h + dw avx_pd_instruction-instruction_handler + db 'vunpcklps',14h + dw avx_instruction-instruction_handler instructions_10: + db 'aesdeclast',0DFh + dw sse4_instruction_38-instruction_handler + db 'aesenclast',0DDh + dw sse4_instruction_38-instruction_handler db 'cmpunordpd',3 dw cmp_pd_instruction-instruction_handler db 'cmpunordps',3 @@ -1985,9 +2811,458 @@ instructions_10: dw sse_pd_instruction-instruction_handler db 'punpcklqdq',6Ch dw sse_pd_instruction-instruction_handler + db 'vcmptruepd',0Fh + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmptrueps',0Fh + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmptruesd',0Fh + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmptruess',0Fh + dw avx_cmp_ss_instruction-instruction_handler + db 'vcvttpd2dq',0E6h + dw avx_cvtpd2ps_instruction-instruction_handler + db 'vcvttps2dq',5Bh + dw avx_cvttps2dq_instruction-instruction_handler + db 'vcvttsd2si',2Ch + dw avx_cvtsd2si_instruction-instruction_handler + db 'vcvttss2si',2Ch + dw avx_cvtss2si_instruction-instruction_handler + db 'vextractps',0 + dw avx_extractps_instruction-instruction_handler + db 'vmaskmovpd',2Dh + dw avx_maskmov_instruction-instruction_handler + db 'vmaskmovps',2Ch + dw avx_maskmov_instruction-instruction_handler + db 'vpclmulqdq',-1 + dw avx_pclmulqdq_instruction-instruction_handler + db 'vpcmpestri',61h + dw avx_single_source_128bit_instruction_3a_imm8-instruction_handler + db 'vpcmpestrm',60h + dw avx_single_source_128bit_instruction_3a_imm8-instruction_handler + db 'vpcmpistri',63h + dw avx_single_source_128bit_instruction_3a_imm8-instruction_handler + db 'vpcmpistrm',62h + dw avx_single_source_128bit_instruction_3a_imm8-instruction_handler + db 'vpcomnequb',5 + dw xop_pcom_ub_instruction-instruction_handler + db 'vpcomnequd',5 + dw xop_pcom_ud_instruction-instruction_handler + db 'vpcomnequq',5 + dw xop_pcom_uq_instruction-instruction_handler + db 'vpcomnequw',5 + dw xop_pcom_uw_instruction-instruction_handler + db 'vpcomtrueb',7 + dw xop_pcom_b_instruction-instruction_handler + db 'vpcomtrued',7 + dw xop_pcom_d_instruction-instruction_handler + db 'vpcomtrueq',7 + dw xop_pcom_q_instruction-instruction_handler + db 'vpcomtruew',7 + dw xop_pcom_w_instruction-instruction_handler + db 'vperm2f128',6 + dw avx_perm2f128_instruction-instruction_handler + db 'vpermil2pd',49h + dw vpermil2_instruction-instruction_handler + db 'vpermil2ps',48h + dw vpermil2_instruction-instruction_handler + db 'vpmacssdqh',8Fh + dw xop_triple_source_128bit_instruction-instruction_handler + db 'vpmacssdql',87h + dw xop_triple_source_128bit_instruction-instruction_handler + db 'vpmadcsswd',0A6h + dw xop_triple_source_128bit_instruction-instruction_handler + db 'vpmaddubsw',4 + dw avx_128bit_instruction_38-instruction_handler + db 'vpunpckhbw',68h + dw avx_128bit_instruction-instruction_handler + db 'vpunpckhdq',6Ah + dw avx_128bit_instruction-instruction_handler + db 'vpunpckhwd',69h + dw avx_128bit_instruction-instruction_handler + db 'vpunpcklbw',60h + dw avx_128bit_instruction-instruction_handler + db 'vpunpckldq',62h + dw avx_128bit_instruction-instruction_handler + db 'vpunpcklwd',61h + dw avx_128bit_instruction-instruction_handler + db 'vzeroupper',77h + dw vzeroupper_instruction-instruction_handler + db 'xsaveopt64',110b + dw fxsave_instruction_64bit-instruction_handler instructions_11: + db 'pclmulhqhdq',10001b + dw pclmulqdq_instruction-instruction_handler + db 'pclmullqhdq',10000b + dw pclmulqdq_instruction-instruction_handler db 'prefetchnta',0 dw prefetch_instruction-instruction_handler + db 'vaesdeclast',0DFh + dw avx_128bit_instruction_38-instruction_handler + db 'vaesenclast',0DDh + dw avx_128bit_instruction_38-instruction_handler + db 'vcmpeq_ospd',10h + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpeq_osps',10h + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpeq_ossd',10h + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpeq_osss',10h + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpeq_uqpd',8 + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpeq_uqps',8 + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpeq_uqsd',8 + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpeq_uqss',8 + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpeq_uspd',18h + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpeq_usps',18h + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpeq_ussd',18h + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpeq_usss',18h + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpfalsepd',0Bh + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpfalseps',0Bh + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpfalsesd',0Bh + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpfalsess',0Bh + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpge_oqpd',1Dh + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpge_oqps',1Dh + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpge_oqsd',1Dh + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpge_oqss',1Dh + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpgt_oqpd',1Eh + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpgt_oqps',1Eh + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpgt_oqsd',1Eh + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpgt_oqss',1Eh + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmple_oqpd',12h + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmple_oqps',12h + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmple_oqsd',12h + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmple_oqss',12h + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmplt_oqpd',11h + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmplt_oqps',11h + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmplt_oqsd',11h + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmplt_oqss',11h + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpord_spd',17h + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpord_sps',17h + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpord_ssd',17h + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpord_sss',17h + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpunordpd',3 + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpunordps',3 + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpunordsd',3 + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpunordss',3 + dw avx_cmp_ss_instruction-instruction_handler + db 'vfmadd132pd',98h + dw fma_instruction_pd-instruction_handler + db 'vfmadd132ps',98h + dw fma_instruction_ps-instruction_handler + db 'vfmadd132sd',99h + dw fma_instruction_sd-instruction_handler + db 'vfmadd132ss',99h + dw fma_instruction_ss-instruction_handler + db 'vfmadd213pd',0A8h + dw fma_instruction_pd-instruction_handler + db 'vfmadd213ps',0A8h + dw fma_instruction_ps-instruction_handler + db 'vfmadd213sd',0A9h + dw fma_instruction_sd-instruction_handler + db 'vfmadd213ss',0A9h + dw fma_instruction_ss-instruction_handler + db 'vfmadd231pd',0B8h + dw fma_instruction_pd-instruction_handler + db 'vfmadd231ps',0B8h + dw fma_instruction_ps-instruction_handler + db 'vfmadd231sd',0B9h + dw fma_instruction_sd-instruction_handler + db 'vfmadd231ss',0B9h + dw fma_instruction_ss-instruction_handler + db 'vfmaddsubpd',5Dh + dw fma4_instruction_p-instruction_handler + db 'vfmaddsubps',5Ch + dw fma4_instruction_p-instruction_handler + db 'vfmsub132pd',9Ah + dw fma_instruction_pd-instruction_handler + db 'vfmsub132ps',9Ah + dw fma_instruction_ps-instruction_handler + db 'vfmsub132sd',9Bh + dw fma_instruction_sd-instruction_handler + db 'vfmsub132ss',9Bh + dw fma_instruction_ss-instruction_handler + db 'vfmsub213pd',0AAh + dw fma_instruction_pd-instruction_handler + db 'vfmsub213ps',0AAh + dw fma_instruction_ps-instruction_handler + db 'vfmsub213sd',0ABh + dw fma_instruction_sd-instruction_handler + db 'vfmsub213ss',0ABh + dw fma_instruction_ss-instruction_handler + db 'vfmsub231pd',0BAh + dw fma_instruction_pd-instruction_handler + db 'vfmsub231ps',0BAh + dw fma_instruction_ps-instruction_handler + db 'vfmsub231sd',0BBh + dw fma_instruction_sd-instruction_handler + db 'vfmsub231ss',0BBh + dw fma_instruction_ss-instruction_handler + db 'vfmsubaddpd',5Fh + dw fma4_instruction_p-instruction_handler + db 'vfmsubaddps',5Eh + dw fma4_instruction_p-instruction_handler + db 'vinsertf128',18h + dw avx_insertf128_instruction-instruction_handler + db 'vmaskmovdqu',0 + dw avx_maskmovdqu_instruction-instruction_handler + db 'vpcomfalseb',6 + dw xop_pcom_b_instruction-instruction_handler + db 'vpcomfalsed',6 + dw xop_pcom_d_instruction-instruction_handler + db 'vpcomfalseq',6 + dw xop_pcom_q_instruction-instruction_handler + db 'vpcomfalsew',6 + dw xop_pcom_w_instruction-instruction_handler + db 'vpcomtrueub',7 + dw xop_pcom_ub_instruction-instruction_handler + db 'vpcomtrueud',7 + dw xop_pcom_ud_instruction-instruction_handler + db 'vpcomtrueuq',7 + dw xop_pcom_uq_instruction-instruction_handler + db 'vpcomtrueuw',7 + dw xop_pcom_uw_instruction-instruction_handler + db 'vphminposuw',41h + dw avx_single_source_128bit_instruction_38-instruction_handler + db 'vpunpckhqdq',6Dh + dw avx_128bit_instruction-instruction_handler + db 'vpunpcklqdq',6Ch + dw avx_128bit_instruction-instruction_handler +instructions_12: + db 'pclmulhqlqdq',1 + dw pclmulqdq_instruction-instruction_handler + db 'pclmullqlqdq',0 + dw pclmulqdq_instruction-instruction_handler + db 'vbroadcastsd',0 + dw avx_broadcastsd_instruction-instruction_handler + db 'vbroadcastss',0 + dw avx_broadcastss_instruction-instruction_handler + db 'vcmpneq_oqpd',0Ch + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpneq_oqps',0Ch + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpneq_oqsd',0Ch + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpneq_oqss',0Ch + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpneq_ospd',1Ch + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpneq_osps',1Ch + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpneq_ossd',1Ch + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpneq_osss',1Ch + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpneq_uspd',14h + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpneq_usps',14h + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpneq_ussd',14h + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpneq_usss',14h + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpnge_uqpd',19h + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpnge_uqps',19h + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpnge_uqsd',19h + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpnge_uqss',19h + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpngt_uqpd',1Ah + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpngt_uqps',1Ah + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpngt_uqsd',1Ah + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpngt_uqss',1Ah + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpnle_uqpd',16h + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpnle_uqps',16h + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpnle_uqsd',16h + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpnle_uqss',16h + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpnlt_uqpd',15h + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpnlt_uqps',15h + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpnlt_uqsd',15h + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpnlt_uqss',15h + dw avx_cmp_ss_instruction-instruction_handler + db 'vextractf128',19h + dw avx_extractf128_instruction-instruction_handler + db 'vfnmadd132pd',9Ch + dw fma_instruction_pd-instruction_handler + db 'vfnmadd132ps',9Ch + dw fma_instruction_ps-instruction_handler + db 'vfnmadd132sd',9Dh + dw fma_instruction_sd-instruction_handler + db 'vfnmadd132ss',9Dh + dw fma_instruction_ss-instruction_handler + db 'vfnmadd213pd',0ACh + dw fma_instruction_pd-instruction_handler + db 'vfnmadd213ps',0ACh + dw fma_instruction_ps-instruction_handler + db 'vfnmadd213sd',0ADh + dw fma_instruction_sd-instruction_handler + db 'vfnmadd213ss',0ADh + dw fma_instruction_ss-instruction_handler + db 'vfnmadd231pd',0BCh + dw fma_instruction_pd-instruction_handler + db 'vfnmadd231ps',0BCh + dw fma_instruction_ps-instruction_handler + db 'vfnmadd231sd',0BDh + dw fma_instruction_sd-instruction_handler + db 'vfnmadd231ss',0BDh + dw fma_instruction_ss-instruction_handler + db 'vfnmsub132pd',9Eh + dw fma_instruction_pd-instruction_handler + db 'vfnmsub132ps',9Eh + dw fma_instruction_ps-instruction_handler + db 'vfnmsub132sd',9Fh + dw fma_instruction_sd-instruction_handler + db 'vfnmsub132ss',9Fh + dw fma_instruction_ss-instruction_handler + db 'vfnmsub213pd',0AEh + dw fma_instruction_pd-instruction_handler + db 'vfnmsub213ps',0AEh + dw fma_instruction_ps-instruction_handler + db 'vfnmsub213sd',0AFh + dw fma_instruction_sd-instruction_handler + db 'vfnmsub213ss',0AFh + dw fma_instruction_ss-instruction_handler + db 'vfnmsub231pd',0BEh + dw fma_instruction_pd-instruction_handler + db 'vfnmsub231ps',0BEh + dw fma_instruction_ps-instruction_handler + db 'vfnmsub231sd',0BFh + dw fma_instruction_sd-instruction_handler + db 'vfnmsub231ss',0BFh + dw fma_instruction_ss-instruction_handler + db 'vpclmulhqhdq',10001b + dw avx_pclmulqdq_instruction-instruction_handler + db 'vpclmullqhdq',10000b + dw avx_pclmulqdq_instruction-instruction_handler + db 'vpcomfalseub',6 + dw xop_pcom_ub_instruction-instruction_handler + db 'vpcomfalseud',6 + dw xop_pcom_ud_instruction-instruction_handler + db 'vpcomfalseuq',6 + dw xop_pcom_uq_instruction-instruction_handler + db 'vpcomfalseuw',6 + dw xop_pcom_uw_instruction-instruction_handler + db 'vpermilmo2pd',10b + dw vpermil_2pd_instruction-instruction_handler + db 'vpermilmo2ps',10b + dw vpermil_2ps_instruction-instruction_handler + db 'vpermilmz2pd',11b + dw vpermil_2pd_instruction-instruction_handler + db 'vpermilmz2ps',11b + dw vpermil_2ps_instruction-instruction_handler + db 'vpermiltd2pd',0 + dw vpermil_2pd_instruction-instruction_handler + db 'vpermiltd2ps',0 + dw vpermil_2ps_instruction-instruction_handler +instructions_13: + db 'vcmptrue_uspd',1Fh + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmptrue_usps',1Fh + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmptrue_ussd',1Fh + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmptrue_usss',1Fh + dw avx_cmp_ss_instruction-instruction_handler + db 'vcmpunord_spd',13h + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpunord_sps',13h + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpunord_ssd',13h + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpunord_sss',13h + dw avx_cmp_ss_instruction-instruction_handler + db 'vpclmulhqlqdq',1 + dw avx_pclmulqdq_instruction-instruction_handler + db 'vpclmullqlqdq',0 + dw avx_pclmulqdq_instruction-instruction_handler +instructions_14: + db 'vbroadcastf128',0 + dw avx_broadcastf128_instruction-instruction_handler + db 'vcmpfalse_ospd',1Bh + dw avx_cmp_pd_instruction-instruction_handler + db 'vcmpfalse_osps',1Bh + dw avx_cmp_ps_instruction-instruction_handler + db 'vcmpfalse_ossd',1Bh + dw avx_cmp_sd_instruction-instruction_handler + db 'vcmpfalse_osss',1Bh + dw avx_cmp_ss_instruction-instruction_handler + db 'vfmaddsub132pd',96h + dw fma_instruction_pd-instruction_handler + db 'vfmaddsub132ps',96h + dw fma_instruction_ps-instruction_handler + db 'vfmaddsub213pd',0A6h + dw fma_instruction_pd-instruction_handler + db 'vfmaddsub213ps',0A6h + dw fma_instruction_ps-instruction_handler + db 'vfmaddsub231pd',0B6h + dw fma_instruction_pd-instruction_handler + db 'vfmaddsub231ps',0B6h + dw fma_instruction_ps-instruction_handler + db 'vfmsubadd132pd',97h + dw fma_instruction_pd-instruction_handler + db 'vfmsubadd132ps',97h + dw fma_instruction_ps-instruction_handler + db 'vfmsubadd213pd',0A7h + dw fma_instruction_pd-instruction_handler + db 'vfmsubadd213ps',0A7h + dw fma_instruction_ps-instruction_handler + db 'vfmsubadd231pd',0B7h + dw fma_instruction_pd-instruction_handler + db 'vfmsubadd231ps',0B7h + dw fma_instruction_ps-instruction_handler +instructions_15: + db 'aeskeygenassist',0DFh + dw sse4_instruction_3a_imm8-instruction_handler +instructions_16: + db 'vaeskeygenassist',0DFh + dw avx_single_source_128bit_instruction_3a_imm8-instruction_handler instructions_end: data_directives: diff --git a/programs/develop/fasm/trunk/variable.inc b/programs/develop/fasm/trunk/variable.inc index 0c8562d84..6ef359b8c 100644 --- a/programs/develop/fasm/trunk/variable.inc +++ b/programs/develop/fasm/trunk/variable.inc @@ -1,6 +1,6 @@ ; flat assembler core variables -; Copyright (c) 1999-2009, Tomasz Grysztar. +; Copyright (c) 1999-2011, Tomasz Grysztar. ; All rights reserved. ; Variables which have to be set up by interface: @@ -86,44 +86,54 @@ image_base dd ? image_base_high dd ? resource_data dd ? resource_size dd ? +actual_fixups_size dd ? +reserved_fixups dd ? +reserved_fixups_size dd ? +last_fixup_base dd ? parenthesis_stack dd ? blocks_stack dd ? parsed_lines dd ? logical_value_parentheses dd ? file_extension dd ? -labels_type db ? -code_type db ? -virtual_data db ? - operand_size db ? size_override db ? operand_prefix db ? -rex_prefix db ? opcode_prefix db ? +rex_prefix db ? +vex_required db ? +vex_register db ? +immediate_size db ? + base_code db ? extended_code db ? supplemental_code db ? postbyte_register db ? +segment_register db ? +xop_opcode_map db ? -immediate_size db ? mmx_size db ? jump_type db ? push_size db ? value_size db ? address_size db ? size_declared db ? + value_undefined db ? value_type db ? +fp_sign db ? +fp_format db ? compare_type db ? logical_value_wrapping db ? next_pass_needed db ? -macro_status db ? -segment_register db ? -prefixed_instruction db ? -fp_sign db ? -fp_format db ? output_format db ? +labels_type db ? +code_type db ? +virtual_data db ? + +macro_status db ? +prefixed_instruction db ? +formatter_symbols_allowed db ? characters rb 100h converted rb 100h diff --git a/programs/develop/fasm/trunk/version.inc b/programs/develop/fasm/trunk/version.inc index c1af753f5..a1288459c 100644 --- a/programs/develop/fasm/trunk/version.inc +++ b/programs/develop/fasm/trunk/version.inc @@ -1,6 +1,6 @@ -; flat assembler version 1.68 -; Copyright (c) 1999-2009, Tomasz Grysztar. +; flat assembler version 1.69 +; Copyright (c) 1999-2011, Tomasz Grysztar. ; All rights reserved. ; ; This programs is free for commercial and non-commercial use as long as @@ -33,7 +33,7 @@ ; cannot simply be copied and put under another distribution licence ; (including the GNU Public Licence). -VERSION_STRING equ "1.69.11" +VERSION_STRING equ "1.69.34" VERSION_MAJOR = 1 VERSION_MINOR = 69 diff --git a/programs/develop/fasm/trunk/x86_64.inc b/programs/develop/fasm/trunk/x86_64.inc index 810b98dff..11c4a328f 100644 --- a/programs/develop/fasm/trunk/x86_64.inc +++ b/programs/develop/fasm/trunk/x86_64.inc @@ -1,6 +1,6 @@ ; flat assembler core -; Copyright (c) 1999-2009, Tomasz Grysztar. +; Copyright (c) 1999-2011, Tomasz Grysztar. ; All rights reserved. simple_instruction_except64: @@ -34,6 +34,9 @@ simple_instruction_32bit: je size_prefix stos byte [edi] jmp instruction_assembled +iret_instruction: + cmp [code_type],64 + jne simple_instruction simple_instruction_64bit: cmp [code_type],64 jne illegal_instruction @@ -73,15 +76,15 @@ int_instruction: cmp al,'(' jne invalid_operand call get_byte_value + cmp [next_pass_needed],0 + jne int_imm_ok + test eax,eax + js value_out_of_range + int_imm_ok: mov ah,al mov al,0CDh stos word [edi] jmp instruction_assembled -iret_instruction: - cmp [code_type],64 - jne simple_instruction - call operand_64bit - jmp simple_instruction aa_instruction: cmp [code_type],64 je illegal_instruction @@ -1824,6 +1827,8 @@ enter_instruction: jne enter_imm16_ok cmp [value_type],0 jne invalid_use_of_symbol + test eax,eax + js value_out_of_range enter_imm16_ok: push eax mov [operand_size],0 @@ -1840,6 +1845,11 @@ enter_instruction: cmp al,'(' jne invalid_operand call get_byte_value + cmp [next_pass_needed],0 + jne enter_imm8_ok + test eax,eax + js value_out_of_range + enter_imm8_ok: mov dl,al pop ebx mov al,0C8h @@ -1890,6 +1900,8 @@ ret_instruction: jne ret_imm_ok cmp [value_type],0 jne invalid_use_of_symbol + test eax,eax + js value_out_of_range ret_imm_ok: cmp [size_declared],0 jne ret_imm_store @@ -3170,6 +3182,10 @@ conditional_jump: conditional_jump_32bit_store: mov edx,eax sub edx,4 + jno conditional_jump_32bit_range_ok + cmp [code_type],64 + je relative_jump_out_of_range + conditional_jump_32bit_range_ok: mov ah,[base_code] add ah,10h mov al,0Fh @@ -3209,7 +3225,7 @@ conditional_jump: cmp [value_type],0 jne invalid_use_of_symbol mov edx,eax - sub edx,2 + sub dx,2 mov ah,[base_code] add ah,10h mov al,0Fh @@ -3271,6 +3287,7 @@ loop_instruction: make_loop_jump: call check_for_short_jump jc conditional_jump_short + scas word [edi] jmp jump_out_of_range loop_counter_size: cmp [operand_prefix],0 @@ -3749,6 +3766,9 @@ invlpg_instruction: call get_address jmp instruction_ready swapgs_instruction: + cmp [code_type],64 + jne illegal_instruction +rdtscp_instruction: mov [base_code],0Fh mov [extended_code],1 mov [postbyte_register],7 @@ -4346,7 +4366,7 @@ basic_mmx_instruction: call convert_mmx_register mov bl,al jmp nomem_instruction_ready -mmx_ps_instruction: +mmx_bit_shift_instruction: mov [base_code],0Fh mov [extended_code],al lods byte [esi] @@ -4422,7 +4442,8 @@ pmovmskb_instruction: jmp nomem_instruction_ready mmx_imm8: push ebx ecx edx - mov [operand_size],0 + xor cl,cl + xchg cl,[operand_size] lods byte [esi] cmp al,',' jne invalid_operand @@ -4430,6 +4451,7 @@ pmovmskb_instruction: call get_size_operator test ah,not 1 jnz invalid_operand_size + mov [operand_size],cl cmp al,'(' jne invalid_operand call get_byte_value @@ -4597,11 +4619,18 @@ movd_instruction: mov bl,al jmp nomem_instruction_ready make_mmx_prefix: + cmp [vex_required],0 + jne mmx_prefix_for_vex cmp [operand_size],16 jne no_mmx_prefix mov [operand_prefix],66h no_mmx_prefix: ret + mmx_prefix_for_vex: + cmp [operand_size],16 + jne invalid_operand + mov [opcode_prefix],66h + ret movq_instruction: mov [base_code],0Fh lods byte [esi] @@ -4718,17 +4747,13 @@ movdq_instruction: cmp al,10h jne invalid_operand lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov [postbyte_register],al mov [extended_code],7Fh jmp instruction_ready movdq_mmreg: lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov [postbyte_register],al lods byte [esi] cmp al,',' @@ -4743,9 +4768,7 @@ movdq_instruction: jmp instruction_ready movdq_mmreg_mmreg: lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov bl,al jmp nomem_instruction_ready lddqu_instruction: @@ -4754,9 +4777,7 @@ lddqu_instruction: cmp al,10h jne invalid_operand lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register push eax lods byte [esi] cmp al,',' @@ -4772,41 +4793,22 @@ lddqu_instruction: mov [base_code],0Fh mov [extended_code],0F0h jmp instruction_ready -movq2dq_instruction: - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size - mov [postbyte_register],al - mov [operand_size],0 - lods byte [esi] - cmp al,',' - jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - cmp ah,8 - jne invalid_operand_size - mov bl,al - mov [opcode_prefix],0F3h - mov [base_code],0Fh - mov [extended_code],0D6h - jmp nomem_instruction_ready + movdq2q_instruction: + mov [opcode_prefix],0F2h + mov [mmx_size],8 + jmp movq2dq_ +movq2dq_instruction: + mov [opcode_prefix],0F3h + mov [mmx_size],16 + movq2dq_: lods byte [esi] call get_size_operator cmp al,10h jne invalid_operand lods byte [esi] call convert_mmx_register - cmp ah,8 + cmp ah,[mmx_size] jne invalid_operand_size mov [postbyte_register],al mov [operand_size],0 @@ -4819,10 +4821,10 @@ movdq2q_instruction: jne invalid_operand lods byte [esi] call convert_mmx_register - cmp ah,16 + xor [mmx_size],8+16 + cmp ah,[mmx_size] jne invalid_operand_size mov bl,al - mov [opcode_prefix],0F2h mov [base_code],0Fh mov [extended_code],0D6h jmp nomem_instruction_ready @@ -4846,6 +4848,32 @@ sse_sd_instruction: mov [mmx_size],8 mov [opcode_prefix],0F2h jmp sse_instruction +cmp_pd_instruction: + mov [opcode_prefix],66h +cmp_ps_instruction: + mov [mmx_size],16 + mov byte [value],al + mov al,0C2h + jmp sse_instruction +cmp_ss_instruction: + mov [mmx_size],4 + mov [opcode_prefix],0F3h + jmp cmp_sx_instruction +cmpsd_instruction: + mov al,0A7h + mov ah,[esi] + or ah,ah + jz simple_instruction_32bit + cmp ah,0Fh + je simple_instruction_32bit + mov al,-1 +cmp_sd_instruction: + mov [mmx_size],8 + mov [opcode_prefix],0F2h + cmp_sx_instruction: + mov byte [value],al + mov al,0C2h + jmp sse_instruction comiss_instruction: mov [mmx_size],4 jmp sse_instruction @@ -4853,6 +4881,8 @@ comisd_instruction: mov [mmx_size],8 mov [opcode_prefix],66h jmp sse_instruction +cvtdq2pd_instruction: + mov [opcode_prefix],0F3h cvtps2pd_instruction: mov [mmx_size],8 jmp sse_instruction @@ -4860,7 +4890,7 @@ cvtpd2dq_instruction: mov [mmx_size],16 mov [opcode_prefix],0F2h jmp sse_instruction -cvtdq2pd_instruction: +movshdup_instruction: mov [mmx_size],16 mov [opcode_prefix],0F3h sse_instruction: @@ -4872,9 +4902,7 @@ sse_instruction: jne invalid_operand sse_xmmreg: lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register sse_reg: mov [postbyte_register],al mov [operand_size],0 @@ -4895,6 +4923,12 @@ sse_instruction: cmp [operand_size],al jne invalid_operand_size sse_mem_size_ok: + mov al,[extended_code] + mov ah,[supplemental_code] + cmp al,0C2h + je sse_cmp_mem_ok + cmp ax,443Ah + je sse_cmp_mem_ok cmp [immediate_size],1 je mmx_imm8 cmp [immediate_size],-1 @@ -4903,6 +4937,11 @@ sse_instruction: mov [immediate_size],0 sse_ok: jmp instruction_ready + sse_cmp_mem_ok: + cmp byte [value],-1 + je mmx_imm8 + call store_instruction_with_imm8 + jmp instruction_assembled sse_xmmreg_xmmreg: cmp [operand_prefix],66h jne sse_xmmreg_xmmreg_ok @@ -4912,10 +4951,14 @@ sse_instruction: je invalid_operand sse_xmmreg_xmmreg_ok: lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov bl,al + mov al,[extended_code] + mov ah,[supplemental_code] + cmp al,0C2h + je sse_cmp_nomem_ok + cmp ax,443Ah + je sse_cmp_nomem_ok cmp [immediate_size],1 je mmx_nomem_imm8 cmp [immediate_size],-1 @@ -4924,6 +4967,13 @@ sse_instruction: mov [immediate_size],0 sse_nomem_ok: jmp nomem_instruction_ready + sse_cmp_nomem_ok: + cmp byte [value],-1 + je mmx_nomem_imm8 + call store_nomem_instruction + mov al,byte [value] + stosb + jmp instruction_assembled take_additional_xmm0: cmp byte [esi],',' jne additional_xmm0_ok @@ -4932,15 +4982,13 @@ sse_instruction: cmp al,10h jne invalid_operand lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register test al,al jnz invalid_operand additional_xmm0_ok: ret -ps_dq_instruction: +pslldq_instruction: mov [postbyte_register],al mov [opcode_prefix],66h mov [base_code],0Fh @@ -4950,9 +4998,7 @@ ps_dq_instruction: cmp al,10h jne invalid_operand lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov bl,al jmp mmx_nomem_imm8 movpd_instruction: @@ -5004,9 +5050,7 @@ sse_mov_instruction: cmp al,10h jne invalid_operand lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov [postbyte_register],al jmp instruction_ready movlpd_instruction: @@ -5020,9 +5064,7 @@ movlps_instruction: cmp al,10h jne sse_mem lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov [postbyte_register],al mov [operand_size],0 lods byte [esi] @@ -5040,9 +5082,7 @@ movhlps_instruction: cmp al,10h jne invalid_operand lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov [postbyte_register],al lods byte [esi] cmp al,',' @@ -5092,130 +5132,24 @@ movmskps_instruction: jne invalid_operand lods byte [esi] call convert_register + mov [postbyte_register],al cmp ah,4 + je movmskps_reg_ok + cmp ah,8 jne invalid_operand_size - mov [operand_size],0 - mov [postbyte_register],al - lods byte [esi] - cmp al,',' + cmp [code_type],64 jne invalid_operand - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size - mov bl,al - jmp nomem_instruction_ready -cmppd_instruction: - mov [opcode_prefix],66h -cmpps_instruction: - mov [base_code],0Fh - mov [extended_code],0C2h - mov [mmx_size],16 - mov byte [value],-1 - jmp sse_cmp_instruction -cmp_pd_instruction: - mov [opcode_prefix],66h -cmp_ps_instruction: - mov [base_code],0Fh - mov [extended_code],0C2h - mov [mmx_size],16 - mov byte [value],al - jmp sse_cmp_instruction -cmpss_instruction: - mov [mmx_size],4 - mov [opcode_prefix],0F3h - jmp cmpsx_instruction -cmpsd_instruction: - mov al,0A7h - mov ah,[esi] - or ah,ah - jz simple_instruction_32bit - cmp ah,0Fh - je simple_instruction_32bit - mov [mmx_size],8 - mov [opcode_prefix],0F2h - cmpsx_instruction: - mov [base_code],0Fh - mov [extended_code],0C2h - mov byte [value],-1 - jmp sse_cmp_instruction -cmp_ss_instruction: - mov [mmx_size],4 - mov [opcode_prefix],0F3h - jmp cmp_sx_instruction -cmp_sd_instruction: - mov [mmx_size],8 - mov [opcode_prefix],0F2h - cmp_sx_instruction: - mov [base_code],0Fh - mov [extended_code],0C2h - mov byte [value],al -sse_cmp_instruction: - lods byte [esi] - call get_size_operator - cmp al,10h - jne invalid_operand - lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size - mov [postbyte_register],al - lods byte [esi] - cmp al,',' - jne invalid_operand - mov [operand_size],0 - lods byte [esi] - call get_size_operator - cmp al,10h - je sse_cmp_xmmreg_xmmreg - cmp al,'[' - jne invalid_operand - call get_address - mov al,[operand_size] - or al,al - jz sse_cmp_size_ok - cmp al,[mmx_size] - jne invalid_operand_size - sse_cmp_size_ok: - push ebx ecx edx - call get_nextbyte - pop edx ecx ebx - call store_instruction_with_imm8 - jmp instruction_assembled - sse_cmp_xmmreg_xmmreg: - lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size - mov bl,al - call store_nomem_instruction - call get_nextbyte - mov al,byte [value] - stos byte [edi] - jmp instruction_assembled - get_nextbyte: - cmp byte [value],-1 - jne nextbyte_ok + movmskps_reg_ok: mov [operand_size],0 lods byte [esi] cmp al,',' jne invalid_operand lods byte [esi] call get_size_operator - test [operand_size],not 1 - jnz invalid_value - cmp al,'(' - jne invalid_operand - call get_byte_value - cmp al,7 - ja invalid_value - mov byte [value],al - nextbyte_ok: - ret + cmp al,10h + je sse_xmmreg_xmmreg_ok + jmp invalid_operand + cvtpi2pd_instruction: mov [opcode_prefix],66h cvtpi2ps_instruction: @@ -5226,9 +5160,7 @@ cvtpi2ps_instruction: cmp al,10h jne invalid_operand lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov [postbyte_register],al mov [operand_size],0 lods byte [esi] @@ -5267,10 +5199,9 @@ cvtsi2sd_instruction: cmp al,10h jne invalid_operand lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov [postbyte_register],al + cvtsi_xmmreg: mov [operand_size],0 lods byte [esi] cmp al,',' @@ -5285,7 +5216,10 @@ cvtsi2sd_instruction: cmp [operand_size],0 je cvtsi_size_ok cmp [operand_size],4 + je cvtsi_size_ok + cmp [operand_size],8 jne invalid_operand_size + call operand_64bit cvtsi_size_ok: jmp instruction_ready cvtsi_xmmreg_reg: @@ -5413,13 +5347,9 @@ amd3dnow_instruction: sse4_instruction_38_xmm0: mov [immediate_size],-1 - jmp sse4_instruction_38 -sse4_instruction_38_imm8: - mov [immediate_size],1 sse4_instruction_38: mov [mmx_size],16 mov [opcode_prefix],66h - mov [base_code],0Fh mov [supplemental_code],al mov al,38h jmp sse_instruction @@ -5433,14 +5363,17 @@ sse4_sd_instruction_3a_imm8: jmp sse4_instruction_3a_setup sse4_instruction_3a_imm8: mov [immediate_size],1 -sse4_instruction_3a: mov [mmx_size],16 sse4_instruction_3a_setup: mov [opcode_prefix],66h - mov [base_code],0Fh mov [supplemental_code],al mov al,3Ah jmp sse_instruction +pclmulqdq_instruction: + mov byte [value],al + mov [mmx_size],16 + mov al,44h + jmp sse4_instruction_3a_setup extractps_instruction: mov [opcode_prefix],66h mov [base_code],0Fh @@ -5468,9 +5401,7 @@ extractps_instruction: cmp al,10h jne invalid_operand lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov [postbyte_register],al pop ecx ebx edx jmp mmx_imm8 @@ -5487,9 +5418,7 @@ extractps_instruction: cmp al,10h jne invalid_operand lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov [postbyte_register],al pop ebx mov al,bh @@ -5500,19 +5429,18 @@ extractps_instruction: call operand_64bit jmp mmx_nomem_imm8 insertps_instruction: - mov [opcode_prefix],66h - mov [base_code],0Fh - mov [extended_code],3Ah - mov [supplemental_code],21h lods byte [esi] call get_size_operator cmp al,10h jne invalid_operand lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov [postbyte_register],al + insertps_xmmreg: + mov [opcode_prefix],66h + mov [base_code],0Fh + mov [extended_code],3Ah + mov [supplemental_code],21h mov [operand_size],0 lods byte [esi] cmp al,',' @@ -5520,7 +5448,7 @@ insertps_instruction: lods byte [esi] call get_size_operator cmp al,10h - je insertps_reg + je insertps_xmmreg_reg cmp al,'[' jne invalid_operand call get_address @@ -5530,7 +5458,7 @@ insertps_instruction: jne invalid_operand_size insertps_size_ok: jmp mmx_imm8 - insertps_reg: + insertps_xmmreg_reg: lods byte [esi] call convert_mmx_register mov bl,al @@ -5564,6 +5492,10 @@ pextrb_instruction: cmp [operand_size],0 jne invalid_operand_size pextr_size_ok: + cmp al,8 + jne pextr_prefix_ok + call operand_64bit + pextr_prefix_ok: push edx ebx ecx mov [operand_size],0 lods byte [esi] @@ -5574,9 +5506,7 @@ pextrb_instruction: cmp al,10h jne invalid_operand lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov [postbyte_register],al pop ecx ebx edx jmp mmx_imm8 @@ -5633,7 +5563,7 @@ pinsrd_instruction: jmp pinsr_instruction pinsrq_instruction: mov [mmx_size],8 - jmp pinsr_instruction + call operand_64bit pinsr_instruction: mov [opcode_prefix],66h mov [base_code],0Fh @@ -5644,10 +5574,9 @@ pinsrq_instruction: cmp al,10h jne invalid_operand lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov [postbyte_register],al + pinsr_xmmreg: mov [operand_size],0 lods byte [esi] cmp al,',' @@ -5705,9 +5634,7 @@ pmovsxdq_instruction: cmp al,10h jne invalid_operand lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov [postbyte_register],al lods byte [esi] cmp al,',' @@ -5728,12 +5655,12 @@ pmovsxdq_instruction: jmp instruction_ready pmovsx_xmmreg_reg: lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov bl,al jmp nomem_instruction_ready +fxsave_instruction_64bit: + call operand_64bit fxsave_instruction: mov [extended_code],0AEh mov [base_code],0Fh @@ -5794,11 +5721,9 @@ pause_instruction: movntq_instruction: mov [mmx_size],8 jmp movnt_instruction -movntps_instruction: - mov [mmx_size],16 - jmp movnt_instruction -movntdq_instruction: +movntpd_instruction: mov [opcode_prefix],66h +movntps_instruction: mov [mmx_size],16 movnt_instruction: mov [extended_code],al @@ -5852,9 +5777,7 @@ movntss_instruction: cmp al,10h jne invalid_operand lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov [postbyte_register],al jmp instruction_ready @@ -5937,9 +5860,7 @@ movntdqa_instruction: cmp al,10h jne invalid_operand lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov [postbyte_register],al lods byte [esi] cmp al,',' @@ -5960,9 +5881,7 @@ extrq_instruction: cmp al,10h jne invalid_operand lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov [postbyte_register],al mov [operand_size],0 lods byte [esi] @@ -5986,9 +5905,7 @@ extrq_instruction: extrq_xmmreg_xmmreg: inc [extended_code] lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov bl,al jmp nomem_instruction_ready insertq_instruction: @@ -6000,9 +5917,7 @@ insertq_instruction: cmp al,10h jne invalid_operand lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov [postbyte_register],al mov [operand_size],0 lods byte [esi] @@ -6013,9 +5928,7 @@ insertq_instruction: cmp al,10h jne invalid_operand lods byte [esi] - call convert_mmx_register - cmp ah,16 - jne invalid_operand_size + call convert_xmm_register mov bl,al cmp byte [esi],',' je insertq_with_imm @@ -6140,21 +6053,12 @@ movbe_instruction: jne invalid_operand lods byte [esi] call get_size_operator -; cmp al,10h -; je movbe_reg_reg cmp al,'[' jne invalid_argument call get_address mov al,[operand_size] call operand_autodetect jmp instruction_ready -; movbe_reg_reg: -; lods byte [esi] -; call convert_register -; mov bl,al -; mov al,ah -; call operand_autodetect -; jmp nomem_instruction_ready movbe_mem: inc [supplemental_code] call get_address @@ -6382,6 +6286,38 @@ invlpga_instruction: mov ah,bl jmp simple_svm_detect_size +rdrand_instruction: + mov [base_code],0Fh + mov [extended_code],0C7h + mov [postbyte_register],al + lods byte [esi] + call get_size_operator + cmp al,10h + jne invalid_operand + lods byte [esi] + call convert_register + mov bl,al + mov al,ah + call operand_autodetect + jmp nomem_instruction_ready +rdfsbase_instruction: + mov [opcode_prefix],0F3h + mov [base_code],0Fh + mov [extended_code],0AEh + mov [postbyte_register],al + lods byte [esi] + call get_size_operator + cmp al,10h + jne invalid_operand + lods byte [esi] + call convert_register + mov bl,al + mov al,ah + cmp ah,2 + je invalid_operand_size + call operand_autodetect + jmp nomem_instruction_ready + convert_register: mov ah,al shr ah,4 @@ -6426,6 +6362,8 @@ convert_mmx_register: cmp ah,0Bh jne invalid_operand mov ah,8 + cmp [vex_required],0 + jne invalid_operand jmp match_register_size xmm_register: and al,0Fh @@ -6435,6 +6373,12 @@ convert_mmx_register: cmp [code_type],64 jne invalid_operand jmp match_register_size +convert_xmm_register: + mov ah,al + shr ah,4 + cmp ah,0Ch + je xmm_register + jmp invalid_operand get_size_operator: xor ah,ah cmp al,11h @@ -6553,10 +6497,12 @@ store_segment_prefix_if_necessary: mov al,[segment_register] or al,al jz segment_prefix_ok - cmp al,3 - je ss_prefix cmp al,4 ja segment_prefix_386 + cmp [code_type],64 + je segment_prefix_ok + cmp al,3 + je ss_prefix jb segment_prefix_86 cmp bl,25h je segment_prefix_86 @@ -6595,6 +6541,8 @@ store_segment_prefix: segment_prefix_ok: ret store_instruction_code: + cmp [vex_required],0 + jne store_vex_instruction_code mov al,[operand_prefix] or al,al jz operand_prefix_ok @@ -6656,6 +6604,25 @@ store_instruction: or [rex_prefix],44h and [postbyte_register],111b reg_code_ok: + cmp [code_type],64 + jne address_value_ok + xor eax,eax + bt edx,31 + sbb eax,[address_high] + jz address_value_ok + cmp [address_high],0 + jne address_value_out_of_range + test ch,44h + jnz address_value_ok + test bx,8080h + jz address_value_ok + address_value_out_of_range: + cmp [error_line],0 + jne address_value_ok + mov edx,[current_line] + mov [error_line],edx + mov [error],value_out_of_range + address_value_ok: call store_segment_prefix_if_necessary or bx,bx jz address_immediate @@ -6773,19 +6740,10 @@ store_instruction: cmp [code_type],64 jne invalid_address_size address_prefix_ok: - cmp bl,44h - je swap_base_with_index - cmp bl,84h - jne base_register_ok - swap_base_with_index: - cmp cl,1 - jne invalid_address - xchg bl,bh cmp bl,44h je invalid_address cmp bl,84h je invalid_address - base_register_ok: test bh,1000b jz base_code_ok or [rex_prefix],41h @@ -6842,20 +6800,6 @@ store_instruction: shl cl,3 or al,cl stos word [edi] - address_32bit_value: - cmp [code_type],64 - jne store_address_32bit_value - mov eax,edx - cdq - cmp edx,[address_high] - je address_32bit_value_ok - cmp [error_line],0 - jne address_32bit_value_ok - mov edx,[current_line] - mov [error_line],edx - mov [error],value_out_of_range - address_32bit_value_ok: - mov edx,eax jmp store_address_32bit_value sib_address_8bit_value: or al,01000000b @@ -6886,12 +6830,12 @@ store_instruction: or al,cl stos word [edi] test ch,44h - jnz address_32bit_value + jnz store_address_32bit_value test ch,88h - jnz address_32bit_value + jnz store_address_32bit_value or ch,ch jnz invalid_address_size - jmp address_32bit_value + jmp store_address_32bit_value zero_index_register: mov bl,4 mov cl,1 @@ -6919,7 +6863,7 @@ store_instruction: shl cl,3 or al,cl stos byte [edi] - jmp address_32bit_value + jmp store_address_32bit_value simple_address_8bit_value: or al,01000000b mov cl,[postbyte_register] @@ -7002,11 +6946,6 @@ store_instruction: jnz address_immediate_sib_32bit test ch,not 88h jnz invalid_address_size - xor eax,eax - bt edx,31 - sbb eax,0 - cmp eax,[address_high] - jne value_out_of_range address_immediate_sib_store: call store_instruction_code mov al,100b