fasm: the program updated to 1.70.01

tested with the kernel and several applications
sorry for previous ugly commit


git-svn-id: svn://kolibrios.org@2665 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Ivan Baravy 2012-05-20 14:43:49 +00:00
parent 96a29bfdda
commit 73798864bd
15 changed files with 6038 additions and 5183 deletions

View File

@ -1,281 +1,265 @@
Visit http://flatassembler.net/ for more information. Visit http://flatassembler.net/ for more information.
version 1.69.11 (Dec 19, 2009) version 1.70.01 (Apr 30, 2012)
[+] Allowed syntax of "pmovmskb" with 64-bit register destination in long mode. [-] Corrected a recently introduced bug that caused some incorrect
address expressions to cause an error prematurely during the
[-] The code generated for "call eax" instruction was missing prefix in 16-bit parsing stage.
mode - fixed.
version 1.70 (Apr 17, 2012)
version 1.69.10 (Oct 28, 2009)
[+] Added support for AVX, AVX2, AES, CLMUL, FMA, RDRAND, FSGSBASE, F16C,
[-] Fixed long mode opcode generator to allow absolute addresses to be FMA4, XOP, MOVBE, BMI, TBM, INVPCID, HLE and RTM instruction sets.
generated with "qword" keyword inside square brackets.
[+] Added half-precision floating point values support.
version 1.69.09 (Oct 20, 2009) [+] Extended the syntax of "rept" directive to allow numerical expressions
to be calculated by preprocessor in its arguments.
[-] Fixed a crash during the symbolic information generation when a "static"
symbol was encountered. [+] Added "large" and "NX" settings from PE format.
[+] Allowed PE fixups to be resolved anywhere in the generated executable.
version 1.69.08 (Oct 04, 2009)
[+] Allowed to specify branding value (use 3 for Linux) after the
[-] Minor bugfixes. "format ELF executable" setting.
[+] Added "intepreter", "dynamic" and "note" keywords for creation of
version 1.69.07 (Oct 03, 2009) special segments in ELF executables.
[-] Corrected encoding of "extrq" intruction for some cases. [-] Fixed long mode opcode generator to allow absolute addresses to be
generated with "qword" keyword inside square brackets.
version 1.69.06 (Sep 29, 2009) [-] Disallowed negative immediates with "int", "enter", "ret" instructions.
[-] The prefix 67h for "jecxz" and "loopd" instructions in 64-bit mode wasn't [+] Allowed symbolic information dump file to be created even in case of error.
correctly generated - fixed. In such case it contains only the preprocessed source that can be extracted
with PREPSRC tool. If error occured during preprocessing, only the source up
[-] It's no longer possible to define two special segments of the same type to the point of error is provided.
in ELF executables.
[+] Added symbol references table to symbolic dump file.
version 1.69.05 (Sep 14, 2009) [-] Corrected the "defined" and "used" flags in the symbols dump to reflect the
state from the final assembly pass.
[+] Allowed to specify branding value (use 3 for Linux) after the
"format ELF executable" setting. [+] Added "assert" directive.
[+] Added "intepreter", "dynamic" and "note" keywords for creation of [-] Formatter symbols like "PE" or "readable" are now recognized only in the
special segments in ELF executables. context of formatter directives, and thus are no longer disallowed as
labels.
version 1.69.04 (Sep 7, 2009) [+] Macroinstruction argument now can have default value, defined with "="
symbol followed by value after the argument name in definition.
[-] Fixed a bug with REX prefix generation with address of type "rX+rsp".
[+] Added "relativeto" operator, which can be used in logical expressions
to test whether two values differ only by a constant and not relocatable
version 1.69.03 (Aug 03, 2009) amount.
[+] Allowed simplified syntax for "monitor", "mwait", "blendvps", "blendvpd" and [-] Revised the expression calculator, it now is able to correctly perform
"pblendvb" instructions. calculations in signed and unsigned ranges in full 64-bit. This fixes
a number of issues - the overflow will now be correctly detected for
64-bit values in cases, where previous versions could not distinguish
version 1.69.02 (Jul 04, 2009) whether it was an overflow or not. The effect of these corrections is
that "dq" directive will now behave consistently with behavior of the
[-] Minor bugfixes. data directives for smaller sizes, and the same applies to all the
places where "qword" size for value is used.
version 1.69.01 (Jul 01, 2009)
version 1.68 (Jun 13, 2009)
[+] Added "movbe" instruction.
[+] Added SSSE3 (Supplemental SSE3), SSE4.1, SSE4.2 and SSE4a instructions.
[-] "extractps" no longer generates the double 66h prefix.
[+] Added the AMD SVM and Intel SMX instructions.
version 1.69.00 (Jun 23, 2009) [+] Added "rdmsrq", "wrmsrq", "sysexitq" and "sysretq" mnemonics for the
64-bit variants of respective instructions.
[+] Extended the syntax of "rept" directive to allow numerical expressions
to be calculated by preprocessor in its arguments. [+] Added "fstenvw", "fstenvd", "fsavew", "fsaved", "frstorw" and "frstord"
mnemonics to allow choosing between 16-bit and 32-bit variants of
[-] The code of assembler (but not data) has been made position-independent, and structures used by the "fstenv", "fsave" and "frstor" instructions.
this allowed to use code segmentation in DOS unREAL mode, so the code is
no longer limited to 64 kilobytes. [+] Added "plt" operator for the ELF output format.
[+] Allowed "rva" operator to be used in MS COFF object format, and also
version 1.68 (Jun 13, 2009) added "static" keyword for the "public" directive.
[+] Added SSSE3 (Supplemental SSE3), SSE4.1, SSE4.2 and SSE4a instructions. [+] Added Intel-style aliases for the additional long mode 8-bit registers.
[+] Added the AMD SVM and Intel SMX instructions. [-] The PE formatter now automatically detects whether relocatable labels
should be used, depending on whether the fixups directory is placed
[+] Added "rdmsrq", "wrmsrq", "sysexitq" and "sysretq" mnemonics for the somewhere into executable by programer, or not. This makes possible the
64-bit variants of respective instructions. more flexible use of the addressing symbols in case of PE executable fixed
at some position.
[+] Added "fstenvw", "fstenvd", "fsavew", "fsaved", "frstorw" and "frstord"
mnemonics to allow choosing between 16-bit and 32-bit variants of [-] Added support for outputting the 32-bit address relocations in case of
structures used by the "fstenv", "fsave" and "frstor" instructions. 64-bit object formats and PE executable. This makes some specific
instructions compilable, but it also forces linker to put such
[+] Added "plt" operator for the ELF output format. generated code into the low 2 gigabytes of addressing space.
[+] Allowed "rva" operator to be used in MS COFF object format, and also [+] Added "EFI", "EFIboot" and "EFIruntime" subsystem keywords for PE format.
added "static" keyword for the "public" directive.
[-] Corrected the precedence of operators of macroinstruction line maker.
[+] Added Intel-style aliases for the additional long mode 8-bit registers. The symbol escaping now has always the higher priority than symbol conversion,
and both have higher precedence than concatenation.
[-] The PE formatter now automatically detects whether relocatable labels
should be used, depending on whether the fixups directory is placed [+] Allowed to check "@b" and "@f" symbols with "defined" operator.
somewhere into executable by programer, or not. This makes possible the
more flexible use of the addressing symbols in case of PE executable fixed [+] Allowed "as" operator to specify the output file extension when
at some position. placed at the end of the "format" directive line.
[-] Added support for outputting the 32-bit address relocations in case of [-] Definition of macro with the same name as one of the preprocessor's directives
64-bit object formats and PE executable. This makes some specific is no longer allowed.
instructions compilable, but it also forces linker to put such
generated code into the low 2 gigabytes of addressing space. [+] Allowed single quote character to be put inside the number value,
to help improve long numbers readability.
[+] Added "EFI", "EFIboot" and "EFIruntime" subsystem keywords for PE format.
[+] Added optional symbolic information output, and a set of tools that extract
[-] Corrected the precedence of operators of macroinstruction line maker. various kinds of information from it.
The symbol escaping now has always the higher priority than symbol conversion,
and both have higher precedence than concatenation. [+] Added "err" directive that allows to signalize error from the source.
[+] Allowed to check "@b" and "@f" symbols with "defined" operator.
version 1.66 (May 7, 2006)
[+] Allowed "as" operator to specify the output file extension when
placed at the end of the "format" directive line. [+] Added "define" directive to preprocessor, which defines symbolic constants,
the same kind as "equ" directive, however there's an important difference
[-] Definition of macro with the same name as one of the preprocessor's directives that "define" doesn't process symbolic constants in the value before
is no longer allowed. assigning it. For example:
[+] Allowed single quote character to be put inside the number value, a equ 1
to help improve long numbers readability. a equ a+a
[+] Added optional symbolic information output, and a set of tools that extract define b 1
various kinds of information from it. define b b+b
[+] Added "err" directive that allows to signalize error from the source. 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
macroinstructions.
version 1.66 (May 7, 2006)
[-] Moved part of the conditional expression processing into parser,
[+] Added "define" directive to preprocessor, which defines symbolic constants, for slightly better performance and lesser memory usage by assembler.
the same kind as "equ" directive, however there's an important difference The logical values defined with "eq", "eqtype" and "in" operators are now
that "define" doesn't process symbolic constants in the value before evaluated by the parser and if they are enough to determine the condition,
assigning it. For example: the whole block is processed accordingly. Thus this block:
a equ 1 if eax eq EAX | 0/0
a equ a+a nop
end if
define b 1
define b b+b 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
defines the "a" constant with value "1+1", but the "b" is defined with sense - but since this is none of the "eq", "eqtype" and "in" expressions,
value "b+b". This directive may be useful in some advanced the parser doesn't investigate.
macroinstructions.
[-] Also the assembler is now calculating only as many logical values as it
[-] Moved part of the conditional expression processing into parser, needs to determine the condition. So this block:
for slightly better performance and lesser memory usage by assembler.
The logical values defined with "eq", "eqtype" and "in" operators are now if defined alpha & alpha
evaluated by the parser and if they are enough to determine the condition,
the whole block is processed accordingly. Thus this block: end if
if eax eq EAX | 0/0 will not cause error when "alpha" is not defined, as it would with previous
nop versions. This is because after checking that "defined alpha" is false
end if condition it doesn't need to know the second logical value to determine the
value of conjunction.
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 [+] Added "short" keyword for specifying jump type, the "jmp byte" form is now
sense - but since this is none of the "eq", "eqtype" and "in" expressions, obsolete and no longer correct - use "jmp short" instead.
the parser doesn't investigate.
[-] The size operator applied to jump no longer applies to the size of relative
[-] Also the assembler is now calculating only as many logical values as it displacement - now it applies to the size of target address.
needs to determine the condition. So this block:
[-] The "ret" instruction with 0 parameter is now assembled into short form,
if defined alpha & alpha unless you force using the 16-bit immediate with "word" operator.
end if [+] Added missing extended registers for the 32-bit addressing in long mode.
will not cause error when "alpha" is not defined, as it would with previous [+] Added "linkremove" and "linkinfo" section flags for MS COFF output.
versions. This is because after checking that "defined alpha" is false
condition it doesn't need to know the second logical value to determine the [+] Added support for GOT offsets in ELF object formatter, which can be useful
value of conjunction. when making position-independent code for shared libraries. For any label
you can get its offset relative to GOT by preceding it with "rva" operator
[+] Added "short" keyword for specifying jump type, the "jmp byte" form is now (the same keyword as for PE format is used, to avoid adding a new one,
obsolete and no longer correct - use "jmp short" instead. while this one has very similar meaning).
[-] The size operator applied to jump no longer applies to the size of relative [-] Changed ELF executable to use "segment" directive in place of "section",
displacement - now it applies to the size of target address. to make the distinction between the run-time segments and linkable
sections. If you had a "section" directive in your ELF executables and they
[-] The "ret" instruction with 0 parameter is now assembled into short form, no longer assemble, replace it with "segment".
unless you force using the 16-bit immediate with "word" operator.
[-] The PE formatter now always creates the fixups directory when told to -
[+] Added missing extended registers for the 32-bit addressing in long mode. even when there are no fixups to be put there (in such case it creates the
directory with one empty block).
[+] Added "linkremove" and "linkinfo" section flags for MS COFF output.
[-] Some of the internal structures have been extended to provide the
[+] Added support for GOT offsets in ELF object formatter, which can be useful possibility of making extensive symbol dumps.
when making position-independent code for shared libraries. For any label
you can get its offset relative to GOT by preceding it with "rva" operator [-] Corrected "fix" directive to keep the value intact before assigning it to the
(the same keyword as for PE format is used, to avoid adding a new one, prioritized constant.
while this one has very similar meaning).
[+] The ` operator now works with any kind of symbol; when used with quoted
[-] Changed ELF executable to use "segment" directive in place of "section", string it simply does nothing. Thus the sequence of ` operators applied to
to make the distinction between the run-time segments and linkable one symbol work the same as if there was just one. In similar manner, the
sections. If you had a "section" directive in your ELF executables and they sequence of # operators now works as if it was a single one - using such a
no longer assemble, replace it with "segment". sequence instead of escaping, which was kept for some backward
compatibility, is now deprecated.
[-] The PE formatter now always creates the fixups directory when told to -
even when there are no fixups to be put there (in such case it creates the [-] Corrected order of identifying assembler directives ("if db eq db" was
directory with one empty block). incorrectly interpreted as data definition).
[-] Some of the internal structures have been extended to provide the [-] Many other small bugs fixed.
possibility of making extensive symbol dumps.
[-] Corrected "fix" directive to keep the value intact before assigning it to the version 1.64 (Aug 8, 2005)
prioritized constant.
[+] Output of PE executables for Win64 architecture (with "format PE64"
[+] The ` operator now works with any kind of symbol; when used with quoted setting).
string it simply does nothing. Thus the sequence of ` operators applied to
one symbol work the same as if there was just one. In similar manner, the [+] Added "while" and "break" directives.
sequence of # operators now works as if it was a single one - using such a
sequence instead of escaping, which was kept for some backward [+] Added "irp" and "irps" directives.
compatibility, is now deprecated.
[+] The macro arguments can be marked as required with the "*" character.
[-] Corrected order of identifying assembler directives ("if db eq db" was
incorrectly interpreted as data definition). [-] Fixed checking for overflow when multiplying 64-bit values - the result
must always fit in the range of signed 64 integer now.
[-] Many other small bugs fixed.
[-] Segment prefixes were generated incorrectly in 16-bit mode when BP was used
as a second addressing register - fixed.
version 1.64 (Aug 8, 2005)
[-] The "local" directive was not creating unique labels in some cases - fixed.
[+] Output of PE executables for Win64 architecture (with "format PE64"
setting). [-] The "not encodable with long immediate" error in 64-bit mode was sometimes
wrongly signaled - fixed.
[+] Added "while" and "break" directives.
[-] Other minor fixes and corrections.
[+] Added "irp" and "irps" directives.
[+] The macro arguments can be marked as required with the "*" character. version 1.62 (Jun 14, 2005)
[-] Fixed checking for overflow when multiplying 64-bit values - the result [+] Escaping of symbols inside macroinstructions with backslash.
must always fit in the range of signed 64 integer now.
[+] Ability of outputting the COFF object files for Win64 architecture
[-] Segment prefixes were generated incorrectly in 16-bit mode when BP was used (with "format MS64 COFF" setting).
as a second addressing register - fixed.
[+] New preprocessor directives: "restruc", "rept" and "match"
[-] The "local" directive was not creating unique labels in some cases - fixed.
[+] VMX instructions support (not documented).
[-] The "not encodable with long immediate" error in 64-bit mode was sometimes
wrongly signaled - fixed. [+] Extended data directives to allow use of the "dup" operator.
[-] Other minor fixes and corrections. [+] Extended "struc" features to allow custom definitions of main structure's
label.
version 1.62 (Jun 14, 2005) [-] When building resources from the the .RES file that contained more
than one resource of the same string name, the separate resource
[+] Escaping of symbols inside macroinstructions with backslash. directories were created with the same names - fixed.
[+] Ability of outputting the COFF object files for Win64 architecture [-] Several bugs in the ELF64 object output has been fixed.
(with "format MS64 COFF" setting).
[-] Corrected behavior of "fix" directive to more straightforward.
[+] New preprocessor directives: "restruc", "rept" and "match"
[-] Fixed bug in "include" directive, which caused files included from within
[+] VMX instructions support (not documented). macros to be processed the wrong way.
[+] Extended data directives to allow use of the "dup" operator.
[+] Extended "struc" features to allow custom definitions of main structure's
label.
[-] When building resources from the the .RES file that contained more
than one resource of the same string name, the separate resource
directories were created with the same names - fixed.
[-] Several bugs in the ELF64 object output has been fixed.
[-] Corrected behavior of "fix" directive to more straightforward.
[-] Fixed bug in "include" directive, which caused files included from within
macros to be processed the wrong way.

View File

@ -35,6 +35,8 @@ assembler:
mov [file_extension],eax mov [file_extension],eax
mov [next_pass_needed],al mov [next_pass_needed],al
mov [output_format],al mov [output_format],al
mov [org_origin_sign],al
mov [adjustment_sign],al
mov [labels_type],al mov [labels_type],al
mov [virtual_data],al mov [virtual_data],al
mov [code_type],16 mov [code_type],16
@ -169,6 +171,8 @@ assemble_line:
mov [prefixed_instruction],0 mov [prefixed_instruction],0
cmp [symbols_file],0 cmp [symbols_file],0
je continue_line je continue_line
cmp [next_pass_needed],0
jne continue_line
mov ebx,[display_buffer] mov ebx,[display_buffer]
mov dword [ebx-4],1 mov dword [ebx-4],1
mov dword [ebx-8],1Ch mov dword [ebx-8],1Ch
@ -185,6 +189,11 @@ assemble_line:
mov [ebx+8+4],edx mov [ebx+8+4],edx
mov [ebx+10h],ecx mov [ebx+10h],ecx
mov edx,[org_symbol] mov edx,[org_symbol]
; mov al,[virtual_data]
; mov ah,[org_origin_sign]
; shl eax,16
; mov al,[labels_type]
; mov ah,[code_type]
mov eax,dword [labels_type] mov eax,dword [labels_type]
mov [ebx+14h],edx mov [ebx+14h],edx
mov [ebx+18h],eax mov [ebx+18h],eax
@ -199,24 +208,39 @@ assemble_line:
je reserved_word_used_as_symbol je reserved_word_used_as_symbol
mov ebx,eax mov ebx,eax
lods byte [esi] lods byte [esi]
mov cl,al mov [label_size],al
call make_label
jmp continue_line
make_label:
mov eax,edi mov eax,edi
xor edx,edx xor edx,edx
xor cl,cl
sub eax,dword [org_origin] sub eax,dword [org_origin]
sbb edx,dword [org_origin+4] sbb edx,dword [org_origin+4]
mov ch,[labels_type] sbb cl,[org_origin_sign]
jp label_value_ok
call recoverable_overflow
label_value_ok:
mov [address_sign],cl
cmp [virtual_data],0 cmp [virtual_data],0
jne make_virtual_label jne make_virtual_label
or byte [ebx+9],1 or byte [ebx+9],1
xchg eax,[ebx] xchg eax,[ebx]
xchg edx,[ebx+4] xchg edx,[ebx+4]
mov ch,[ebx+9]
shr ch,1
and ch,1
neg ch
sub eax,[ebx] sub eax,[ebx]
sbb edx,[ebx+4] sbb edx,[ebx+4]
sbb ch,cl
mov dword [adjustment],eax mov dword [adjustment],eax
mov dword [adjustment+4],edx mov dword [adjustment+4],edx
mov [adjustment_sign],ch
or al,ch
or eax,edx or eax,edx
setnz ah setnz ah
jmp finish_label_symbol jmp finish_label
make_virtual_label: make_virtual_label:
and byte [ebx+9],not 1 and byte [ebx+9],not 1
cmp eax,[ebx] cmp eax,[ebx]
@ -226,7 +250,17 @@ assemble_line:
mov [ebx+4],edx mov [ebx+4],edx
setne al setne al
or ah,al or ah,al
finish_label:
mov ch,[labels_type]
mov cl,[label_size]
mov ebp,[org_registers]
mov edx,[org_symbol]
finish_label_symbol: finish_label_symbol:
mov al,[address_sign]
xor al,[ebx+9]
and al,10b
or ah,al
xor [ebx+9],al
cmp cl,[ebx+10] cmp cl,[ebx+10]
mov [ebx+10],cl mov [ebx+10],cl
setne al setne al
@ -235,14 +269,12 @@ assemble_line:
mov [ebx+11],ch mov [ebx+11],ch
setne al setne al
or ah,al or ah,al
mov edx,[org_registers] cmp ebp,[ebx+12]
cmp edx,[ebx+12] mov [ebx+12],ebp
mov [ebx+12],edx
setne al setne al
or ah,al or ah,al
or ch,ch or ch,ch
jz label_symbol_ok jz label_symbol_ok
mov edx,[org_symbol]
cmp edx,[ebx+20] cmp edx,[ebx+20]
mov [ebx+20],edx mov [ebx+20],edx
setne al setne al
@ -261,17 +293,18 @@ assemble_line:
sub cx,[ebx+16] sub cx,[ebx+16]
setnz al setnz al
or ah,al or ah,al
jz continue_line jz label_made
test byte [ebx+8],8 test byte [ebx+8],8
jz continue_line jz label_made
mov cx,[current_pass] mov cx,[current_pass]
cmp cx,[ebx+18] cmp cx,[ebx+18]
jne continue_line jne label_made
or [next_pass_needed],-1 or [next_pass_needed],-1
jmp continue_line label_made:
ret
new_label: new_label:
or byte [ebx+8],1 or byte [ebx+8],1
jmp continue_line ret
define_constant: define_constant:
lods dword [esi] lods dword [esi]
inc esi inc esi
@ -293,6 +326,7 @@ assemble_line:
push eax push eax
mov al,byte [esi-1] mov al,byte [esi-1]
push eax push eax
or [size_override],-1
call get_value call get_value
pop ebx pop ebx
mov ch,bl mov ch,bl
@ -314,6 +348,11 @@ assemble_line:
mov [ebx+4],edx mov [ebx+4],edx
setne al setne al
or ah,al or ah,al
mov al,[value_sign]
xor al,[ebx+9]
and al,10b
or ah,al
xor [ebx+9],al
cmp cl,[ebx+10] cmp cl,[ebx+10]
mov [ebx+10],cl mov [ebx+10],cl
setne al setne al
@ -370,12 +409,12 @@ assemble_line:
; mov [size_override],0 ; mov [size_override],0
; mov [operand_prefix],0 ; mov [operand_prefix],0
; mov [opcode_prefix],0 ; mov [opcode_prefix],0
mov dword [operand_size],0 and dword [operand_size],0
; mov [rex_prefix],0 ; mov [rex_prefix],0
; mov [vex_required],0 ; mov [vex_required],0
; mov [vex_register],0 ; mov [vex_register],0
; mov [immediate_size],0 ; mov [immediate_size],0
mov dword [rex_prefix],0 and dword [rex_prefix],0
call instruction_handler call instruction_handler
instruction_handler: instruction_handler:
movzx ebx,word [esi] movzx ebx,word [esi]
@ -408,13 +447,18 @@ org_directive:
test cl,1 test cl,1
jnz invalid_use_of_symbol jnz invalid_use_of_symbol
mov [labels_type],cl mov [labels_type],cl
mov ecx,edi mov dword [org_origin],edi
sub ecx,eax xor ecx,ecx
adc edx,0 mov dword [org_origin+4],ecx
neg edx mov [org_origin_sign],cl
mov dword [org_origin],ecx mov [org_registers],ecx
mov dword [org_origin+4],edx mov cl,[value_sign]
mov [org_registers],0 sub dword [org_origin],eax
sbb dword [org_origin+4],edx
sbb [org_origin_sign],cl
jp org_value_ok
call recoverable_overflow
org_value_ok:
mov [org_start],edi mov [org_start],edi
mov edx,[symbol_identifier] mov edx,[symbol_identifier]
mov [org_symbol],edx mov [org_symbol],edx
@ -436,7 +480,7 @@ label_directive:
je reserved_word_used_as_symbol je reserved_word_used_as_symbol
inc esi inc esi
mov ebx,eax mov ebx,eax
xor cl,cl mov [label_size],0
lods byte [esi] lods byte [esi]
cmp al,':' cmp al,':'
je get_label_size je get_label_size
@ -447,30 +491,12 @@ label_directive:
lods word [esi] lods word [esi]
cmp al,11h cmp al,11h
jne invalid_argument jne invalid_argument
mov cl,ah mov [label_size],ah
label_size_ok: label_size_ok:
mov eax,edi
xor edx,edx
sub eax,dword [org_origin]
sbb edx,dword [org_origin+4]
mov ebp,[org_registers]
cmp byte [esi],80h cmp byte [esi],80h
je get_free_label_value je get_free_label_value
mov ch,[labels_type] call make_label
push [org_symbol] jmp instruction_assembled
pop [address_symbol]
cmp [virtual_data],0
jne make_free_label
or byte [ebx+9],1
xchg eax,[ebx]
xchg edx,[ebx+4]
sub eax,[ebx]
sbb edx,[ebx+4]
mov dword [adjustment],eax
mov dword [adjustment+4],edx
or eax,edx
setne ah
jmp finish_label
get_free_label_value: get_free_label_value:
inc esi inc esi
lods byte [esi] lods byte [esi]
@ -507,50 +533,9 @@ label_directive:
mov [ebx+4],edx mov [ebx+4],edx
setne al setne al
or ah,al or ah,al
finish_label:
cmp cl,[ebx+10]
mov [ebx+10],cl
setne al
or ah,al
cmp ch,[ebx+11]
mov [ebx+11],ch
setne al
or ah,al
cmp ebp,[ebx+12]
mov [ebx+12],ebp
setne al
or ah,al
or ch,ch
jz free_label_symbol_ok
mov edx,[address_symbol] mov edx,[address_symbol]
cmp edx,[ebx+20] mov cl,[label_size]
mov [ebx+20],edx call finish_label_symbol
setne al
or ah,al
free_label_symbol_ok:
mov cx,[current_pass]
xchg [ebx+16],cx
mov edx,[current_line]
mov [ebx+28],edx
and byte [ebx+8],not 2
test byte [ebx+8],1
jz new_free_label
cmp cx,[ebx+16]
je symbol_already_defined
inc cx
sub cx,[ebx+16]
setnz al
or ah,al
jz instruction_assembled
test byte [ebx+8],8
jz instruction_assembled
mov cx,[current_pass]
cmp cx,[ebx+18]
jne instruction_assembled
or [next_pass_needed],-1
jmp instruction_assembled
new_free_label:
or byte [ebx+8],1
jmp instruction_assembled jmp instruction_assembled
load_directive: load_directive:
lods byte [esi] lods byte [esi]
@ -571,8 +556,8 @@ load_directive:
cmp al,8 cmp al,8
ja invalid_value ja invalid_value
mov [operand_size],al mov [operand_size],al
mov dword [value],0 and dword [value],0
mov dword [value+4],0 and dword [value+4],0
lods word [esi] lods word [esi]
cmp ax,82h+'(' shl 8 cmp ax,82h+'(' shl 8
jne invalid_argument jne invalid_argument
@ -603,13 +588,10 @@ load_directive:
rep movs byte [edi],[esi] rep movs byte [edi],[esi]
jmp value_loaded jmp value_loaded
bad_load_address: bad_load_address:
cmp [error_line],0 call recoverable_overflow
jne value_loaded
mov eax,[current_line]
mov [error_line],eax
mov [error],value_out_of_range
value_loaded: value_loaded:
pop edi esi pop edi esi
mov [value_sign],0
mov eax,dword [value] mov eax,dword [value]
mov edx,dword [value+4] mov edx,dword [value+4]
pop ebx pop ebx
@ -627,6 +609,7 @@ store_directive:
mov [operand_size],1 mov [operand_size],1
jmp store_value_ok jmp store_value_ok
sized_store: sized_store:
or [size_override],-1
call get_value call get_value
store_value_ok: store_value_ok:
cmp [value_type],0 cmp [value_type],0
@ -669,11 +652,7 @@ store_directive:
jmp instruction_assembled jmp instruction_assembled
bad_store_address: bad_store_address:
pop edi esi pop edi esi
cmp [error_line],0 call recoverable_overflow
jne instruction_assembled
mov eax,[current_line]
mov [error_line],eax
mov [error],value_out_of_range
jmp instruction_assembled jmp instruction_assembled
display_directive: display_directive:
@ -795,10 +774,8 @@ virtual_directive:
je invalid_value je invalid_value
call get_address_value call get_address_value
mov ebp,[address_symbol] mov ebp,[address_symbol]
xor ch,ch
or bh,bh or bh,bh
jz set_virtual setnz ch
mov ch,1
jmp set_virtual jmp set_virtual
virtual_at_current: virtual_at_current:
dec esi dec esi
@ -807,8 +784,11 @@ virtual_directive:
mov ebp,[org_symbol] mov ebp,[org_symbol]
mov eax,edi mov eax,edi
xor edx,edx xor edx,edx
xor cl,cl
sub eax,dword [org_origin] sub eax,dword [org_origin]
sbb edx,dword [org_origin+4] sbb edx,dword [org_origin+4]
sbb cl,[org_origin_sign]
mov [address_sign],cl
mov bx,word [org_registers] mov bx,word [org_registers]
mov cx,word [org_registers+2] mov cx,word [org_registers+2]
xchg bh,bl xchg bh,bl
@ -821,19 +801,27 @@ virtual_directive:
mov byte [org_registers+3],cl mov byte [org_registers+3],cl
call allocate_structure_data call allocate_structure_data
mov word [ebx],virtual_directive-instruction_handler mov word [ebx],virtual_directive-instruction_handler
mov cl,[address_sign]
not eax not eax
not edx not edx
not cl
add eax,1 add eax,1
adc edx,0 adc edx,0
adc cl,0
add eax,edi add eax,edi
adc edx,0 adc edx,0
adc cl,0
xchg dword [org_origin],eax xchg dword [org_origin],eax
xchg dword [org_origin+4],edx xchg dword [org_origin+4],edx
xchg [org_origin_sign],cl
mov [ebx+10h],eax mov [ebx+10h],eax
mov [ebx+14h],edx mov [ebx+14h],edx
pop eax pop eax
mov [ebx+18h],eax mov [ebx+18h],eax
mov al,[virtual_data] mov al,[virtual_data]
and al,0Fh
shl cl,4
or al,cl
mov [ebx+2],al mov [ebx+2],al
mov al,[labels_type] mov al,[labels_type]
mov [ebx+3],al mov [ebx+3],al
@ -876,7 +864,14 @@ virtual_directive:
call find_structure_data call find_structure_data
jc unexpected_instruction jc unexpected_instruction
mov al,[ebx+2] mov al,[ebx+2]
mov ah,al
shr ah,4
and al,1
neg al
and ah,1
neg ah
mov [virtual_data],al mov [virtual_data],al
mov [org_origin_sign],ah
mov al,[ebx+3] mov al,[ebx+3]
mov [labels_type],al mov [labels_type],al
mov eax,[ebx+10h] mov eax,[ebx+10h]
@ -1339,7 +1334,7 @@ data_words:
cmp al,'?' cmp al,'?'
jne invalid_argument jne invalid_argument
mov eax,edi mov eax,edi
mov word [edi],0 and word [edi],0
scas word [edi] scas word [edi]
jmp undefined_data jmp undefined_data
ret ret
@ -1377,7 +1372,7 @@ data_dwords:
cmp al,'?' cmp al,'?'
jne invalid_argument jne invalid_argument
mov eax,edi mov eax,edi
mov dword [edi],0 and dword [edi],0
scas dword [edi] scas dword [edi]
jmp undefined_data jmp undefined_data
get_dword: get_dword:
@ -1420,9 +1415,9 @@ data_pwords:
cmp al,'?' cmp al,'?'
jne invalid_argument jne invalid_argument
mov eax,edi mov eax,edi
mov dword [edi],0 and dword [edi],0
scas dword [edi] scas dword [edi]
mov word [edi],0 and word [edi],0
scas word [edi] scas word [edi]
jmp undefined_data jmp undefined_data
get_pword: get_pword:
@ -1467,9 +1462,9 @@ data_qwords:
cmp al,'?' cmp al,'?'
jne invalid_argument jne invalid_argument
mov eax,edi mov eax,edi
mov dword [edi],0 and dword [edi],0
scas dword [edi] scas dword [edi]
mov dword [edi],0 and dword [edi],0
scas dword [edi] scas dword [edi]
jmp undefined_data jmp undefined_data
get_qword: get_qword:
@ -1487,11 +1482,11 @@ data_twords:
cmp al,'?' cmp al,'?'
jne invalid_argument jne invalid_argument
mov eax,edi mov eax,edi
mov dword [edi],0 and dword [edi],0
scas dword [edi] scas dword [edi]
mov dword [edi],0 and dword [edi],0
scas dword [edi] scas dword [edi]
mov word [edi],0 and word [edi],0
scas word [edi] scas word [edi]
jmp undefined_data jmp undefined_data
get_tword: get_tword:
@ -1647,7 +1642,7 @@ data_file:
mov esi,[eax] mov esi,[eax]
test byte [eax+7],80h test byte [eax+7],80h
jz get_current_path jz get_current_path
mov eax,[eax+12] mov eax,[eax+8]
jmp find_current_source_path jmp find_current_source_path
get_current_path: get_current_path:
lodsb lodsb
@ -1665,15 +1660,31 @@ data_file:
jmp cut_current_path jmp cut_current_path
current_path_ok: current_path_ok:
mov esi,[esp+4] mov esi,[esp+4]
call preprocess_path call expand_path
pop edx pop edx
mov esi,edx mov esi,edx
call open call open
jnc file_opened jnc file_opened
mov edx,[include_paths]
search_in_include_paths:
push edx esi
mov edi,esi
mov esi,[esp+4]
call get_include_directory
mov [esp+4],esi
mov esi,[esp+8]
call expand_path
pop edx
mov esi,edx
call open
pop edx
jnc file_opened
cmp byte [edx],0
jne search_in_include_paths
mov edi,esi mov edi,esi
mov esi,[esp] mov esi,[esp]
push edi push edi
call preprocess_path call expand_path
pop edx pop edx
mov esi,edx mov esi,edx
call open call open

File diff suppressed because it is too large Load Diff

View File

@ -72,8 +72,8 @@ invalid_address_size:
address_sizes_do_not_agree: address_sizes_do_not_agree:
push _address_sizes_do_not_agree push _address_sizes_do_not_agree
jmp error_with_source jmp error_with_source
prefix_conflict: disallowed_combination_of_registers:
push _prefix_conflict push _disallowed_combination_of_registers
jmp error_with_source jmp error_with_source
long_immediate_not_encodable: long_immediate_not_encodable:
push _long_immediate_not_encodable push _long_immediate_not_encodable

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
; flat assembler core ; flat assembler core
; Copyright (c) 1999-2012, Tomasz Grysztar. ; Copyright (c) 1999-2012, Tomasz Grysztar.
; All rights reserved. ; All rights reserved.
convert_expression: convert_expression:
push ebp push ebp
call get_fp_value call get_fp_value
jnc fp_expression jnc fp_expression
@ -12,14 +12,14 @@ convert_expression:
push edi push edi
mov edi,single_operand_operators mov edi,single_operand_operators
call get_operator call get_operator
pop edi pop edi
or al,al or al,al
jz expression_element jz expression_element
cmp al,82h cmp al,82h
je expression_loop je expression_loop
push eax push eax
jmp expression_loop jmp expression_loop
expression_element: expression_element:
mov al,[esi] mov al,[esi]
cmp al,1Ah cmp al,1Ah
je expression_number je expression_number
@ -131,17 +131,45 @@ convert_number:
cmp al,')' cmp al,')'
jne invalid_expression jne invalid_expression
ret ret
symbol_value: symbol_value:
cmp [source_start],0 cmp [source_start],0
je preprocessor_value je preprocessor_value
push edi push edi esi
mov edi,address_registers lods word [esi]
call get_operator cmp al,1Ah
or al,al jne no_address_register
jnz register_value movzx ecx,ah
mov edi,directive_operators call get_symbol
call get_operator jc no_address_register
pop edi cmp al,10h
jne no_address_register
mov al,ah
shr ah,4
cmp ah,4
je register_value
cmp ah,8
je register_value
cmp ah,0Ch
je register_value
cmp ah,0Dh
je register_value
cmp ah,0Fh
je register_value
cmp ah,2
jne no_address_register
cmp al,23h
je register_value
cmp al,25h
je register_value
cmp al,26h
je register_value
cmp al,27h
je register_value
no_address_register:
pop esi
mov edi,directive_operators
call get_operator
pop edi
or al,al or al,al
jnz broken_value jnz broken_value
lods byte [esi] lods byte [esi]
@ -155,13 +183,13 @@ convert_number:
stos dword [edi] stos dword [edi]
ret ret
broken_value: broken_value:
mov eax,0Fh mov eax,0Fh
jmp store_label_value jmp store_label_value
register_value: register_value:
pop edi pop edx edi
mov byte [edi-1],10h mov byte [edi-1],10h
stos byte [edi] stos byte [edi]
ret ret
preprocessor_value: preprocessor_value:
dec edi dec edi
cmp [hash_tree],0 cmp [hash_tree],0
@ -390,18 +418,18 @@ get_number:
cmp al,7 cmp al,7
ja bad_number ja bad_number
oct_digit_ok: oct_digit_ok:
xor edx,edx xor edx,edx
mov cl,bl mov cl,bl
dec esi dec esi
cmp bl,63 cmp bl,63
ja oct_out_of_range ja oct_out_of_range
jne oct_range_ok jne oct_range_ok
cmp al,1 cmp al,1
ja oct_out_of_range ja oct_out_of_range
oct_range_ok: oct_range_ok:
add bl,3 add bl,3
cmp cl,30 cmp cl,30
je oct_digit_wrap je oct_digit_wrap
ja oct_digit_high ja oct_digit_high
shl eax,cl shl eax,cl
or dword [edi],eax or dword [edi],eax

View File

@ -35,14 +35,15 @@ formatter:
jae out_of_memory jae out_of_memory
cmp [file_extension],0 cmp [file_extension],0
jne extension_specified jne extension_specified
cmp [output_format],2 mov al,[output_format]
cmp al,2
je exe_extension je exe_extension
jb bin_extension jb bin_extension
cmp [output_format],4 cmp al,4
je obj_extension je obj_extension
cmp [output_format],5 cmp al,5
je o_extension je o_extension
cmp [output_format],3 cmp al,3
jne no_extension jne no_extension
cmp [subsystem],1 cmp [subsystem],1
je sys_extension je sys_extension
@ -164,7 +165,7 @@ formatter:
mov [current_offset],edi mov [current_offset],edi
sub edi,[code_start] sub edi,[code_start]
mov [code_size],edi mov [code_size],edi
mov [written_size],0 and [written_size],0
mov edx,[output_file] mov edx,[output_file]
call create call create
jc write_failed jc write_failed
@ -324,10 +325,18 @@ public_directive:
cmp eax,0Fh cmp eax,0Fh
jb invalid_use_of_symbol jb invalid_use_of_symbol
je reserved_word_used_as_symbol je reserved_word_used_as_symbol
inc esi
mov dx,[current_pass] mov dx,[current_pass]
mov [eax+18],dx mov [eax+18],dx
or byte [eax+8],8 or byte [eax+8],8
inc esi cmp [symbols_file],0
je public_reference_ok
cmp [next_pass_needed],0
jne public_reference_ok
mov ebx,eax
call store_label_reference
mov eax,ebx
public_reference_ok:
mov ebx,[free_additional_memory] mov ebx,[free_additional_memory]
lea edx,[ebx+10h] lea edx,[ebx+10h]
cmp edx,[structures_buffer] cmp edx,[structures_buffer]
@ -395,6 +404,7 @@ extrn_directive:
jne invalid_argument jne invalid_argument
extrn_size_ok: extrn_size_ok:
mov [address_symbol],edx mov [address_symbol],edx
mov [label_size],ah
movzx ecx,ah movzx ecx,ah
mov [edx+8],ecx mov [edx+8],ecx
xor eax,eax xor eax,eax
@ -485,6 +495,7 @@ mz_segment:
rep stos byte [edi] rep stos byte [edi]
mov dword [org_origin],edi mov dword [org_origin],edi
mov dword [org_origin+4],eax mov dword [org_origin+4],eax
mov [org_origin_sign],al
mov [org_registers],eax mov [org_registers],eax
mov [org_start],edi mov [org_start],edi
mov eax,edx mov eax,edx
@ -503,7 +514,8 @@ mz_segment:
segment_type_ok: segment_type_ok:
mov [code_type],al mov [code_type],al
mov eax,edx mov eax,edx
mov cx,0100h mov ch,1
mov [label_size],0
xor edx,edx xor edx,edx
xor ebp,ebp xor ebp,ebp
mov [address_symbol],edx mov [address_symbol],edx
@ -515,11 +527,7 @@ mz_entry:
call get_word_value call get_word_value
cmp [value_type],1 cmp [value_type],1
je initial_cs_ok je initial_cs_ok
cmp [error_line],0 call recoverable_invalid_address
jne initial_cs_ok
mov eax,[current_line]
mov [error_line],eax
mov [error],invalid_address
initial_cs_ok: initial_cs_ok:
mov edx,[additional_memory] mov edx,[additional_memory]
mov [edx+16h],ax mov [edx+16h],ax
@ -536,6 +544,14 @@ mz_entry:
mov edx,[additional_memory] mov edx,[additional_memory]
mov [edx+14h],ax mov [edx+14h],ax
jmp instruction_assembled jmp instruction_assembled
recoverable_invalid_address:
cmp [error_line],0
jne ignore_invalid_address
push [current_line]
pop [error_line]
mov [error],invalid_address
ignore_invalid_address:
ret
mz_stack: mz_stack:
lods byte [esi] lods byte [esi]
cmp al,'(' cmp al,'('
@ -553,11 +569,7 @@ mz_stack:
stack_pointer: stack_pointer:
cmp [value_type],1 cmp [value_type],1
je initial_ss_ok je initial_ss_ok
cmp [error_line],0 call recoverable_invalid_address
jne initial_ss_ok
mov eax,[current_line]
mov [error_line],eax
mov [error],invalid_address
initial_ss_ok: initial_ss_ok:
mov edx,[additional_memory] mov edx,[additional_memory]
mov [edx+0Eh],ax mov [edx+0Eh],ax
@ -834,7 +846,7 @@ format_pe:
mov [subsystem],3 mov [subsystem],3
mov [subsystem_version],3 + 10 shl 16 mov [subsystem_version],3 + 10 shl 16
mov [image_base],400000h mov [image_base],400000h
mov [image_base_high],0 and [image_base_high],0
test [format_flags],8 test [format_flags],8
jz pe_settings jz pe_settings
mov [machine],8664h mov [machine],8664h
@ -1061,7 +1073,7 @@ format_pe:
jc pe_entry_init_ok jc pe_entry_init_ok
mov [edx+28h],eax ; entry point rva mov [edx+28h],eax ; entry point rva
pe_entry_init_ok: pe_entry_init_ok:
mov [number_of_sections],0 and [number_of_sections],0
movzx ebx,word [edx+14h] movzx ebx,word [edx+14h]
lea ebx,[edx+18h+ebx] lea ebx,[edx+18h+ebx]
mov [current_section],ebx mov [current_section],ebx
@ -1071,38 +1083,45 @@ format_pe:
mov [ebx+0Ch],eax mov [ebx+0Ch],eax
mov dword [ebx+24h],0E0000060h mov dword [ebx+24h],0E0000060h
xor ecx,ecx xor ecx,ecx
xor bl,bl
not eax not eax
not ecx not ecx
not bl
add eax,1 add eax,1
adc ecx,0 adc ecx,0
adc bl,0
add eax,edi add eax,edi
adc ecx,0 adc ecx,0
adc bl,0
test [format_flags],4 test [format_flags],4
jnz peplus_org jnz peplus_org
sub eax,[edx+34h] sub eax,[edx+34h]
sbb ecx,0 sbb ecx,0
sbb bl,0
jmp pe_org_ok jmp pe_org_ok
peplus_org: peplus_org:
sub eax,[edx+30h] sub eax,[edx+30h]
sbb ecx,[edx+34h] sbb ecx,[edx+34h]
sbb bl,0
pe_org_ok: pe_org_ok:
test [format_flags],8 test [format_flags],8
jnz pe64_code jnz pe64_code
mov bl,2 mov bh,2
mov [code_type],32 mov [code_type],32
jmp pe_code_type_ok jmp pe_code_type_ok
pe64_code: pe64_code:
mov bl,4 mov bh,4
mov [code_type],64 mov [code_type],64
pe_code_type_ok: pe_code_type_ok:
bt [resolver_flags],0 bt [resolver_flags],0
jc pe_labels_type_ok jc pe_labels_type_ok
xor bl,bl xor bh,bh
pe_labels_type_ok: pe_labels_type_ok:
mov [labels_type],bl mov [labels_type],bh
mov dword [org_origin],eax mov dword [org_origin],eax
mov dword [org_origin+4],ecx mov dword [org_origin+4],ecx
mov [org_registers],0 mov [org_origin_sign],bl
and [org_registers],0
mov [org_start],edi mov [org_start],edi
bt [format_flags],8 bt [format_flags],8
jnc dll_flag_ok jnc dll_flag_ok
@ -1155,13 +1174,15 @@ pe_section:
mov esi,edx mov esi,edx
rep movs byte [edi],[esi] rep movs byte [edi],[esi]
pop edi esi pop edi esi
mov dword [ebx+24h],0 and dword [ebx+24h],0
mov [ebx+14h],edi mov [ebx+14h],edi
mov edx,[code_start] mov edx,[code_start]
mov eax,edi mov eax,edi
xor ecx,ecx xor ecx,ecx
mov [org_origin_sign],0
sub eax,[ebx+0Ch] sub eax,[ebx+0Ch]
sbb ecx,0 sbb ecx,0
sbb [org_origin_sign],0
mov [labels_type],2 mov [labels_type],2
mov [code_type],32 mov [code_type],32
test [format_flags],8 test [format_flags],8
@ -1173,6 +1194,7 @@ pe_section:
jnz peplus_section_org jnz peplus_section_org
sub eax,[edx+34h] sub eax,[edx+34h]
sbb ecx,0 sbb ecx,0
sbb [org_origin_sign],0
bt [resolver_flags],0 bt [resolver_flags],0
jc pe_section_org_ok jc pe_section_org_ok
mov [labels_type],0 mov [labels_type],0
@ -1180,13 +1202,14 @@ pe_section:
peplus_section_org: peplus_section_org:
sub eax,[edx+30h] sub eax,[edx+30h]
sbb ecx,[edx+34h] sbb ecx,[edx+34h]
sbb [org_origin_sign],0
bt [resolver_flags],0 bt [resolver_flags],0
jc pe_section_org_ok jc pe_section_org_ok
mov [labels_type],0 mov [labels_type],0
pe_section_org_ok: pe_section_org_ok:
mov dword [org_origin],eax mov dword [org_origin],eax
mov dword [org_origin+4],ecx mov dword [org_origin+4],ecx
mov [org_registers],0 and [org_registers],0
mov [org_start],edi mov [org_start],edi
get_section_flags: get_section_flags:
lods byte [esi] lods byte [esi]
@ -1246,7 +1269,7 @@ pe_section:
jb align_section jb align_section
mov edi,[undefined_data_start] mov edi,[undefined_data_start]
align_section: align_section:
mov [undefined_data_end],0 and [undefined_data_end],0
mov ebp,edi mov ebp,edi
sub ebp,[ebx+14h] sub ebp,[ebx+14h]
mov ecx,[edx+3Ch] mov ecx,[edx+3Ch]
@ -1373,11 +1396,7 @@ pe_entry:
check_pe_entry_label_type: check_pe_entry_label_type:
cmp [value_type],bl cmp [value_type],bl
je pe_entry_ok je pe_entry_ok
cmp [error_line],0 call recoverable_invalid_address
jne pe_entry_ok
mov edx,[current_line]
mov [error_line],edx
mov [error],invalid_address
pe_entry_ok: pe_entry_ok:
cdq cdq
test [format_flags],4 test [format_flags],4
@ -1395,19 +1414,13 @@ pe_entry:
check_pe64_entry_label_type: check_pe64_entry_label_type:
cmp [value_type],bl cmp [value_type],bl
je pe64_entry_type_ok je pe64_entry_type_ok
cmp [error_line],0 call recoverable_invalid_address
jne pe64_entry_type_ok
mov edx,[current_line]
mov [error_line],edx
mov [error],invalid_address
pe64_entry_type_ok: pe64_entry_type_ok:
mov ecx,[code_start] mov ecx,[code_start]
sub eax,[ecx+30h] sub eax,[ecx+30h]
sbb edx,[ecx+34h] sbb edx,[ecx+34h]
jz pe64_entry_range_ok jz pe64_entry_range_ok
mov edx,[current_line] call recoverable_overflow
mov [error_line],edx
mov [error],value_out_of_range
pe64_entry_range_ok: pe64_entry_range_ok:
mov [ecx+28h],eax mov [ecx+28h],eax
jmp instruction_assembled jmp instruction_assembled
@ -1540,11 +1553,7 @@ mark_pe_relocation:
check_standard_pe_relocation_type: check_standard_pe_relocation_type:
cmp [value_type],2 cmp [value_type],2
je pe_relocation_type_ok je pe_relocation_type_ok
cmp [error_line],0 call recoverable_misuse
jne pe_relocation_type_ok
mov eax,[current_line]
mov [error_line],eax
mov [error],invalid_use_of_symbol
pe_relocation_type_ok: pe_relocation_type_ok:
mov ebx,[current_section] mov ebx,[current_section]
mov eax,edi mov eax,edi
@ -1580,7 +1589,7 @@ make_pe_fixups:
jc fixups_ready jc fixups_ready
or [next_pass_needed],-1 or [next_pass_needed],-1
fixups_ready: fixups_ready:
mov [last_fixup_base],0 and [last_fixup_base],0
call make_fixups call make_fixups
xchg eax,[actual_fixups_size] xchg eax,[actual_fixups_size]
sub eax,[actual_fixups_size] sub eax,[actual_fixups_size]
@ -1652,7 +1661,7 @@ make_pe_resource:
je resource_from_file je resource_from_file
cmp [current_pass],0 cmp [current_pass],0
jne reserve_space_for_resource jne reserve_space_for_resource
mov [resource_size],0 and [resource_size],0
reserve_space_for_resource: reserve_space_for_resource:
add edi,[resource_size] add edi,[resource_size]
cmp edi,[display_buffer] cmp edi,[display_buffer]
@ -2310,18 +2319,28 @@ format_coff:
mov [current_section],ebx mov [current_section],ebx
xor eax,eax xor eax,eax
mov [number_of_sections],eax mov [number_of_sections],eax
mov dword [org_origin],edi call setup_coff_section_org
mov dword [org_origin+4],eax
mov [org_registers],eax
mov [org_start],edi
mov [org_symbol],ebx
mov [labels_type],2
mov [code_type],32 mov [code_type],32
test [format_flags],8 test [format_flags],8
jz format_defined jz format_defined
mov [labels_type],4
mov [code_type],64 mov [code_type],64
jmp format_defined jmp format_defined
setup_coff_section_org:
xor eax,eax
mov dword [org_origin],edi
mov dword [org_origin+4],eax
mov [org_origin_sign],al
mov [org_registers],eax
mov [org_start],edi
mov [org_symbol],ebx
test [format_flags],8
jnz coff_64bit_labels
mov [labels_type],2
ret
coff_64bit_labels:
mov [labels_type],4
ret
coff_section: coff_section:
call close_coff_section call close_coff_section
mov ebx,[free_additional_memory] mov ebx,[free_additional_memory]
@ -2334,18 +2353,9 @@ coff_section:
xor eax,eax xor eax,eax
mov [ebx],al mov [ebx],al
mov [ebx+8],edi mov [ebx+8],edi
mov dword [org_origin],edi
mov dword [org_origin+4],eax
mov [org_registers],eax
mov [org_start],edi
mov [org_symbol],ebx
mov [labels_type],2
test [format_flags],8
jz coff_labels_type_ok
mov [labels_type],4
coff_labels_type_ok:
mov [ebx+10h],eax mov [ebx+10h],eax
mov [ebx+14h],eax mov [ebx+14h],eax
call setup_coff_section_org
lods word [esi] lods word [esi]
cmp ax,'(' cmp ax,'('
jne invalid_argument jne invalid_argument
@ -2552,8 +2562,8 @@ coff_formatter:
mov edx,[esi+8] mov edx,[esi+8]
add esi,10h add esi,10h
inc eax inc eax
cmp byte [edx+11],2 cmp byte [edx+11],0
jne enumerate_symbols je enumerate_symbols
mov edx,[edx+20] mov edx,[edx+20]
cmp byte [edx],0C0h cmp byte [edx],0C0h
jae enumerate_symbols jae enumerate_symbols
@ -2803,13 +2813,14 @@ coff_formatter:
mov cx,[ecx+1Eh] mov cx,[ecx+1Eh]
mov [ebx+0Ch],cx mov [ebx+0Ch],cx
public_symbol_section_ok: public_symbol_section_ok:
cmp dword [eax+4],0 movzx ecx,byte [eax+9]
je store_public_symbol shr cl,1
cmp dword [eax+4],-1 and cl,1
neg ecx
cmp ecx,[eax+4]
jne value_out_of_range jne value_out_of_range
bt dword [eax],31 xor ecx,[eax]
jnc value_out_of_range js value_out_of_range
store_public_symbol:
mov eax,[eax] mov eax,[eax]
mov [ebx+8],eax mov [ebx+8],eax
mov al,2 mov al,2
@ -2850,7 +2861,7 @@ coff_formatter:
mov [edx],eax mov [edx],eax
sub edi,[code_start] sub edi,[code_start]
mov [code_size],edi mov [code_size],edi
mov [written_size],0 and [written_size],0
mov edx,[output_file] mov edx,[output_file]
call create call create
jc write_failed jc write_failed
@ -2910,7 +2921,6 @@ format_elf:
mov [code_type],32 mov [code_type],32
cmp word [esi],1D19h cmp word [esi],1D19h
je format_elf_exe je format_elf_exe
mov [labels_type],2
elf_header_ok: elf_header_ok:
mov byte [edx+10h],1 mov byte [edx+10h],1
mov eax,[additional_memory] mov eax,[additional_memory]
@ -2923,11 +2933,6 @@ format_elf:
xor eax,eax xor eax,eax
mov [current_section],ebx mov [current_section],ebx
mov [number_of_sections],eax mov [number_of_sections],eax
mov dword [org_origin],edi
mov dword [org_origin+4],eax
mov [org_registers],eax
mov [org_start],edi
mov [org_symbol],ebx
mov [ebx],al mov [ebx],al
mov [ebx+4],eax mov [ebx+4],eax
mov [ebx+8],edi mov [ebx+8],edi
@ -2935,6 +2940,7 @@ format_elf:
mov [ebx+14h],eax mov [ebx+14h],eax
mov al,4 mov al,4
mov [ebx+10h],eax mov [ebx+10h],eax
call setup_coff_section_org
test [format_flags],8 test [format_flags],8
jz format_defined jz format_defined
mov byte [ebx+10h],8 mov byte [ebx+10h],8
@ -2958,9 +2964,8 @@ format_elf:
mov byte [edx+3Ah],40h mov byte [edx+3Ah],40h
mov [code_type],64 mov [code_type],64
cmp word [esi],1D19h cmp word [esi],1D19h
je format_elf64_exe jne elf_header_ok
mov [labels_type],4 jmp format_elf64_exe
jmp elf_header_ok
elf_section: elf_section:
bt [format_flags],0 bt [format_flags],0
jc illegal_instruction jc illegal_instruction
@ -2976,21 +2981,10 @@ elf_section:
xor eax,eax xor eax,eax
mov [ebx],al mov [ebx],al
mov [ebx+8],edi mov [ebx+8],edi
mov dword [org_origin],edi
mov dword [org_origin+4],eax
mov [org_registers],eax
mov [org_start],edi
mov [org_symbol],ebx
test [format_flags],8
jnz elf64_labels_type
mov [labels_type],2
jmp elf_labels_type_ok
elf64_labels_type:
mov [labels_type],4
elf_labels_type_ok:
mov [ebx+10h],eax mov [ebx+10h],eax
mov al,10b mov al,10b
mov [ebx+14h],eax mov [ebx+14h],eax
call setup_coff_section_org
lods word [esi] lods word [esi]
cmp ax,'(' cmp ax,'('
jne invalid_argument jne invalid_argument
@ -3218,8 +3212,7 @@ elf_formatter:
mov dx,[eax+0Eh] mov dx,[eax+0Eh]
jmp section_for_public_ok jmp section_for_public_ok
undefined_public: undefined_public:
mov eax,[ebx+24] mov [error_info],ebx
mov [error_info],eax
jmp undefined_symbol jmp undefined_symbol
elf64_public: elf64_public:
cmp dl,4 cmp dl,4
@ -3233,7 +3226,15 @@ elf_formatter:
stos dword [edi] stos dword [edi]
test [format_flags],8 test [format_flags],8
jnz elf64_public_symbol jnz elf64_public_symbol
call get_public_value movzx eax,byte [ebx+9]
shr al,1
and al,1
neg eax
cmp eax,[ebx+4]
jne value_out_of_range
xor eax,[ebx]
js value_out_of_range
mov eax,[ebx]
stos dword [edi] stos dword [edi]
xor eax,eax xor eax,eax
mov al,[ebx+10] mov al,[ebx+10]
@ -3262,9 +3263,13 @@ elf_formatter:
or al,2 or al,2
store_elf64_public_info: store_elf64_public_info:
stos dword [edi] stos dword [edi]
call get_public_value mov al,[ebx+9]
shl eax,31-1
xor eax,[ebx+4]
js value_out_of_range
mov eax,[ebx]
stos dword [edi] stos dword [edi]
xor eax,eax mov eax,[ebx+4]
stos dword [edi] stos dword [edi]
mov al,[ebx+10] mov al,[ebx+10]
stos dword [edi] stos dword [edi]
@ -3278,16 +3283,6 @@ elf_formatter:
mov [esi],eax mov [esi],eax
add esi,10h add esi,10h
jmp find_other_symbols jmp find_other_symbols
get_public_value:
mov eax,[ebx]
cmp dword [ebx+4],0
je public_value_ok
cmp dword [ebx+4],-1
jne value_out_of_range
bt eax,31
jnc value_out_of_range
public_value_ok:
ret
make_extrn_symbol: make_extrn_symbol:
mov eax,[esi+4] mov eax,[esi+4]
stos dword [edi] stos dword [edi]
@ -3488,7 +3483,7 @@ elf_formatter:
stos dword [edi] stos dword [edi]
test [format_flags],8 test [format_flags],8
jz elf_machine_word_ok jz elf_machine_word_ok
mov dword [edi],0 and dword [edi],0
add edi,4 add edi,4
elf_machine_word_ok: elf_machine_word_ok:
ret ret
@ -3669,27 +3664,36 @@ format_elf_exe:
init_elf_segments: init_elf_segments:
xor eax,eax xor eax,eax
rep stos dword [edi] rep stos dword [edi]
mov [number_of_sections],0 and [number_of_sections],0
mov byte [ebx],1 mov byte [ebx],1
mov word [ebx+1Ch],1000h mov word [ebx+1Ch],1000h
mov byte [ebx+18h],111b mov byte [ebx+18h],111b
mov eax,edi mov eax,edi
xor ebp,ebp
xor cl,cl
sub eax,[code_start] sub eax,[code_start]
sbb ebp,0
sbb cl,0
mov [ebx+4],eax mov [ebx+4],eax
add eax,[image_base] add eax,[image_base]
adc ebp,0
adc cl,0
mov [ebx+8],eax mov [ebx+8],eax
mov [ebx+0Ch],eax mov [ebx+0Ch],eax
mov [edx+18h],eax mov [edx+18h],eax
xor edx,edx
not eax not eax
not edx not ebp
not cl
add eax,1 add eax,1
adc edx,0 adc ebp,0
adc cl,0
add eax,edi add eax,edi
adc edx,0 adc ebp,0
adc cl,0
mov dword [org_origin],eax mov dword [org_origin],eax
mov dword [org_origin+4],edx mov dword [org_origin+4],edx
mov [org_registers],0 mov [org_origin_sign],cl
and [org_registers],0
mov [org_start],edi mov [org_start],edi
mov [symbols_stream],edi mov [symbols_stream],edi
jmp format_defined jmp format_defined
@ -3709,7 +3713,7 @@ format_elf_exe:
mov [edx+7],al mov [edx+7],al
elf64_exe_brand_ok: elf64_exe_brand_ok:
mov [image_base],400000h mov [image_base],400000h
mov [image_base_high],0 and [image_base_high],0
cmp byte [esi],80h cmp byte [esi],80h
jne elf64_exe_base_ok jne elf64_exe_base_ok
lods word [esi] lods word [esi]
@ -3735,7 +3739,7 @@ format_elf_exe:
init_elf64_segments: init_elf64_segments:
xor eax,eax xor eax,eax
rep stos dword [edi] rep stos dword [edi]
mov [number_of_sections],0 and [number_of_sections],0
mov byte [ebx],1 mov byte [ebx],1
mov word [ebx+30h],1000h mov word [ebx+30h],1000h
mov byte [ebx+4],111b mov byte [ebx+4],111b
@ -3744,8 +3748,10 @@ format_elf_exe:
sub eax,[code_start] sub eax,[code_start]
mov [ebx+8],eax mov [ebx+8],eax
xor edx,edx xor edx,edx
xor cl,cl
add eax,[image_base] add eax,[image_base]
adc edx,[image_base_high] adc edx,[image_base_high]
adc cl,0
mov [ebx+10h],eax mov [ebx+10h],eax
mov [ebx+10h+4],edx mov [ebx+10h+4],edx
mov [ebx+18h],eax mov [ebx+18h],eax
@ -3755,13 +3761,17 @@ format_elf_exe:
mov [ebx+18h+4],edx mov [ebx+18h+4],edx
not eax not eax
not edx not edx
not cl
add eax,1 add eax,1
adc edx,0 adc edx,0
adc cl,0
add eax,edi add eax,edi
adc edx,0 adc edx,0
adc cl,0
mov dword [org_origin],eax mov dword [org_origin],eax
mov dword [org_origin+4],edx mov dword [org_origin+4],edx
mov [org_registers],0 mov [org_origin_sign],cl
and [org_registers],0
mov [org_start],edi mov [org_start],edi
mov [symbols_stream],edi mov [symbols_stream],edi
jmp format_defined jmp format_defined
@ -3863,15 +3873,20 @@ elf_segment:
mov [ebx+0Ch],edx mov [ebx+0Ch],edx
mov eax,edx mov eax,edx
xor edx,edx xor edx,edx
xor cl,cl
not eax not eax
not edx not edx
not cl
add eax,1 add eax,1
adc edx,0 adc edx,0
adc cl,0
add eax,edi add eax,edi
adc edx,0 adc edx,0
adc cl,0
mov dword [org_origin],eax mov dword [org_origin],eax
mov dword [org_origin+4],edx mov dword [org_origin+4],edx
mov [org_registers],0 mov [org_origin_sign],cl
and [org_registers],0
mov [org_start],edi mov [org_start],edi
inc [number_of_sections] inc [number_of_sections]
jmp instruction_assembled jmp instruction_assembled
@ -3990,15 +4005,20 @@ elf_segment:
mov [ebx+10h+4],edx mov [ebx+10h+4],edx
mov [ebx+18h],eax mov [ebx+18h],eax
mov [ebx+18h+4],edx mov [ebx+18h+4],edx
xor cl,cl
not eax not eax
not edx not edx
not cl
add eax,1 add eax,1
adc edx,0 adc edx,0
adc cl,0
add eax,edi add eax,edi
adc edx,0 adc edx,0
adc cl,0
mov dword [org_origin],eax mov dword [org_origin],eax
mov dword [org_origin+4],edx mov dword [org_origin+4],edx
mov [org_registers],0 mov [org_origin_sign],cl
and [org_registers],0
mov [org_start],edi mov [org_start],edi
inc [number_of_sections] inc [number_of_sections]
jmp instruction_assembled jmp instruction_assembled

View File

@ -1,9 +1,9 @@
; flat assembler core ; flat assembler core
; Copyright (c) 1999-2012, Tomasz Grysztar. ; Copyright (c) 1999-2012, Tomasz Grysztar.
; All rights reserved. ; All rights reserved.
_out_of_memory db 'out of memory',0 _out_of_memory db 'out of memory',0
_stack_overflow db 'out of stack space',0 _stack_overflow db 'out of stack space',0
_main_file_not_found db 'source file not found',0 _main_file_not_found db 'source file not found',0
_unexpected_end_of_file db 'unexpected end of file',0 _unexpected_end_of_file db 'unexpected end of file',0
@ -22,13 +22,13 @@ _illegal_instruction db 'illegal instruction',0
_invalid_operand db 'invalid operand',0 _invalid_operand db 'invalid operand',0
_invalid_operand_size db 'invalid size of operand',0 _invalid_operand_size db 'invalid size of operand',0
_operand_size_not_specified db 'operand size not specified',0 _operand_size_not_specified db 'operand size not specified',0
_operand_sizes_do_not_match db 'operand sizes do not match',0 _operand_sizes_do_not_match db 'operand sizes do not match',0
_invalid_address_size db 'invalid size of address value',0 _invalid_address_size db 'invalid size of address value',0
_address_sizes_do_not_agree db 'address sizes do not agree',0 _address_sizes_do_not_agree db 'address sizes do not agree',0
_prefix_conflict db 'disallowed combination of registers',0 _disallowed_combination_of_registers db 'disallowed combination of registers',0
_long_immediate_not_encodable db 'not encodable with long immediate',0 _long_immediate_not_encodable db 'not encodable with long immediate',0
_relative_jump_out_of_range db 'relative jump out of range',0 _relative_jump_out_of_range db 'relative jump out of range',0
_invalid_expression db 'invalid expression',0 _invalid_expression db 'invalid expression',0
_invalid_address db 'invalid address',0 _invalid_address db 'invalid address',0
_invalid_value db 'invalid value',0 _invalid_value db 'invalid value',0
_value_out_of_range db 'value out of range',0 _value_out_of_range db 'value out of range',0
@ -45,8 +45,8 @@ _missing_end_directive db 'missing end directive',0
_unexpected_instruction db 'unexpected instruction',0 _unexpected_instruction db 'unexpected instruction',0
_extra_characters_on_line db 'extra characters on line',0 _extra_characters_on_line db 'extra characters on line',0
_section_not_aligned_enough db 'section is not aligned enough',0 _section_not_aligned_enough db 'section is not aligned enough',0
_setting_already_specified db 'setting already specified',0 _setting_already_specified db 'setting already specified',0
_data_already_defined db 'data already defined',0 _data_already_defined db 'data already defined',0
_too_many_repeats db 'too many repeats',0 _too_many_repeats db 'too many repeats',0
_invoked_error db 'error directive invoked in source file',0 _invoked_error db 'error directive invoked in source file',0
_assertion_failed db 'assertion failed',0 _assertion_failed db 'assertion failed',0

View File

@ -503,7 +503,7 @@ parse_line_contents:
cmp al,',' cmp al,','
je separator je separator
cmp al,'=' cmp al,'='
je separator je expression_comparator
cmp al,'|' cmp al,'|'
je separator je separator
cmp al,'&' cmp al,'&'
@ -569,7 +569,11 @@ parse_line_contents:
je parse_from_operator je parse_from_operator
cmp al,89h cmp al,89h
je parse_label_operator je parse_label_operator
cmp al,0F8h
je forced_expression
jmp argument_parsed jmp argument_parsed
instruction_separator:
stos byte [edi]
allow_embedded_instruction: allow_embedded_instruction:
cmp byte [esi],1Ah cmp byte [esi],1Ah
jne parse_argument jne parse_argument
@ -810,6 +814,29 @@ parse_line_contents:
stos byte [edi] stos byte [edi]
inc [parenthesis_stack] inc [parenthesis_stack]
jmp parse_argument jmp parse_argument
expression_comparator:
stos byte [edi]
jmp forced_expression
greater:
cmp byte [esi],'='
jne separator
inc esi
mov al,0F2h
jmp separator
less:
cmp byte [edi-1],0F6h
je separator
cmp byte [esi],'>'
je not_equal
cmp byte [esi],'='
jne separator
inc esi
mov al,0F3h
jmp separator
not_equal:
inc esi
mov al,0F1h
jmp expression_comparator
expression: expression:
mov al,'(' mov al,'('
stos byte [edi] stos byte [edi]
@ -892,30 +919,6 @@ parse_line_contents:
mov al,'}' mov al,'}'
separator: separator:
stos byte [edi] stos byte [edi]
jmp argument_parsed
instruction_separator:
stos byte [edi]
jmp allow_embedded_instruction
greater:
cmp byte [esi],'='
jne separator
inc esi
mov al,0F2h
jmp separator
less:
cmp byte [edi-1],0F6h
je separator
cmp byte [esi],'>'
je not_equal
cmp byte [esi],'='
jne separator
inc esi
mov al,0F3h
jmp separator
not_equal:
inc esi
mov al,0F1h
jmp separator
argument_parsed: argument_parsed:
cmp [parenthesis_stack],0 cmp [parenthesis_stack],0
je parse_argument je parse_argument
@ -984,6 +987,7 @@ get_operator:
jne next_operator jne next_operator
repe cmps byte [esi],[edi] repe cmps byte [esi],[edi]
je operator_found je operator_found
jb no_operator
next_operator: next_operator:
mov edi,ebx mov edi,ebx
inc edi inc edi
@ -1046,12 +1050,10 @@ get_symbol:
ja symbols_up ja symbols_up
jb symbols_down jb symbols_down
mov ax,[edi] mov ax,[edi]
cmp al,18h cmp al,18h
jb symbol_ok jb symbol_ok
cmp [formatter_symbols_allowed],0 cmp [formatter_symbols_allowed],0
je no_symbol je no_symbol
symbol_ok: symbol_ok:
pop esi pop esi
add esi,ebp add esi,ebp

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,28 @@
; flat assembler core ; flat assembler core
; Copyright (c) 1999-2012, Tomasz Grysztar. ; Copyright (c) 1999-2012, Tomasz Grysztar.
; All rights reserved. ; All rights reserved.
dump_symbols: dump_symbols:
mov edi,[code_start] mov edi,[code_start]
call setup_dump_header call setup_dump_header
mov esi,[input_file] mov esi,[input_file]
call copy_asciiz call copy_asciiz
cmp edi,[display_buffer] cmp edi,[display_buffer]
jae out_of_memory jae out_of_memory
mov eax,edi mov eax,edi
sub eax,ebx sub eax,ebx
mov [ebx-38h+0Ch],eax mov [ebx-40h+0Ch],eax
mov esi,[output_file] mov esi,[output_file]
call copy_asciiz call copy_asciiz
cmp edi,[display_buffer] cmp edi,[display_buffer]
jae out_of_memory jae out_of_memory
mov edx,[symbols_stream] mov edx,[symbols_stream]
mov ebp,[free_additional_memory] mov ebp,[free_additional_memory]
mov [number_of_sections],0 and [number_of_sections],0
cmp [output_format],4 cmp [output_format],4
je prepare_strings_table je prepare_strings_table
cmp [output_format],5 cmp [output_format],5
jne strings_table_ready jne strings_table_ready
bt [format_flags],0 bt [format_flags],0
jc strings_table_ready jc strings_table_ready
@ -149,40 +149,45 @@ dump_symbols:
label_used_flag_ok: label_used_flag_ok:
add edx,LABEL_STRUCTURE_SIZE add edx,LABEL_STRUCTURE_SIZE
jmp prepare_labels_dump jmp prepare_labels_dump
labels_dump_ok: labels_dump_ok:
mov eax,edi mov eax,edi
sub eax,ebx sub eax,ebx
mov [ebx-38h+14h],eax mov [ebx-40h+14h],eax
add eax,38h add eax,40h
mov [ebx-38h+18h],eax mov [ebx-40h+18h],eax
mov ecx,[memory_end] mov ecx,[memory_end]
sub ecx,[labels_list] sub ecx,[labels_list]
mov [ebx-38h+1Ch],ecx mov [ebx-40h+1Ch],ecx
add eax,ecx add eax,ecx
mov [ebx-38h+20h],eax mov [ebx-40h+20h],eax
mov ecx,[source_start] mov ecx,[source_start]
sub ecx,[memory_start] sub ecx,[memory_start]
mov [ebx-38h+24h],ecx mov [ebx-40h+24h],ecx
add eax,ecx add eax,ecx
mov [ebx-38h+28h],eax mov [ebx-40h+28h],eax
mov eax,[number_of_sections] mov eax,[number_of_sections]
shl eax,2 shl eax,2
mov [ebx-38h+34h],eax mov [ebx-40h+34h],eax
call prepare_preprocessed_source call prepare_preprocessed_source
mov esi,[labels_list] mov esi,[labels_list]
mov ebp,edi mov ebp,edi
make_lines_dump: make_lines_dump:
cmp esi,[display_buffer] cmp esi,[display_buffer]
je lines_dump_ok je lines_dump_ok
mov eax,[esi-4] mov eax,[esi-4]
mov ecx,[esi-8] mov ecx,[esi-8]
sub esi,8 sub esi,8
sub esi,ecx sub esi,ecx
cmp eax,1 cmp eax,1
jne make_lines_dump je process_line_dump
mov eax,[esi+4] cmp eax,2
sub eax,[code_start] jne make_lines_dump
add eax,[headers_size] add dword [ebx-40h+3Ch],8
jmp make_lines_dump
process_line_dump:
mov eax,[esi+4]
sub eax,[code_start]
add eax,[headers_size]
cmp byte [esi+1Ah],0 cmp byte [esi+1Ah],0
je store_offset je store_offset
xor eax,eax xor eax,eax
@ -190,14 +195,16 @@ dump_symbols:
stos dword [edi] stos dword [edi]
mov eax,[esi] mov eax,[esi]
sub eax,[memory_start] sub eax,[memory_start]
stos dword [edi] stos dword [edi]
mov eax,[esi+4] mov eax,[esi+4]
xor edx,edx xor edx,edx
sub eax,[esi+8] xor cl,cl
sbb edx,[esi+8+4] sub eax,[esi+8]
stos dword [edi] sbb edx,[esi+8+4]
mov eax,edx sbb cl,[esi+1Bh]
stos dword [edi] stos dword [edi]
mov eax,edx
stos dword [edi]
mov eax,[esi+10h] mov eax,[esi+10h]
stos dword [edi] stos dword [edi]
mov eax,[esi+14h] mov eax,[esi+14h]
@ -207,50 +214,57 @@ dump_symbols:
mov eax,[eax+4] mov eax,[eax+4]
jae base_symbol_for_line_ok jae base_symbol_for_line_ok
xor eax,eax xor eax,eax
base_symbol_for_line_ok: base_symbol_for_line_ok:
stos dword [edi] stos dword [edi]
mov eax,[esi+18h] mov eax,[esi+18h]
and eax,001FFFFh and eax,01FFFFh
stos dword [edi] stos dword [edi]
cmp edi,[display_buffer] mov [edi-1],cl
jae out_of_memory cmp edi,[display_buffer]
jmp make_lines_dump jae out_of_memory
lines_dump_ok: mov eax,edi
mov edx,edi sub eax,1Ch
sub eax,ebp
mov [esi],eax
jmp make_lines_dump
lines_dump_ok:
mov edx,edi
mov eax,[current_offset] mov eax,[current_offset]
sub eax,[code_start] sub eax,[code_start]
add eax,[headers_size] add eax,[headers_size]
stos dword [edi] stos dword [edi]
mov ecx,edi mov ecx,edi
sub ecx,ebx sub ecx,ebx
sub ecx,[ebx-38h+14h] sub ecx,[ebx-40h+14h]
mov [ebx-38h+2Ch],ecx mov [ebx-40h+2Ch],ecx
add ecx,[ebx-38h+28h] add ecx,[ebx-40h+28h]
mov [ebx-38h+30h],ecx mov [ebx-40h+30h],ecx
find_inexisting_offsets: add ecx,[ebx-40h+34h]
sub edx,1Ch mov [ebx-40h+38h],ecx
cmp edx,ebp find_inexisting_offsets:
sub edx,1Ch
cmp edx,ebp
jb write_symbols jb write_symbols
test byte [edx+1Ah],1 test byte [edx+1Ah],1
jnz find_inexisting_offsets jnz find_inexisting_offsets
cmp eax,[edx] cmp eax,[edx]
jb correct_inexisting_offset jb correct_inexisting_offset
mov eax,[edx] mov eax,[edx]
jmp find_inexisting_offsets jmp find_inexisting_offsets
correct_inexisting_offset: correct_inexisting_offset:
mov dword [edx],0 and dword [edx],0
or byte [edx+1Ah],2 or byte [edx+1Ah],2
jmp find_inexisting_offsets jmp find_inexisting_offsets
write_symbols: write_symbols:
mov edx,[symbols_file] mov edx,[symbols_file]
call create call create
jc write_failed jc write_failed
mov edx,[code_start] mov edx,[code_start]
mov ecx,[edx+14h] mov ecx,[edx+14h]
add ecx,38h add ecx,40h
call write call write
jc write_failed jc write_failed
mov edx,[display_buffer] mov edx,[display_buffer]
mov ecx,[memory_end] mov ecx,[memory_end]
sub ecx,[labels_list] sub ecx,[labels_list]
call write call write
@ -267,22 +281,53 @@ dump_symbols:
jc write_failed jc write_failed
mov edx,[free_additional_memory] mov edx,[free_additional_memory]
mov ecx,[number_of_sections] mov ecx,[number_of_sections]
shl ecx,2 shl ecx,2
call write call write
jc write_failed jc write_failed
call close mov esi,[labels_list]
ret mov edi,[memory_start]
setup_dump_header: make_references_dump:
xor eax,eax cmp esi,[display_buffer]
mov ecx,38h shr 2 je references_dump_ok
rep stos dword [edi] mov eax,[esi-4]
mov ebx,edi mov ecx,[esi-8]
mov dword [ebx-38h],'fas'+1Ah shl 24 sub esi,8
mov dword [ebx-38h+4],VERSION_MAJOR + VERSION_MINOR shl 8 + 38h shl 16 sub esi,ecx
mov dword [ebx-38h+10h],38h cmp eax,2
ret je dump_reference
prepare_preprocessed_source: cmp eax,1
mov esi,[memory_start] jne make_references_dump
mov edx,[esi]
jmp make_references_dump
dump_reference:
mov eax,[memory_end]
sub eax,[esi]
sub eax,LABEL_STRUCTURE_SIZE
stosd
mov eax,edx
stosd
cmp edi,[display_buffer]
jb make_references_dump
jmp out_of_memory
references_dump_ok:
mov edx,[memory_start]
mov ecx,edi
sub ecx,edx
call write
jc write_failed
call close
ret
setup_dump_header:
xor eax,eax
mov ecx,40h shr 2
rep stos dword [edi]
mov ebx,edi
mov dword [ebx-40h],'fas'+1Ah shl 24
mov dword [ebx-40h+4],VERSION_MAJOR + VERSION_MINOR shl 8 + 40h shl 16
mov dword [ebx-40h+10h],40h
ret
prepare_preprocessed_source:
mov esi,[memory_start]
mov ebp,[source_start] mov ebp,[source_start]
test ebp,ebp test ebp,ebp
jnz prepare_preprocessed_line jnz prepare_preprocessed_line
@ -362,29 +407,29 @@ dump_preprocessed_source:
call copy_asciiz call copy_asciiz
cmp edi,[additional_memory_end] cmp edi,[additional_memory_end]
jae out_of_memory jae out_of_memory
mov eax,edi mov eax,edi
sub eax,ebx sub eax,ebx
dec eax dec eax
mov [ebx-38h+0Ch],eax mov [ebx-40h+0Ch],eax
mov eax,edi mov eax,edi
sub eax,ebx sub eax,ebx
mov [ebx-38h+14h],eax mov [ebx-40h+14h],eax
add eax,38h add eax,40h
mov [ebx-38h+20h],eax mov [ebx-40h+20h],eax
call prepare_preprocessed_source call prepare_preprocessed_source
sub esi,[memory_start] sub esi,[memory_start]
mov [ebx-38h+24h],esi mov [ebx-40h+24h],esi
mov edx,[symbols_file] mov edx,[symbols_file]
call create call create
jc write_failed jc write_failed
mov edx,[free_additional_memory] mov edx,[free_additional_memory]
mov ecx,[edx+14h] mov ecx,[edx+14h]
add ecx,38h add ecx,40h
call write call write
jc write_failed jc write_failed
mov edx,[memory_start] mov edx,[memory_start]
mov ecx,esi mov ecx,esi
call write call write
jc write_failed jc write_failed
call close call close
ret ret

File diff suppressed because it is too large Load Diff

View File

@ -117,12 +117,16 @@ jump_type db ?
push_size db ? push_size db ?
value_size db ? value_size db ?
address_size db ? address_size db ?
label_size db ?
size_declared db ? size_declared db ?
value_undefined db ? value_undefined db ?
value_constant db ?
value_type db ? value_type db ?
value_sign db ?
fp_sign db ? fp_sign db ?
fp_format db ? fp_format db ?
address_sign db ?
compare_type db ? compare_type db ?
logical_value_wrapping db ? logical_value_wrapping db ?
next_pass_needed db ? next_pass_needed db ?
@ -130,8 +134,11 @@ output_format db ?
labels_type db ? labels_type db ?
code_type db ? code_type db ?
virtual_data db ? virtual_data db ?
org_origin_sign db ?
adjustment_sign db ?
macro_status db ? macro_status db ?
default_argument_value db ?
prefixed_instruction db ? prefixed_instruction db ?
formatter_symbols_allowed db ? formatter_symbols_allowed db ?

View File

@ -1,5 +1,5 @@
; flat assembler version 1.69 ; flat assembler version 1.70
; Copyright (c) 1999-2012, Tomasz Grysztar. ; Copyright (c) 1999-2012, Tomasz Grysztar.
; All rights reserved. ; All rights reserved.
; ;
@ -33,7 +33,7 @@
; cannot simply be copied and put under another distribution licence ; cannot simply be copied and put under another distribution licence
; (including the GNU Public Licence). ; (including the GNU Public Licence).
VERSION_STRING equ "1.69.36" VERSION_STRING equ "1.70.01"
VERSION_MAJOR = 1 VERSION_MAJOR = 1
VERSION_MINOR = 69 VERSION_MINOR = 70

View File

@ -76,10 +76,9 @@ int_instruction:
cmp al,'(' cmp al,'('
jne invalid_operand jne invalid_operand
call get_byte_value call get_byte_value
cmp [next_pass_needed],0
jne int_imm_ok
test eax,eax test eax,eax
js value_out_of_range jns int_imm_ok
call recoverable_overflow
int_imm_ok: int_imm_ok:
mov ah,al mov ah,al
mov al,0CDh mov al,0CDh
@ -160,11 +159,7 @@ basic_instruction:
jae long_immediate_not_encodable jae long_immediate_not_encodable
jmp basic_mem_imm_32bit_ok jmp basic_mem_imm_32bit_ok
basic_mem_imm_nosize: basic_mem_imm_nosize:
cmp [error_line],0 call recoverable_unknown_size
jne basic_mem_imm_8bit
mov eax,[current_line]
mov [error_line],eax
mov [error],operand_size_not_specified
basic_mem_imm_8bit: basic_mem_imm_8bit:
call get_byte_value call get_byte_value
mov byte [value],al mov byte [value],al
@ -373,6 +368,14 @@ basic_instruction:
add [base_code],5 add [base_code],5
call store_instruction_code call store_instruction_code
jmp basic_store_imm_32bit jmp basic_store_imm_32bit
recoverable_unknown_size:
cmp [error_line],0
jne ignore_unknown_size
push [current_line]
pop [error_line]
mov [error],operand_size_not_specified
ignore_unknown_size:
ret
single_operand_instruction: single_operand_instruction:
mov [base_code],0F6h mov [base_code],0F6h
mov [postbyte_register],al mov [postbyte_register],al
@ -392,11 +395,7 @@ single_operand_instruction:
inc [base_code] inc [base_code]
jmp instruction_ready jmp instruction_ready
single_mem_nosize: single_mem_nosize:
cmp [error_line],0 call recoverable_unknown_size
jne single_mem_8bit
mov eax,[current_line]
mov [error_line],eax
mov [error],operand_size_not_specified
single_mem_8bit: single_mem_8bit:
jmp instruction_ready jmp instruction_ready
single_reg: single_reg:
@ -575,11 +574,7 @@ mov_instruction:
call store_instruction_with_imm16 call store_instruction_with_imm16
jmp instruction_assembled jmp instruction_assembled
mov_mem_imm_nosize: mov_mem_imm_nosize:
cmp [error_line],0 call recoverable_unknown_size
jne mov_mem_imm_32bit
mov eax,[current_line]
mov [error_line],eax
mov [error],operand_size_not_specified
mov_mem_imm_32bit: mov_mem_imm_32bit:
call operand_32bit call operand_32bit
call get_dword_value call get_dword_value
@ -920,37 +915,6 @@ mov_instruction:
cmp ah,8 cmp ah,8
je mov_xrx_store je mov_xrx_store
jmp invalid_operand_size jmp invalid_operand_size
cmov_instruction:
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_register
mov [postbyte_register],al
lods byte [esi]
cmp al,','
jne invalid_operand
lods byte [esi]
call get_size_operator
cmp al,'['
je cmov_reg_mem
cmp al,10h
jne invalid_operand
cmov_reg_reg:
lods byte [esi]
call convert_register
mov bl,al
mov al,ah
call operand_autodetect
jmp nomem_instruction_ready
cmov_reg_mem:
call get_address
mov al,[operand_size]
call operand_autodetect
jmp instruction_ready
test_instruction: test_instruction:
mov [base_code],84h mov [base_code],84h
lods byte [esi] lods byte [esi]
@ -1020,11 +984,7 @@ test_instruction:
call store_instruction_with_imm16 call store_instruction_with_imm16
jmp instruction_assembled jmp instruction_assembled
test_mem_imm_nosize: test_mem_imm_nosize:
cmp [error_line],0 call recoverable_unknown_size
jne test_mem_imm_32bit
mov eax,[current_line]
mov [error_line],eax
mov [error],operand_size_not_specified
test_mem_imm_32bit: test_mem_imm_32bit:
call operand_32bit call operand_32bit
call get_dword_value call get_dword_value
@ -1243,11 +1203,7 @@ push_instruction:
je push_mem_32bit je push_mem_32bit
cmp ah,8 cmp ah,8
je push_mem_64bit je push_mem_64bit
cmp [error_line],0 call recoverable_unknown_size
jne push_mem_store
mov eax,[current_line]
mov [error_line],eax
mov [error],operand_size_not_specified
jmp push_mem_store jmp push_mem_store
push_mem_16bit: push_mem_16bit:
test ah,not 2 test ah,not 2
@ -1509,11 +1465,7 @@ pop_instruction:
je pop_mem_32bit je pop_mem_32bit
cmp ah,8 cmp ah,8
je pop_mem_64bit je pop_mem_64bit
cmp [error_line],0 call recoverable_unknown_size
jne pop_mem_store
mov eax,[current_line]
mov [error_line],eax
mov [error],operand_size_not_specified
jmp pop_mem_store jmp pop_mem_store
pop_mem_16bit: pop_mem_16bit:
test ah,not 2 test ah,not 2
@ -1689,11 +1641,7 @@ inc_instruction:
mov [postbyte_register],al mov [postbyte_register],al
jmp instruction_ready jmp instruction_ready
inc_mem_nosize: inc_mem_nosize:
cmp [error_line],0 call recoverable_unknown_size
jne inc_mem_8bit
mov eax,[current_line]
mov [error_line],eax
mov [error],operand_size_not_specified
inc_mem_8bit: inc_mem_8bit:
mov al,0FEh mov al,0FEh
xchg al,[base_code] xchg al,[base_code]
@ -2028,11 +1976,7 @@ sh_instruction:
mov [base_code],0D3h mov [base_code],0D3h
jmp instruction_ready jmp instruction_ready
sh_mem_cl_nosize: sh_mem_cl_nosize:
cmp [error_line],0 call recoverable_unknown_size
jne sh_mem_cl_8bit
mov eax,[current_line]
mov [error_line],eax
mov [error],operand_size_not_specified
sh_mem_cl_8bit: sh_mem_cl_8bit:
mov [base_code],0D2h mov [base_code],0D2h
jmp instruction_ready jmp instruction_ready
@ -2059,11 +2003,7 @@ sh_instruction:
mov [base_code],0D1h mov [base_code],0D1h
jmp instruction_ready jmp instruction_ready
sh_mem_imm_nosize: sh_mem_imm_nosize:
cmp [error_line],0 call recoverable_unknown_size
jne sh_mem_imm_8bit
mov eax,[current_line]
mov [error_line],eax
mov [error],operand_size_not_specified
sh_mem_imm_8bit: sh_mem_imm_8bit:
cmp byte [value],1 cmp byte [value],1
je sh_mem_1_8bit je sh_mem_1_8bit
@ -2277,11 +2217,7 @@ movx_instruction:
call operand_autodetect call operand_autodetect
jmp instruction_ready jmp instruction_ready
movx_unknown_size: movx_unknown_size:
cmp [error_line],0 call recoverable_unknown_size
jne movx_mem_store
mov eax,[current_line]
mov [error_line],eax
mov [error],operand_size_not_specified
jmp movx_mem_store jmp movx_mem_store
movx_reg: movx_reg:
lods byte [esi] lods byte [esi]
@ -2400,11 +2336,7 @@ bt_instruction:
call store_instruction_with_imm8 call store_instruction_with_imm8
jmp instruction_assembled jmp instruction_assembled
bt_mem_imm_nosize: bt_mem_imm_nosize:
cmp [error_line],0 call recoverable_unknown_size
jne bt_mem_imm_store
mov eax,[current_line]
mov [error_line],eax
mov [error],operand_size_not_specified
jmp bt_mem_imm_store jmp bt_mem_imm_store
bt_reg: bt_reg:
lods byte [esi] lods byte [esi]
@ -2457,6 +2389,16 @@ bt_instruction:
bs_instruction: bs_instruction:
mov [extended_code],al mov [extended_code],al
mov [base_code],0Fh mov [base_code],0Fh
call get_reg_mem
jc bs_reg_reg
mov al,[operand_size]
call operand_autodetect
jmp instruction_ready
bs_reg_reg:
mov al,ah
call operand_autodetect
jmp nomem_instruction_ready
get_reg_mem:
lods byte [esi] lods byte [esi]
call get_size_operator call get_size_operator
cmp al,10h cmp al,10h
@ -2470,20 +2412,19 @@ bs_instruction:
lods byte [esi] lods byte [esi]
call get_size_operator call get_size_operator
cmp al,10h cmp al,10h
je bs_reg_reg je get_reg_reg
cmp al,'[' cmp al,'['
jne invalid_argument jne invalid_argument
call get_address call get_address
mov al,[operand_size] clc
call operand_autodetect ret
jmp instruction_ready get_reg_reg:
bs_reg_reg:
lods byte [esi] lods byte [esi]
call convert_register call convert_register
mov bl,al mov bl,al
mov al,ah stc
call operand_autodetect ret
jmp nomem_instruction_ready
imul_instruction: imul_instruction:
mov [base_code],0F6h mov [base_code],0F6h
mov [postbyte_register],5 mov [postbyte_register],5
@ -2503,11 +2444,7 @@ imul_instruction:
inc [base_code] inc [base_code]
jmp instruction_ready jmp instruction_ready
imul_mem_nosize: imul_mem_nosize:
cmp [error_line],0 call recoverable_unknown_size
jne imul_mem_8bit
mov eax,[current_line]
mov [error_line],eax
mov [error],operand_size_not_specified
imul_mem_8bit: imul_mem_8bit:
jmp instruction_ready jmp instruction_ready
imul_reg: imul_reg:
@ -2892,11 +2829,7 @@ jmp_instruction:
je jmp_mem_far je jmp_mem_far
cmp [jump_type],2 cmp [jump_type],2
je jmp_mem_near je jmp_mem_near
cmp [error_line],0 call recoverable_unknown_size
jne jmp_mem_near
mov eax,[current_line]
mov [error_line],eax
mov [error],operand_size_not_specified
jmp_mem_near: jmp_mem_near:
cmp [code_type],16 cmp [code_type],16
je jmp_mem_16bit je jmp_mem_16bit
@ -3007,6 +2940,10 @@ jmp_instruction:
jmp_imm_32bit_store: jmp_imm_32bit_store:
mov edx,eax mov edx,eax
sub edx,3 sub edx,3
jno jmp_imm_32bit_ok
cmp [code_type],64
je relative_jump_out_of_range
jmp_imm_32bit_ok:
mov al,[base_code] mov al,[base_code]
stos byte [edi] stos byte [edi]
mov eax,edx mov eax,edx
@ -3021,7 +2958,7 @@ jmp_instruction:
mov ecx,edx mov ecx,edx
cdq cdq
cmp edx,ecx cmp edx,ecx
jne value_out_of_range jne relative_jump_out_of_range
call check_for_short_jump call check_for_short_jump
jnc jmp_imm_32bit_store jnc jmp_imm_32bit_store
jmp_short: jmp_short:
@ -3202,7 +3139,7 @@ conditional_jump:
mov ecx,edx mov ecx,edx
cdq cdq
cmp edx,ecx cmp edx,ecx
jne value_out_of_range jne relative_jump_out_of_range
call check_for_short_jump call check_for_short_jump
jnc conditional_jump_32bit_store jnc conditional_jump_32bit_store
conditional_jump_short: conditional_jump_short:
@ -3307,7 +3244,7 @@ loop_instruction:
mov ecx,edx mov ecx,edx
cdq cdq
cmp edx,ecx cmp edx,ecx
jne value_out_of_range jne relative_jump_out_of_range
jmp make_loop_jump jmp make_loop_jump
loop_jump_16bit: loop_jump_16bit:
call get_address_word_value call get_address_word_value
@ -3393,11 +3330,7 @@ movs_instruction:
je simple_instruction_64bit je simple_instruction_64bit
or bl,bl or bl,bl
jnz invalid_operand_size jnz invalid_operand_size
cmp [error_line],0 call recoverable_unknown_size
jne simple_instruction
mov ebx,[current_line]
mov [error_line],ebx
mov [error],operand_size_not_specified
jmp simple_instruction jmp simple_instruction
lods_instruction: lods_instruction:
lods byte [esi] lods byte [esi]
@ -3935,11 +3868,7 @@ basic_fpu_instruction:
je basic_fpu_mem_64bit je basic_fpu_mem_64bit
or al,al or al,al
jnz invalid_operand_size jnz invalid_operand_size
cmp [error_line],0 call recoverable_unknown_size
jne basic_fpu_mem_32bit
mov eax,[current_line]
mov [error_line],eax
mov [error],operand_size_not_specified
basic_fpu_mem_32bit: basic_fpu_mem_32bit:
jmp instruction_ready jmp instruction_ready
basic_fpu_mem_64bit: basic_fpu_mem_64bit:
@ -4007,11 +3936,7 @@ fi_instruction:
je fi_mem_32bit je fi_mem_32bit
or al,al or al,al
jnz invalid_operand_size jnz invalid_operand_size
cmp [error_line],0 call recoverable_unknown_size
jne fi_mem_32bit
mov eax,[current_line]
mov [error_line],eax
mov [error],operand_size_not_specified
fi_mem_32bit: fi_mem_32bit:
mov [base_code],0DAh mov [base_code],0DAh
jmp instruction_ready jmp instruction_ready
@ -4036,11 +3961,7 @@ fld_instruction:
je fld_mem_80bit je fld_mem_80bit
or al,al or al,al
jnz invalid_operand_size jnz invalid_operand_size
cmp [error_line],0 call recoverable_unknown_size
jne fld_mem_32bit
mov eax,[current_line]
mov [error_line],eax
mov [error],operand_size_not_specified
fld_mem_32bit: fld_mem_32bit:
mov [base_code],0D9h mov [base_code],0D9h
jmp instruction_ready jmp instruction_ready
@ -4086,11 +4007,7 @@ fild_instruction:
je fild_mem_64bit je fild_mem_64bit
or al,al or al,al
jnz invalid_operand_size jnz invalid_operand_size
cmp [error_line],0 call recoverable_unknown_size
jne fild_mem_32bit
mov eax,[current_line]
mov [error_line],eax
mov [error],operand_size_not_specified
fild_mem_32bit: fild_mem_32bit:
mov [base_code],0DBh mov [base_code],0DBh
jmp instruction_ready jmp instruction_ready
@ -5648,7 +5565,7 @@ pmovsxdq_instruction:
jne invalid_operand jne invalid_operand
call get_address call get_address
cmp [operand_size],0 cmp [operand_size],0
je mmx_imm8 je instruction_ready
mov al,[mmx_size] mov al,[mmx_size]
cmp al,[operand_size] cmp al,[operand_size]
jne invalid_operand_size jne invalid_operand_size
@ -5854,7 +5771,7 @@ movntdqa_instruction:
mov [opcode_prefix],66h mov [opcode_prefix],66h
mov [base_code],0Fh mov [base_code],0Fh
mov [extended_code],38h mov [extended_code],38h
mov [supplemental_code],2Ah mov [supplemental_code],al
lods byte [esi] lods byte [esi]
call get_size_operator call get_size_operator
cmp al,10h cmp al,10h
@ -5979,11 +5896,7 @@ crc32_instruction:
crc32_reg32_mem_store: crc32_reg32_mem_store:
jmp instruction_ready jmp instruction_ready
crc32_unknown_size: crc32_unknown_size:
cmp [error_line],0 call recoverable_unknown_size
jne crc32_reg32_mem_store
mov eax,[current_line]
mov [error_line],eax
mov [error],operand_size_not_specified
jmp crc32_reg32_mem_store jmp crc32_reg32_mem_store
crc32_reg32_reg: crc32_reg32_reg:
lods byte [esi] lods byte [esi]
@ -6301,6 +6214,8 @@ rdrand_instruction:
call operand_autodetect call operand_autodetect
jmp nomem_instruction_ready jmp nomem_instruction_ready
rdfsbase_instruction: rdfsbase_instruction:
cmp [code_type],64
jne illegal_instruction
mov [opcode_prefix],0F3h mov [opcode_prefix],0F3h
mov [base_code],0Fh mov [base_code],0Fh
mov [extended_code],0AEh mov [extended_code],0AEh
@ -6318,6 +6233,70 @@ rdfsbase_instruction:
call operand_autodetect call operand_autodetect
jmp nomem_instruction_ready jmp nomem_instruction_ready
xabort_instruction:
lods byte [esi]
call get_size_operator
cmp ah,1
ja invalid_operand_size
cmp al,'('
jne invalid_operand
call get_byte_value
mov dl,al
mov ax,0F8C6h
stos word [edi]
mov al,dl
stos byte [edi]
jmp instruction_assembled
xbegin_instruction:
lods byte [esi]
cmp al,'('
jne invalid_operand
mov al,[code_type]
cmp al,64
je xbegin_64bit
cmp al,32
je xbegin_32bit
xbegin_16bit:
call get_address_word_value
add edi,4
call calculate_relative_offset
sub edi,4
shl eax,16
mov ax,0F8C7h
stos dword [edi]
jmp instruction_assembled
xbegin_32bit:
call get_address_dword_value
jmp xbegin_address_ok
xbegin_64bit:
call get_address_qword_value
xbegin_address_ok:
add edi,5
call calculate_relative_offset
sub edi,5
mov edx,eax
cwde
cmp eax,edx
jne xbegin_rel32
mov al,66h
stos byte [edi]
mov eax,edx
shl eax,16
mov ax,0F8C7h
stos dword [edi]
jmp instruction_assembled
xbegin_rel32:
sub edx,1
jno xbegin_rel32_ok
cmp [code_type],64
je relative_jump_out_of_range
xbegin_rel32_ok:
mov ax,0F8C7h
stos word [edi]
mov eax,edx
stos dword [edi]
jmp instruction_assembled
convert_register: convert_register:
mov ah,al mov ah,al
shr ah,4 shr ah,4
@ -6456,11 +6435,7 @@ get_address:
cdq cdq
cmp edx,[address_high] cmp edx,[address_high]
je address_high_ok je address_high_ok
cmp [error_line],0 call recoverable_overflow
jne address_high_ok
mov ebx,[current_line]
mov [error_line],ebx
mov [error],value_out_of_range
address_high_ok: address_high_ok:
mov edx,eax mov edx,eax
ror ecx,16 ror ecx,16
@ -6559,7 +6534,7 @@ store_instruction_code:
cmp [code_type],64 cmp [code_type],64
jne invalid_operand jne invalid_operand
test al,0B0h test al,0B0h
jnz prefix_conflict jnz disallowed_combination_of_registers
stos byte [edi] stos byte [edi]
rex_prefix_ok: rex_prefix_ok:
mov al,[base_code] mov al,[base_code]
@ -6617,13 +6592,11 @@ store_instruction:
test bx,8080h test bx,8080h
jz address_value_ok jz address_value_ok
address_value_out_of_range: address_value_out_of_range:
cmp [error_line],0 call recoverable_overflow
jne address_value_ok
mov edx,[current_line]
mov [error_line],edx
mov [error],value_out_of_range
address_value_ok: address_value_ok:
call store_segment_prefix_if_necessary call store_segment_prefix_if_necessary
test [vex_required],4
jnz address_vsib
or bx,bx or bx,bx
jz address_immediate jz address_immediate
cmp bx,0F800h cmp bx,0F800h
@ -6733,6 +6706,22 @@ store_instruction:
or al,cl or al,cl
stos byte [edi] stos byte [edi]
ret ret
address_vsib:
mov al,bl
shr al,4
cmp al,0Ch
je vector_index_ok
cmp al,0Dh
jne invalid_address
vector_index_ok:
mov al,bh
shr al,4
cmp al,4
je postbyte_32bit
cmp [code_type],64
je address_prefix_ok
test al,al
jnz invalid_address
postbyte_32bit: postbyte_32bit:
call address_32bit_prefix call address_32bit_prefix
jmp address_prefix_ok jmp address_prefix_ok
@ -6779,6 +6768,7 @@ store_instruction:
or ah,bl or ah,bl
and bh,111b and bh,111b
or ah,bh or ah,bh
sib_ready:
test ch,44h test ch,44h
jnz sib_address_32bit_value jnz sib_address_32bit_value
test ch,88h test ch,88h