From acb3468f8b61ecf9ed893c410d8a1e5b05f8a8ff Mon Sep 17 00:00:00 2001 From: heavyiron Date: Sun, 14 Jun 2009 15:16:54 +0000 Subject: [PATCH] fasm 1.68 git-svn-id: svn://kolibrios.org@1115 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/develop/fasm/trunk/WHATSNEW.TXT | 323 ++++------------------- programs/develop/fasm/trunk/formats.inc | 76 +++--- programs/develop/fasm/trunk/tables.inc | 6 + programs/develop/fasm/trunk/version.inc | 6 +- programs/develop/fasm/trunk/x86_64.inc | 32 ++- 5 files changed, 124 insertions(+), 319 deletions(-) diff --git a/programs/develop/fasm/trunk/WHATSNEW.TXT b/programs/develop/fasm/trunk/WHATSNEW.TXT index e89878190d..57a637b746 100644 --- a/programs/develop/fasm/trunk/WHATSNEW.TXT +++ b/programs/develop/fasm/trunk/WHATSNEW.TXT @@ -2,266 +2,25 @@ Visit http://flatassembler.net/ for more information. -version 1.67.35 (Mar 09, 2009) +version 1.68 (Jun 13, 2009) -[-] Some internal code size reductions. +[+] Added SSSE3 (Supplemental SSE3), SSE4.1, SSE4.2 and SSE4a instructions. -[-] Discontinued "-d" switch implementation. +[+] Added the AMD SVM and Intel SMX instructions. +[+] Added "rdmsrq", "wrmsrq", "sysexitq" and "sysretq" mnemonics for the + 64-bit variants of respective instructions. -version 1.67.34 (Feb 22, 2009) +[+] Added "fstenvw", "fstenvd", "fsavew", "fsaved", "frstorw" and "frstord" + mnemonics to allow choosing between 16-bit and 32-bit variants of + structures used by the "fstenv", "fsave" and "frstor" instructions. -[-] Fixed small bug with DT directive far pointer syntax. +[+] Added "plt" operator for the ELF output format. +[+] Allowed "rva" operator to be used in MS COFF object format, and also + added "static" keyword for the "public" directive. -version 1.67.33 (Feb 20, 2009) - -[+] Added ERR directive that allows to signalize error from the source. - - -version 1.67.32 (Feb 13, 2009) - -[+] Allowed single quote character to be put inside the number value, - to help improve long numbers readability. - - -version 1.67.31 (Feb 11, 2009) - -[-] Fixed floating point converter to no longer generate NaN in some cases, - and corrected denormal numbers generation. - - -version 1.67.30 (Feb 08, 2009) - -[+] Added missing Intel SSE4 instructions. - -[+] Added SSE4a (EXTRQ/INSERTQ/MOVNTSD/MOVNTSS) instructions. - -[+] Added FSTENVW/FSTENVD/FSAVEW/FSAVED mnemonics. - - -version 1.67.29 (Nov 15, 2008) - -[+] Added optional symbolic information output, and a set of tools that extract - various kinds of information from it. - -[+] Allowed RVA operator to be used in COFF object format. - -[-] Corrected the FIX directive to allow names of preprocessor's directives to be - used as prioritized symbolic constant name. - - -version 1.67.28 (Nov 06, 2008) - -[+] Added EFI/EFIBOOT/EFIRUNTIME subsystem keywords for PE format (experimental - feature, still needs to be tested). - -[-] Fixed a bug in preprocessor which caused some problems with DISPLAY directive - output in some cases. - -[-] Fixed a bug that allowed to define a symbol named "eip" or "rip". - -[-] Fixed a problem with assembling MOVQ RAX,XMM0 instruction. - - -version 1.67.27 (Jul 12, 2008) - -[-] Fixed a bug which caused instructions from JCXZ/LOOP family to be incorrectly - assembled when requiring 67h prefix and provided with "$" operand. - -[-] Definition of macro with the same name as one of the preprocessor's directives - is no longer allowed. - -[-] Fixed REPT directive to check out validity of its parameters even when the - count is zero. - -[-] Fixed VMREAD/VMWRITE syntax in the USE64 mode. - -[-] Corrected MZ header generation and handling for the case when the last page of - executable contains the round 512 bytes. - - -version 1.67.26 (Jan 27, 2008) - -[+] Added partial SSE4 support (a couple of instructions left to be implemented - in the next releases) - -[+] Added GETSEC instruction for the SMX functions calling. - -[-] Some fixes and rearrangements in the DOS version. - - -version 1.67.25 (Dec 30, 2007) - -[-] Fixed a couple of bugs related to undefined symbol error signaling. - - -version 1.67.24 (Dec 03, 2007) - -[+] Added "-d" option to allow predefining symbolic constants from command line. - -[-] Changed some of the error messages to be more informative. - - -version 1.67.23 (Sep 08, 2007) - -[+] Added "static" keyword for the "public" directive in COFF format. - -[-] Redirected error information into stderr. - - -version 1.67.22 (Aug 05, 2007) - -[+] Allowed to check "@b" and "@f" symbols with "defined" operator. - -[+] Allowed "as" operator to specify the output file extension when - placed at the end of the "format" directive line. - -[-] Fixed a bug with stack size declaration in PE64 format that - caused assembler to crash. - -[-] Corrected the VMREAD and VMWRITE instructions to allow registers - in place of memory operands. - -[-] Corrected a mistake that made PLT operator not work correctly with - the CALL instruction. - - -version 1.67.21 (Feb 17, 2007) - -[+] Allowed 32-bit relocations in PE64 output format. - -[-] Fixed a bug that caused "push cr0" error to go unnoticed by assembler. - - -version 1.67.20 (Feb 12, 2007) - -[-] Corrected the range checking of signed address displacements in 64-bit mode. - - -version 1.67.19 (Feb 10, 2007) - -[-] Disallowed labels starting with $ character. - -[-] Fixed some problems with handling 32-bit relocations in 64-bit formats. - - -version 1.67.18 (Dec 27, 2006) - -[-] Fixed a small mistake in the recent corrections of logical expression parser. - - -version 1.67.17 (Dec 20, 2006) - -[-] Corrected the precedence of operators of macroinstruction line maker. - The symbol escaping now has always the higher priority than symbol conversion, - and both have higher precedence than concatenation. - -[-] Fixed problems with logical expression parser to handle correctly comparing - values containing round brackets with the EQ or EQTYPE operator. - The only limitation now is that when you use round brackets to enclose some - logical expressions, they must be paired everywhere inside those expressions. - - -version 1.67.16 (Dec 17, 2006) - -[-] Fixed a really old bug in register expression calculator. - - -version 1.67.15 (Nov 20, 2006) - -[-] Some final (?) fixes and cleanup in the relative-offsets calculations. - - -version 1.67.14 (Oct 28, 2006) - -[-] Another small bug fixes. - - -version 1.67.13 (Oct 26, 2006) - -[-] Fixed a bug with handling of invalid expressions by "defined" operator. - -[-] Fixed a newly-introduced bug with relocations in automatically generated RIP-relative - addressings. - - -version 1.67.12 (Oct 1, 2006) - -[+] Added EIP-relative addressing, and fixed some bugs with RIP-related one aswell. - - -version 1.67.11 (Sep 26, 2006) - -[+] Added PLT operator for the ELF output format. - -[-] Rearranged and fixed some of the relocation handling routines. - - -version 1.67.10 (Sep 23, 2006) - -[+] Added SSSE3 (Supplemental SSE3) instructions. - - -version 1.67.9 (Sep 21, 2006) - -[+] Added some Win64 headers and examples in the Windows package. - -[-] Fixed another operand size checking bug with MOVQ instruction. - - -version 1.67.8 (Sep 17, 2006) - -[-] Fixed a bug in address processing that caused disallowed combinations like - [qword eax] to be accepted. - - -version 1.67.7 (Jul 31, 2006) - -[-] Fixed a bug that caused over-repeated processing of macro operators when - many embedded macros were placed in one line - -[+] Added SYSRETQ mnemonic. - - -version 1.67.6 (Jul 21, 2006) - -[+] Added (not yet documented) RDMSRQ/WRMSRQ/SYSEXITQ mnemonics for the 64-bit - variants of respective instructions. - -[+] Added information about memory allocation to the command line interfaces. - This should make it easier to decide when to use the -m switch. - - -version 1.67.5 (Jul 7, 2006) - -[-] Fixed encoding of MOV (E)AX,[WORD ADDR] instruction in 32-bit mode. - - -version 1.67.4 (Jul 5, 2006) - -[+] Added R8L-R15L (Intel-style) aliases for R8B-R15B registers. - -[-] Further optimizations in the parser. - - -version 1.67.3 (Jul 2, 2006) - -[-] Improved an instruction searching algorithm a bit. - - -version 1.67.2 (Jul 1, 2006) - -[-] Fixed a recently introduced bug with ELF relocations in case of 32-bit - object. - - -version 1.67.1 (Jun 30, 2006) - -[+] Added the support for the new AMD SVM technology instructions. - - -version 1.67.0 (Jun 28, 2006) +[+] Added Intel-style aliases for the additional long mode 8-bit registers. [-] The PE formatter now automatically detects whether relocatable labels should be used, depending on whether the fixups directory is placed @@ -270,23 +29,45 @@ version 1.67.0 (Jun 28, 2006) at some position. [-] Added support for outputting the 32-bit address relocations in case of - 64-bit object formats. This makes some specific instructions compilable, - but it also forces linker to put such generated code into the low 2 - gigabytes of addressing space. + 64-bit object formats and PE executable. This makes some specific + instructions compilable, but it also forces linker to put such + generated code into the low 2 gigabytes of addressing space. + +[+] Added "EFI", "EFIboot" and "EFIruntime" subsystem keywords for PE format. + +[-] Corrected the precedence of operators of macroinstruction line maker. + The symbol escaping now has always the higher priority than symbol conversion, + and both have higher precedence than concatenation. + +[+] Allowed to check "@b" and "@f" symbols with "defined" operator. + +[+] Allowed "as" operator to specify the output file extension when + placed at the end of the "format" directive line. + +[-] Definition of macro with the same name as one of the preprocessor's directives + is no longer allowed. + +[+] Allowed single quote character to be put inside the number value, + to help improve long numbers readability. + +[+] Added optional symbolic information output, and a set of tools that extract + various kinds of information from it. + +[+] Added "err" directive that allows to signalize error from the source. version 1.66 (May 7, 2006) -[+] Added DEFINE directive to preprocessor, which defines symbolic constants, - the same kind as EQU directive, however there's an important difference - that DEFINE doesn't process symbolic constants in the value before +[+] Added "define" directive to preprocessor, which defines symbolic constants, + the same kind as "equ" directive, however there's an important difference + that "define" doesn't process symbolic constants in the value before assigning it. For example: - a equ 1 - a equ a+a + a equ 1 + a equ a+a - define b 1 - define b b+b + define b 1 + define b b+b defines the "a" constant with value "1+1", but the "b" is defined with value "b+b". This directive may be useful in some advanced @@ -298,11 +79,11 @@ version 1.66 (May 7, 2006) evaluated by the parser and if they are enough to determine the condition, the whole block is processed accordingly. Thus this block: - if eax eq EAX | 0/0 - nop - end if + if eax eq EAX | 0/0 + nop + end if - is parsed into just NOP instruction, since parser is able to determine + is parsed into just "nop" instruction, since parser is able to determine that the condition is true, even though one of the logical values makes no sense - but since this is none of the "eq", "eqtype" and "in" expressions, the parser doesn't investigate. @@ -310,9 +91,9 @@ version 1.66 (May 7, 2006) [-] Also the assembler is now calculating only as many logical values as it needs to determine the condition. So this block: - if defined alpha & alpha + if defined alpha & alpha - end if + end if will not cause error when "alpha" is not defined, as it would with previous versions. This is because after checking that "defined alpha" is false @@ -325,7 +106,7 @@ version 1.66 (May 7, 2006) [-] The size operator applied to jump no longer applies to the size of relative displacement - now it applies to the size of target address. -[-] The RET instruction with 0 parameter is now assembled into short form, +[-] The "ret" instruction with 0 parameter is now assembled into short form, unless you force using the 16-bit immediate with "word" operator. [+] Added missing extended registers for the 32-bit addressing in long mode. @@ -350,7 +131,7 @@ version 1.66 (May 7, 2006) [-] Some of the internal structures have been extended to provide the possibility of making extensive symbol dumps. -[-] Corrected FIX directive to keep the value intact before assigning it to the +[-] Corrected "fix" directive to keep the value intact before assigning it to the prioritized constant. [+] The ` operator now works with any kind of symbol; when used with quoted diff --git a/programs/develop/fasm/trunk/formats.inc b/programs/develop/fasm/trunk/formats.inc index ee976a11d7..1c1b93c7c6 100644 --- a/programs/develop/fasm/trunk/formats.inc +++ b/programs/develop/fasm/trunk/formats.inc @@ -481,11 +481,11 @@ mz_segment: and eax,1111b sub ecx,eax mov edx,edi - xor al,al + xor eax,eax rep stos byte [edi] mov dword [org_origin],edi - mov dword [org_origin+4],0 - mov [org_registers],0 + mov dword [org_origin+4],eax + mov [org_registers],eax mov [org_start],edi mov eax,edx call undefined_data @@ -668,14 +668,14 @@ make_stub: mov eax,40h+default_stub_end-default_stub mov cx,100h+default_stub_end-default_stub mov word [edx],'MZ' - mov word [edx+4],1 + mov byte [edx+4],1 mov word [edx+2],ax - mov word [edx+8],4 - mov word [edx+0Ah],10h + mov byte [edx+8],4 + mov byte [edx+0Ah],10h mov word [edx+0Ch],0FFFFh mov word [edx+10h],cx mov word [edx+3Ch],ax - mov word [edx+18h],40h + mov byte [edx+18h],40h lea edi,[edx+40h] mov esi,default_stub mov ecx,default_stub_end-default_stub @@ -804,7 +804,7 @@ make_stub: mov [esi+0Ah],ax binary_heap_ok: mov word [esi],'MZ' - mov word [esi+8],4 + mov byte [esi+8],4 mov ax,0FFFFh mov [esi+0Ch],ax dec ax @@ -813,7 +813,7 @@ make_stub: mov [esi+0Eh],ax mov [esi+16h],ax mov word [esi+14h],100h - mov word [esi+18h],40h + mov byte [esi+18h],40h mov eax,[display_buffer] sub eax,ecx cmp edi,eax @@ -977,9 +977,9 @@ format_pe: mov word [edx],'PE' ; signature mov ax,[machine] mov word [edx+4],ax - mov dword [edx+38h],1000h ; section alignment - mov dword [edx+3Ch],200h ; file alignment - mov word [edx+40h],1 ; OS version + mov byte [edx+38h+1],10h ; section alignment + mov byte [edx+3Ch+1],2 ; file alignment + mov byte [edx+40h],1 ; OS version mov eax,[subsystem_version] mov [edx+48h],eax mov ax,[subsystem] @@ -993,28 +993,26 @@ format_pe: mov word [edx+1Ah],VERSION_MAJOR + VERSION_MINOR shl 8 test [format_flags],8 jnz init_peplus_specific - mov dword [edx+14h],0E0h ; size of optional header + mov byte [edx+14h],0E0h ; size of optional header mov dword [edx+16h],10B010Eh; flags and magic value mov eax,[image_base] - mov dword [edx+34h],eax - mov dword [edx+60h],1000h ; stack reserve - mov dword [edx+64h],1000h ; stack commit - mov dword [edx+68h],10000h ; heap reserve - mov dword [edx+6Ch],0 ; heap commit - mov dword [edx+74h],16 ; number of directories + mov [edx+34h],eax + mov byte [edx+60h+1],10h ; stack reserve + mov byte [edx+64h+1],10h ; stack commit + mov byte [edx+68h+2],1 ; heap reserve + mov byte [edx+74h],16 ; number of directories jmp pe_header_ok init_peplus_specific: - mov dword [edx+14h],0F0h ; size of optional header + mov byte [edx+14h],0F0h ; size of optional header mov dword [edx+16h],20B002Eh; flags and magic value mov eax,[image_base] - mov dword [edx+30h],eax + mov [edx+30h],eax mov eax,[image_base_high] - mov dword [edx+34h],eax - mov dword [edx+60h],1000h ; stack reserve - mov dword [edx+68h],1000h ; stack commit - mov dword [edx+70h],10000h ; heap reserve - mov dword [edx+78h],0 ; heap commit - mov dword [edx+84h],16 ; number of directories + mov [edx+34h],eax + mov byte [edx+60h+1],10h ; stack reserve + mov byte [edx+68h+1],10h ; stack commit + mov byte [edx+70h+2],1 ; heap reserve + mov byte [edx+84h],16 ; number of directories pe_header_ok: bsf ecx,[edx+3Ch] imul ebx,[number_of_sections],28h @@ -1089,11 +1087,11 @@ format_pe: mov [org_start],edi bt [format_flags],8 jnc dll_flag_ok - or dword [edx+16h],2000h + or byte [edx+16h+1],20h dll_flag_ok: bt [format_flags],9 jnc wdm_flag_ok - or word [edx+5Eh],2000h + or byte [edx+5Eh+1],20h wdm_flag_ok: jmp format_defined pe_section: @@ -1234,7 +1232,6 @@ pe_section: mov eax,[code_start] sub eax,[stub_size] sub [ebx+14h],eax - mov ecx,[ebx+10h] test byte [ebx+24h],20h jz pe_code_sum_ok @@ -1254,7 +1251,6 @@ pe_section: mov eax,[ebx+0Ch] mov [edx+30h],eax pe_data_sum_ok: - mov eax,[ebx+8] or eax,eax jz udata_ok @@ -1263,7 +1259,6 @@ pe_section: or byte [ebx+24h],80h add [edx+24h],ecx udata_ok: - mov ecx,[edx+38h] dec ecx add eax,ecx @@ -2261,10 +2256,11 @@ format_coff: flat_section_flags_ok: mov dword [ebx+14h],eax mov [current_section],ebx - mov [number_of_sections],0 + xor eax,eax + mov [number_of_sections],eax mov dword [org_origin],edi - mov dword [org_origin+4],0 - mov [org_registers],0 + mov dword [org_origin+4],eax + mov [org_registers],eax mov [org_start],edi mov [org_symbol],ebx mov [labels_type],2 @@ -2287,8 +2283,8 @@ coff_section: mov [ebx],al mov [ebx+8],edi mov dword [org_origin],edi - mov dword [org_origin+4],0 - mov [org_registers],0 + mov dword [org_origin+4],eax + mov [org_registers],eax mov [org_start],edi mov [org_symbol],ebx mov [labels_type],2 @@ -2935,8 +2931,8 @@ elf_section: mov [ebx],al mov [ebx+8],edi mov dword [org_origin],edi - mov dword [org_origin+4],0 - mov [org_registers],0 + mov dword [org_origin+4],eax + mov [org_registers],eax mov [org_start],edi mov [org_symbol],ebx test [format_flags],8 @@ -3977,7 +3973,7 @@ close_elf_exe: dump_symbols: mov ebx,[code_start] - mov dword [ebx],'fas'+27 shl 24 + 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 diff --git a/programs/develop/fasm/trunk/tables.inc b/programs/develop/fasm/trunk/tables.inc index 5bc98d18e3..047193e163 100644 --- a/programs/develop/fasm/trunk/tables.inc +++ b/programs/develop/fasm/trunk/tables.inc @@ -963,6 +963,8 @@ instructions_5: dw loop_instruction_16bit-assembler db 'loopz',0E1h dw loop_instruction-assembler + db 'lzcnt',0BDh + dw popcnt_instruction-assembler db 'maxpd',5Fh dw sse_pd_instruction-assembler db 'maxps',5Fh @@ -1324,6 +1326,8 @@ instructions_6: dw sse_pd_instruction-assembler db 'hsubps',07Dh dw cvtpd2dq_instruction-assembler + db 'invept',80h + dw vmx_inv_instruction-assembler db 'invlpg',0 dw invlpg_instruction-assembler db 'lfence',0E8h @@ -1615,6 +1619,8 @@ instructions_7: dw insertq_instruction-assembler db 'invlpga',0DFh dw invlpga_instruction-assembler + db 'invvpid',81h + dw vmx_inv_instruction-assembler db 'ldmxcsr',10b dw fxsave_instruction-assembler db 'loopned',0E0h diff --git a/programs/develop/fasm/trunk/version.inc b/programs/develop/fasm/trunk/version.inc index caf2ce54af..6e78792cfc 100644 --- a/programs/develop/fasm/trunk/version.inc +++ b/programs/develop/fasm/trunk/version.inc @@ -1,5 +1,5 @@ -; flat assembler version 1.67 +; flat assembler version 1.68 ; Copyright (c) 1999-2009, Tomasz Grysztar. ; All rights reserved. ; @@ -33,7 +33,7 @@ ; cannot simply be copied and put under another distribution licence ; (including the GNU Public Licence). -VERSION_STRING equ "1.67.38" +VERSION_STRING equ "1.68" VERSION_MAJOR = 1 -VERSION_MINOR = 67 +VERSION_MINOR = 68 diff --git a/programs/develop/fasm/trunk/x86_64.inc b/programs/develop/fasm/trunk/x86_64.inc index 093b9cb0f6..e7efa1fc2a 100644 --- a/programs/develop/fasm/trunk/x86_64.inc +++ b/programs/develop/fasm/trunk/x86_64.inc @@ -6146,8 +6146,6 @@ vmread_instruction: lods byte [esi] cmp al,',' jne invalid_operand - call vmread_check_size - mov [operand_size],0 lods byte [esi] call get_size_operator cmp al,10h @@ -6165,7 +6163,6 @@ vmread_instruction: lods byte [esi] cmp al,',' jne invalid_operand - mov [operand_size],0 lods byte [esi] call get_size_operator cmp al,10h @@ -6196,8 +6193,6 @@ vmwrite_instruction: lods byte [esi] call convert_register mov [postbyte_register],al - call vmread_check_size - mov [operand_size],0 lods byte [esi] cmp al,',' jne invalid_operand @@ -6216,6 +6211,33 @@ vmwrite_instruction: mov bl,al mov [base_code],0Fh jmp nomem_instruction_ready +vmx_inv_instruction: + mov [opcode_prefix],66h + mov [extended_code],38h + mov [supplemental_code],al + lods byte [esi] + call get_size_operator + cmp al,10h + jne invalid_operand + lods byte [esi] + call convert_register + mov [postbyte_register],al + call vmread_check_size + mov [operand_size],0 + lods byte [esi] + cmp al,',' + jne invalid_operand + lods byte [esi] + call get_size_operator + cmp al,'[' + jne invalid_operand + call get_address + mov al,[operand_size] + or al,al + jz vmx_size_ok + cmp al,16 + jne invalid_operand_size + jmp vmx_size_ok simple_svm_instruction: push eax mov [base_code],0Fh