tag for fasm 1.68

fasm 1.69.06 in trunk

git-svn-id: svn://kolibrios.org@1189 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
heavyiron 2009-10-01 00:41:45 +00:00
parent 40beda5783
commit 905b52e8ee
28 changed files with 25479 additions and 1005 deletions

View File

@ -0,0 +1,200 @@
Visit http://flatassembler.net/ for more information.
version 1.68 (Jun 13, 2009)
[+] Added SSSE3 (Supplemental SSE3), SSE4.1, SSE4.2 and SSE4a instructions.
[+] Added the AMD SVM and Intel SMX instructions.
[+] Added "rdmsrq", "wrmsrq", "sysexitq" and "sysretq" mnemonics for the
64-bit variants of respective instructions.
[+] 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.
[+] 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.
[+] 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
somewhere into executable by programer, or not. This makes possible the
more flexible use of the addressing symbols in case of PE executable fixed
at some position.
[-] Added support for outputting the 32-bit address relocations in case of
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
assigning it. For example:
a equ 1
a equ a+a
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
macroinstructions.
[-] Moved part of the conditional expression processing into parser,
for slightly better performance and lesser memory usage by assembler.
The logical values defined with "eq", "eqtype" and "in" operators are now
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
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.
[-] 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
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
condition it doesn't need to know the second logical value to determine the
value of conjunction.
[+] Added "short" keyword for specifying jump type, the "jmp byte" form is now
obsolete and no longer correct - use "jmp short" instead.
[-] 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,
unless you force using the 16-bit immediate with "word" operator.
[+] Added missing extended registers for the 32-bit addressing in long mode.
[+] Added "linkremove" and "linkinfo" section flags for MS COFF output.
[+] Added support for GOT offsets in ELF object formatter, which can be useful
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
(the same keyword as for PE format is used, to avoid adding a new one,
while this one has very similar meaning).
[-] Changed ELF executable to use "segment" directive in place of "section",
to make the distinction between the run-time segments and linkable
sections. If you had a "section" directive in your ELF executables and they
no longer assemble, replace it with "segment".
[-] 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
directory with one empty block).
[-] 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
prioritized constant.
[+] The ` operator now works with any kind of symbol; when used with quoted
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
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
compatibility, is now deprecated.
[-] Corrected order of identifying assembler directives ("if db eq db" was
incorrectly interpreted as data definition).
[-] Many other small bugs fixed.
version 1.64 (Aug 8, 2005)
[+] Output of PE executables for Win64 architecture (with "format PE64"
setting).
[+] Added "while" and "break" directives.
[+] Added "irp" and "irps" directives.
[+] The macro arguments can be marked as required with the "*" character.
[-] Fixed checking for overflow when multiplying 64-bit values - the result
must always fit in the range of signed 64 integer now.
[-] Segment prefixes were generated incorrectly in 16-bit mode when BP was used
as a second addressing register - fixed.
[-] The "local" directive was not creating unique labels in some cases - fixed.
[-] The "not encodable with long immediate" error in 64-bit mode was sometimes
wrongly signaled - fixed.
[-] Other minor fixes and corrections.
version 1.62 (Jun 14, 2005)
[+] Escaping of symbols inside macroinstructions with backslash.
[+] Ability of outputting the COFF object files for Win64 architecture
(with "format MS64 COFF" setting).
[+] New preprocessor directives: "restruc", "rept" and "match"
[+] VMX instructions support (not documented).
[+] 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.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,5 @@
@erase lang.inc
@echo lang fix en >lang.inc
@fasm fasm.asm fasm
@erase lang.inc
@pause

View File

@ -0,0 +1,6 @@
@erase lang.inc
@echo lang fix ru >lang.inc
@fasm fasm.asm fasm
@erase lang.inc
@kpack fasm
@pause

View File

@ -0,0 +1,174 @@
; flat assembler core
; Copyright (c) 1999-2009, Tomasz Grysztar.
; All rights reserved.
out_of_memory:
push _out_of_memory
jmp fatal_error
stack_overflow:
push _stack_overflow
jmp fatal_error
main_file_not_found:
push _main_file_not_found
jmp fatal_error
unexpected_end_of_file:
push _unexpected_end_of_file
jmp fatal_error
code_cannot_be_generated:
push _code_cannot_be_generated
jmp fatal_error
format_limitations_exceeded:
push _format_limitations_exceeded
jmp fatal_error
invalid_definition:
push _invalid_definition
jmp fatal_error
write_failed:
push _write_failed
jmp fatal_error
file_not_found:
push _file_not_found
jmp assembler_error
error_reading_file:
push _error_reading_file
jmp assembler_error
invalid_file_format:
push _invalid_file_format
jmp assembler_error
invalid_macro_arguments:
push _invalid_macro_arguments
jmp assembler_error
incomplete_macro:
push _incomplete_macro
jmp assembler_error
unexpected_characters:
push _unexpected_characters
jmp assembler_error
invalid_argument:
push _invalid_argument
jmp assembler_error
illegal_instruction:
push _illegal_instruction
jmp assembler_error
invalid_operand:
push _invalid_operand
jmp assembler_error
invalid_operand_size:
push _invalid_operand_size
jmp assembler_error
operand_size_not_specified:
push _operand_size_not_specified
jmp assembler_error
operand_sizes_do_not_match:
push _operand_sizes_do_not_match
jmp assembler_error
invalid_address_size:
push _invalid_address_size
jmp assembler_error
address_sizes_do_not_agree:
push _address_sizes_do_not_agree
jmp assembler_error
prefix_conflict:
push _prefix_conflict
jmp assembler_error
long_immediate_not_encodable:
push _long_immediate_not_encodable
jmp assembler_error
relative_jump_out_of_range:
push _relative_jump_out_of_range
jmp assembler_error
invalid_expression:
push _invalid_expression
jmp assembler_error
invalid_address:
push _invalid_address
jmp assembler_error
invalid_value:
push _invalid_value
jmp assembler_error
value_out_of_range:
push _value_out_of_range
jmp assembler_error
undefined_symbol:
mov edi,message
mov esi,_undefined_symbol
call copy_asciiz
push message
cmp [error_info],0
je assembler_error
mov byte [edi-1],20h
call write_quoted_symbol_name
jmp assembler_error
copy_asciiz:
lods byte [esi]
stos byte [edi]
test al,al
jnz copy_asciiz
ret
write_quoted_symbol_name:
mov al,27h
stosb
mov esi,[error_info]
movzx ecx,byte [esi-1]
rep movs byte [edi],[esi]
mov ax,27h
stosw
ret
symbol_out_of_scope:
mov edi,message
mov esi,_symbol_out_of_scope_1
call copy_asciiz
cmp [error_info],0
je finish_symbol_out_of_scope_message
mov byte [edi-1],20h
call write_quoted_symbol_name
finish_symbol_out_of_scope_message:
mov byte [edi-1],20h
mov esi,_symbol_out_of_scope_2
call copy_asciiz
push message
jmp assembler_error
invalid_use_of_symbol:
push _invalid_use_of_symbol
jmp assembler_error
name_too_long:
push _name_too_long
jmp assembler_error
invalid_name:
push _invalid_name
jmp assembler_error
reserved_word_used_as_symbol:
push _reserved_word_used_as_symbol
jmp assembler_error
symbol_already_defined:
push _symbol_already_defined
jmp assembler_error
missing_end_quote:
push _missing_end_quote
jmp assembler_error
missing_end_directive:
push _missing_end_directive
jmp assembler_error
unexpected_instruction:
push _unexpected_instruction
jmp assembler_error
extra_characters_on_line:
push _extra_characters_on_line
jmp assembler_error
section_not_aligned_enough:
push _section_not_aligned_enough
jmp assembler_error
setting_already_specified:
push _setting_already_specified
jmp assembler_error
data_already_defined:
push _data_already_defined
jmp assembler_error
too_many_repeats:
push _too_many_repeats
jmp assembler_error
invoked_error:
push _invoked_error
jmp assembler_error

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,608 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; flat assembler source ;;
;; Copyright (c) 1999-2006, Tomasz Grysztar ;;
;; All rights reserved. ;;
;; ;;
;; Menuet port by VT ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
NORMAL_MODE = 8
CONSOLE_MODE = 32
MAGIC1 = 6*(text.line_size-1)+14
MAX_PATH = 100
APP_MEMORY = 0x00800000
;; Menuet header
appname equ "flat assembler "
use32
org 0x0
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; program start
dd program_end ; program image size
dd stacktop ; required amount of memory
dd stacktop ; stack
dd params,0x0 ; parameters,icon
include 'lang.inc'
include '..\..\..\macros.inc'
purge add,sub ; macros.inc does incorrect substitution
include 'fasm.inc'
center fix true
START: ; Start of execution
mov edi, fileinfos
mov ecx, (fileinfos_end-fileinfos)/4
or eax, -1
rep stosd
push 68
pop eax
push 11
pop ebx
mcall
cmp [params],0
jz red
mov ecx,10
mov eax,' '
mov edi,infile
push ecx
cld
rep stosd
mov ecx,[esp]
mov edi,outfile
rep stosd
pop ecx
mov edi,path
rep stosd
mov esi,params
; DEBUGF "params: %s\n",esi
mov edi,infile
call mov_param_str
; mov edi,infile
; DEBUGF " input: %s\n",edi
inc esi
mov edi,outfile
call mov_param_str
; mov edi,outfile
; DEBUGF "output: %s\n",edi
inc esi
mov edi,path
call mov_param_str
; mov edi,path
; DEBUGF " path: %s\n",edi
cmp [esi], dword ',run'
jne @f
mov [_run_outfile],1
@@:
mov [_mode],CONSOLE_MODE
jmp start
red: ; Redraw
call draw_window
still:
push 10 ; Wait here for event
pop eax
mcall
dec eax
je red ; Redraw request
dec eax
jne button ; Button in buffer
key: ; Key
mov al,2 ; Read it and ignore
mcall
jmp still
button: ; Button in Window
mov al,17
mcall
cmp ah,1
jne noclose
or eax,-1
mcall
noclose:
cmp ah,2 ; Start compiling
je start
cmp ah,3 ; Start compiled file
jnz norunout
mov edx,outfile
call make_fullpaths
mcall 70,file_info_start
; xor ecx,ecx
jmp still
norunout:
cmp ah,4
jnz norundebug
mov edx,outfile
call make_fullpaths
mcall 70,file_info_debug
jmp still
norundebug:
mov ecx,5
mov [ya],ecx
cmp ah,11 ; Infile
je f1
cmp ah,12 ; Outfile
je f2
cmp ah,13 ; Path
je f3
cmp ah,14
je f4
jmp still
f4:
xor [bGenerateDebugInfo], 1
mcall 8,,,0x8000000E
call draw_checkbox
jmp still
draw_window:
pusha
mcall 12,1 ; Start of draw
get_sys_colors 1,0
xor eax,eax
mov ebx,100*65536+280
mov ecx,90*65536+260
mov edx,[sc.work]
or edx,0x33000000
mov edi,title ; Draw Window Label Text
mcall
mcall 9,PROCESSINFO,-1
mpack ecx,1,1
mov ebx,[pinfo.box.width]
sub ebx,10
push ecx
madd ecx, 14*3+16+2, 14*3+16+2
mcall 38,,,[sc.work_graph]
pop ecx
sub ebx,MAGIC1+3
mcall
madd ecx, 14, 14
mcall
madd ecx, 14, 14
mcall
madd ecx, 14, 14
mcall
push ebx
mpack ebx,MAGIC1,MAGIC1
sub ecx, 14*3
mcall
mov ebx,[esp-2]
pop bx
mcall
add esp,2
mpack ebx,0,MAGIC1-1
mpack ecx,1+1, 14-2
mcall 8,,,0x4000000B ; Button: Enter Infile
madd ecx, 14,0
mcall ,,,0x4000000C ; Button: Enter Outfile
madd ecx, 14,0
mcall ,,,0x4000000D ; Button: Enter Path
mpack ebx,[pinfo.box.width],MAGIC1
msub ebx,MAGIC1+10+1,0
mpack ecx,0, (14*3+16)/3-1
madd ecx,1,0
mcall ,,,0x00000002,[sc.work_button]
madd ecx, (14*3+16)/3+1,0
mcall ,,,0x00000003
madd ecx, (14*3+16)/3+1,0
mcall ,,,4
mpack ebx,6,0 ; Draw Window Text
add ebx,1+ 14/2-3
mov ecx,[sc.work_text]
mov edx,text
mov esi,text.line_size
mov eax,4
newline:
mcall
add ebx, 14
add edx,text.line_size
cmp byte[edx],'x'
jne newline
mov ebx,[pinfo.box.width]
sub ebx,MAGIC1+10+1-9
shl ebx,16
add ebx,1+( (14*3+16)/3-1)/2-3
mcall ,,[sc.work_button_text],s_compile,7
add ebx,(14*3+16)/3+1
mcall ,,,s_run
add ebx,(14*3+16)/3+1
mcall ,,,s_debug
mpack ebx,MAGIC1+6,0
add ebx,1+ 14/2-3+ 14*0
mov esi,[pinfo.box.width]
sub esi,MAGIC1*2+5*2+6+3
mov eax,esi
mov cl,6
div cl
cmp al,MAX_PATH
jbe @f
mov al,MAX_PATH
@@: movzx esi,al
mcall 4,,[sc.work_text],infile
add ebx,14
mcall ,,,outfile
add ebx,14
mcall ,,,path
call draw_checkbox
call draw_messages
mcall 12,2 ; End of Draw
popa
ret
bottom_right dd ?
draw_checkbox:
mcall 8,<5,10>,<14*3+5,10>,14,[sc.work_button]
cmp [bGenerateDebugInfo], 0
jz @f
mov edx, [sc.work_button_text]
mcall 38,<7,13>,<14*3+7,14*3+13>
mcall 38,,<14*3+13,14*3+7>
@@:
mov ecx, [sc.work_text]
or ecx, 0x80000000
mcall 4,<20,14*3+7>,,s_dbgdescr
ret
draw_messages:
mov eax,13 ; clear work area
mpack ebx,7-2,[pinfo.box.width]
sub ebx,5*2+7*2-1-2*2
mpack ecx,0,[pinfo.box.height]
madd ecx, 14*3+16+1+7+1,-( 14*3+16+1+7*2+25)
mov word[bottom_right+2],bx
mov word[bottom_right],cx
msub [bottom_right],7,11
add [bottom_right],7 shl 16 + 53
mov edx,[sc.work]
mcall
_cy = 0
_sy = 2
_cx = 4
_sx = 6
push ebx ecx
mpack ebx,4,5
add bx,[esp+_cx]
mov ecx,[esp+_sy-2]
mov cx,[esp+_sy]
msub ecx,1,1
mcall 38,,,[sc.work_graph]
mov si,[esp+_cy]
add cx,si
shl esi,16
add ecx,esi
madd ecx,1,1
mcall
mpack ebx,4,4
mov esi,[esp+_sy-2]
mov si,cx
mov ecx,esi
mcall
mov si,[esp+_cx]
add bx,si
shl esi,16
add ebx,esi
madd ebx,1,1
mcall
pop ecx ebx
ret
; read string
f1: mov [addr],infile
add [ya], 14*0
jmp rk
f2: mov [addr],outfile
add [ya], 14*1
jmp rk
f3: mov [addr],path
add [ya], 14*2
rk:
mov edi,[addr]
mov al,0
mov ecx,MAX_PATH
add edi,ecx
dec edi
std
repe scasb
sub ecx,MAX_PATH
neg ecx
mov al,$1C ; ''
add edi,2
push edi
cld
rep stosb
call print_text
pop edi
f11:mcall 10
cmp eax,2
jne read_done
mcall; 2
shr eax,8
cmp al,13
je read_done
cmp al,8
jne nobs
cmp edi,[addr]
je f11
sub edi,1
mov byte[edi],$1C ; '_'
call print_text
jmp f11
nobs:
movzx ebx,al
sub ebx,$20
jle f11
sub al,[sub_table+ebx]
keyok:
mov ecx,[addr]
add ecx,MAX_PATH
cmp edi,ecx
jae f11
mov [edi],al
call print_text
inc edi
jmp f11
read_done:
mov ecx,[addr]
add ecx,MAX_PATH
sub ecx,edi
mov al,0;' '
cld
rep stosb
call print_text
jmp still
print_text:
mpack ebx,MAGIC1+6,[pinfo.box.width]
sub ebx,MAGIC1*2+19
movzx esi,bx
mov ecx,[ya-2]
mov cx,8
mcall 13,,,[sc.work]
mpack ebx,MAGIC1+6,[ya]
mov eax,esi
mov cl,6
div cl
cmp al,MAX_PATH
jbe @f
mov al,MAX_PATH
@@: movzx esi,al
mcall 4,,[sc.work_text],[addr]
ret
; DATA
text:
db ' INFILE:'
.line_size = $-text
db 'OUTFILE:'
db ' PATH:'
db 'x'
s_compile db 'COMPILE'
s_run db ' RUN '
s_debug db ' DEBUG '
s_dbgdescr db 'Generate debug information',0
infile db 'example.asm'
times MAX_PATH+$-infile db 0
outfile db 'example'
times MAX_PATH+$-outfile db 0
path db '/rd/1/'
times MAX_PATH+$-path db 0
lf db 13,10,0
addr dd 0x0
ya dd 0x0
zero db 0x0
mov_param_str:
@@:
mov al,[esi]
cmp al,','
je @f
cmp al,0
je @f
mov [edi],al
inc esi
inc edi
jmp @b
@@:
mov al,0
stosb
ret
start:
cmp [_mode],NORMAL_MODE
jne @f
call draw_messages
mov [textxy],7 shl 16 + 70
@@:
mov esi,_logo
call display_string
;
; Fasm native code
;
mov [input_file],infile
mov [output_file],outfile
call init_memory
call make_timestamp
mov [start_time],eax
call preprocessor
call parser
call assembler
cmp [bGenerateDebugInfo], 0
jz @f
call symbol_dump
@@:
call formatter
call display_user_messages
movzx eax,[current_pass]
inc eax
call display_number
mov esi,_passes_suffix
call display_string
call make_timestamp
sub eax,[start_time]
xor edx,edx
mov ebx,100
div ebx
or eax,eax
jz display_bytes_count
xor edx,edx
mov ebx,10
div ebx
push edx
call display_number
mov dl,'.'
call display_character
pop eax
call display_number
mov esi,_seconds_suffix
call display_string
display_bytes_count:
mov eax,[written_size]
call display_number
mov esi,_bytes_suffix
call display_string
xor al,al
cmp [_run_outfile],0
je @f
mov edx,outfile
call make_fullpaths
mov eax,70
mov ebx,file_info_start
xor ecx,ecx
mcall
@@:
jmp exit_program
include 'system.inc'
include 'version.inc'
include 'errors.inc'
include 'expressi.inc'
include 'preproce.inc'
include 'parser.inc'
include 'assemble.inc'
include 'formats.inc'
include 'x86_64.inc'
include 'tables.inc'
include 'symbdump.inc'
include 'messages.inc'
title db appname,VERSION_STRING,0
_logo db 'flat assembler version ',VERSION_STRING,13,10,0
_passes_suffix db ' passes, ',0
_seconds_suffix db ' seconds, ',0
_bytes_suffix db ' bytes.',13,10,0
_include db 'INCLUDE',0
_counter db 4,'0000'
_mode dd NORMAL_MODE
_run_outfile dd 0
bGenerateDebugInfo db 0
sub_table:
times $41 db $00
times $1A db $20
times $25 db $00
times $10 db $20
times $30 db $00
times $10 db $50
times $04 db $00,$01
times $08 db $00
;include_debug_strings
params db 0 ; 'TINYPAD.ASM,TINYPAD,/HD/1/TPAD4/',
program_end:
rb 1000h
align 4
include 'variable.inc'
program_base dd ?
buffer_address dd ?
memory_setting dd ?
start_time dd ?
memblock dd ?
predefinitions rb 1000h
dbgfilename rb MAX_PATH+4
sc system_colors
max_handles = 8
fileinfos rb (4+20+MAX_PATH)*max_handles
fileinfos_end:
pinfo process_information
align 1000h
rb 1000h
stacktop:

View File

@ -0,0 +1,53 @@
center fix false
SYSTEMCOLORS fix sc
PROCESSINFO fix pinfo
macro get_sys_colors wnd_skin,font_1 {
mcall 48,3,SYSTEMCOLORS,sizeof.system_colors
if wnd_skin <> 0
or [SYSTEMCOLORS+system_colors.work],0x03000000
end if
if font_1 <> 0
or [SYSTEMCOLORS+system_colors.grab_text],0x10000000
end if
}
macro draw_caption _edx,_esi {
mov edx,_edx
mov esi,_esi
call __draw_caption
}
macro mmov reg,a1,a2 {
mov reg,(a1) shl 16 + (a2)
}
macro madd reg,a1,a2 {
add reg,(a1) shl 16 + (a2)
}
macro msub reg,a1,a2 {
sub reg,(a1) shl 16 + (a2)
}
macro jmpe reg,def,[val,lab] {
forward
cmp reg,val
je lab
common
if ~def eq
jmp def
end if
}
macro func name {
if used name
name:
}
macro endf {
end if
}
@^ fix macro comment {
^@ fix }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,51 @@
; flat assembler core
; Copyright (c) 1999-2009, Tomasz Grysztar.
; All rights reserved.
_out_of_memory db 'out of memory',0
_stack_overflow db 'out of stack space',0
_main_file_not_found db 'source file not found',0
_unexpected_end_of_file db 'unexpected end of file',0
_code_cannot_be_generated db 'code cannot be generated',0
_format_limitations_exceeded db 'format limitations exceeded',0
_invalid_definition db 'invalid definition provided',0
_write_failed db 'write failed',0
_file_not_found db 'file not found',0
_error_reading_file db 'error reading file',0
_invalid_file_format db 'invalid file format',0
_invalid_macro_arguments db 'invalid macro arguments',0
_incomplete_macro db 'incomplete macro',0
_unexpected_characters db 'unexpected characters',0
_invalid_argument db 'invalid argument',0
_illegal_instruction db 'illegal instruction',0
_invalid_operand db 'invalid operand',0
_invalid_operand_size db 'invalid size of operand',0
_operand_size_not_specified db 'operand size not specified',0
_operand_sizes_do_not_match db 'operand sizes do not match',0
_invalid_address_size db 'invalid size of address value',0
_address_sizes_do_not_agree db 'address sizes do not agree',0
_prefix_conflict db 'disallowed combination of registers',0
_long_immediate_not_encodable db 'not encodable with long immediate',0
_relative_jump_out_of_range db 'relative jump out of range',0
_invalid_expression db 'invalid expression',0
_invalid_address db 'invalid address',0
_invalid_value db 'invalid value',0
_value_out_of_range db 'value out of range',0
_undefined_symbol db 'undefined symbol',0
_symbol_out_of_scope_1 db 'symbol',0
_symbol_out_of_scope_2 db 'out of scope',0
_invalid_use_of_symbol db 'invalid use of symbol',0
_name_too_long db 'name too long',0
_invalid_name db 'invalid name',0
_reserved_word_used_as_symbol db 'reserved word used as symbol',0
_symbol_already_defined db 'symbol already defined',0
_missing_end_quote db 'missing end quote',0
_missing_end_directive db 'missing end directive',0
_unexpected_instruction db 'unexpected instruction',0
_extra_characters_on_line db 'extra characters on line',0
_section_not_aligned_enough db 'section is not aligned enough',0
_setting_already_specified db 'setting already specified',0
_data_already_defined db 'data already defined',0
_too_many_repeats db 'too many repeats',0
_invoked_error db 'error directive invoked in source file',0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,180 @@
; Macroinstructions for defining data structures
macro struct name
{ fields@struct equ name
match child parent, name \{ fields@struct equ child,fields@\#parent \}
sub@struct equ
struc db [val] \{ \common fields@struct equ fields@struct,.,db,<val> \}
struc dw [val] \{ \common fields@struct equ fields@struct,.,dw,<val> \}
struc du [val] \{ \common fields@struct equ fields@struct,.,du,<val> \}
struc dd [val] \{ \common fields@struct equ fields@struct,.,dd,<val> \}
struc dp [val] \{ \common fields@struct equ fields@struct,.,dp,<val> \}
struc dq [val] \{ \common fields@struct equ fields@struct,.,dq,<val> \}
struc dt [val] \{ \common fields@struct equ fields@struct,.,dt,<val> \}
struc rb count \{ fields@struct equ fields@struct,.,db,count dup (?) \}
struc rw count \{ fields@struct equ fields@struct,.,dw,count dup (?) \}
struc rd count \{ fields@struct equ fields@struct,.,dd,count dup (?) \}
struc rp count \{ fields@struct equ fields@struct,.,dp,count dup (?) \}
struc rq count \{ fields@struct equ fields@struct,.,dq,count dup (?) \}
struc rt count \{ fields@struct equ fields@struct,.,dt,count dup (?) \}
macro db [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,db,<val> \}
macro dw [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,dw,<val> \}
macro du [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,du,<val> \}
macro dd [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,dd,<val> \}
macro dp [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,dp,<val> \}
macro dq [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,dq,<val> \}
macro dt [val] \{ \common \local anonymous
fields@struct equ fields@struct,anonymous,dt,<val> \}
macro rb count \{ \local anonymous
fields@struct equ fields@struct,anonymous,db,count dup (?) \}
macro rw count \{ \local anonymous
fields@struct equ fields@struct,anonymous,dw,count dup (?) \}
macro rd count \{ \local anonymous
fields@struct equ fields@struct,anonymous,dd,count dup (?) \}
macro rp count \{ \local anonymous
fields@struct equ fields@struct,anonymous,dp,count dup (?) \}
macro rq count \{ \local anonymous
fields@struct equ fields@struct,anonymous,dq,count dup (?) \}
macro rt count \{ \local anonymous
fields@struct equ fields@struct,anonymous,dt,count dup (?) \}
macro union \{ fields@struct equ fields@struct,,union,<
sub@struct equ union \}
macro struct \{ fields@struct equ fields@struct,,substruct,<
sub@struct equ substruct \}
virtual at 0 }
macro ends
{ match , sub@struct \{ restruc db,dw,du,dd,dp,dq,dt
restruc rb,rw,rd,rp,rq,rt
purge db,dw,du,dd,dp,dq,dt
purge rb,rw,rd,rp,rq,rt
purge union,struct
match name=,fields,fields@struct \\{ fields@struct equ
make@struct name,fields
fields@\\#name equ fields \\}
end virtual \}
match any, sub@struct \{ fields@struct equ fields@struct> \}
restore sub@struct }
macro make@struct name,[field,type,def]
{ common
if $
display 'Error: definition of ',`name,' contains illegal instructions.',0Dh,0Ah
err
end if
local define
define equ name
forward
local sub
match , field \{ make@substruct type,name,sub def
define equ define,.,sub, \}
match any, field \{ define equ define,.#field,type,<def> \}
common
match fields, define \{ define@struct fields \} }
macro define@struct name,[field,type,def]
{ common
local list
list equ
forward
if ~ field eq .
name#field type def
sizeof.#name#field = $ - name#field
else
rb sizeof.#type
end if
local value
match any, list \{ list equ list, \}
list equ list <value>
common
sizeof.#name = $
restruc name
match values, list \{
struc name value \\{
match any, fields@struct \\\{ fields@struct equ fields@struct,.,name,<values> \\\}
match , fields@struct \\\{ label .
forward
match , value \\\\{ field type def \\\\}
match any, value \\\\{ field type value
if ~ field eq .
rb sizeof.#name#field - ($-field)
end if \\\\}
common \\\} \\} \} }
macro enable@substruct
{ macro make@substruct substruct,parent,name,[field,type,def]
\{ \common
\local define
define equ parent,name
\forward
\local sub
match , field \\{ match any, type \\\{ enable@substruct
make@substruct type,name,sub def
purge make@substruct
define equ define,.,sub, \\\} \\}
match any, field \\{ define equ define,.\#field,type,<def> \\}
\common
match fields, define \\{ define@\#substruct fields \\} \} }
enable@substruct
macro define@union parent,name,[field,type,def]
{ common
virtual at 0
forward
if ~ field eq .
virtual at 0
parent#field type def
sizeof.#parent#field = $ - parent#field
end virtual
if sizeof.#parent#field > $
rb sizeof.#parent#field - $
end if
else if sizeof.#type > $
rb sizeof.#type - $
end if
common
sizeof.#name = $
end virtual
struc name [value] \{ \common
label .\#name
last@union equ
forward
match any, last@union \\{ virtual at .\#name
field type def
end virtual \\}
match , last@union \\{ match , value \\\{ field type def \\\}
match any, value \\\{ field type value \\\} \\}
last@union equ field
common rb sizeof.#name - ($ - .\#name) \} }
macro define@substruct parent,name,[field,type,def]
{ common
virtual at 0
forward
if ~ field eq .
parent#field type def
sizeof.#parent#field = $ - parent#field
else
rb sizeof.#type
end if
local value
common
sizeof.#name = $
end virtual
struc name value \{
label .\#name
forward
match , value \\{ field type def \\}
match any, value \\{ field type value
if ~ field eq .
rb sizeof.#parent#field - ($-field)
end if \\}
common \} }

View File

@ -0,0 +1,110 @@
symbol_dump:
push edi
mov edx,[memory_end]
symb_dump:
cmp edx,[labels_list]
jbe symbols_dumped
sub edx,LABEL_STRUCTURE_SIZE
cmp dword [edx+24],0
je symb_dump ; do not dump anonymous symbols
test byte [edx+8],1
jz symb_dump ; do not dump symbols that didn't get defined
mov ax,[current_pass]
cmp ax,[edx+16]
jne symb_dump
test byte [edx+8],4 or 2
jnz symb_dump ; do not dump assembly-time variables
; do not dump variables defined with '='
cmp word [edx+12], 0
jnz symb_dump ; do not dump register-based variables
mov al, '0'
stosb
mov al, 'x'
stosb
mov eax, [edx+4]
mov ecx, 8
@@:
rol eax, 4
test al, 0xF
loopz @b
jz .nohigh
inc ecx
@@:
push eax
and al, 0xF
cmp al, 10
sbb al, 69h
das
stosb
pop eax
rol eax, 4
loop @b
mov eax, [edx]
mov ecx, 8
jmp .low
.nohigh:
mov eax, [edx]
mov ecx, 8
@@:
rol eax, 4
test al, 0xF
loopz @b
inc ecx
.low:
push eax
and al, 0xF
cmp al, 10
sbb al, 69h
das
stosb
pop eax
rol eax, 4
loop .low
mov al, ' '
stosb
mov esi,[edx+24]
movzx ecx,byte [esi-1]
rep movsb
mov ax,0A0Dh
stosw
jmp symb_dump
symbols_dumped:
mov edx,dbgfilename
push esi edi
mov esi, outfile
mov edi, edx
@@:
lodsb
stosb
test al, al
jnz @b
lea ecx, [edi-1]
@@:
dec edi
cmp edi, edx
jb @f
cmp byte [edi], '/'
jz @f
cmp byte [edi], '.'
jnz @b
mov ecx, edi
@@:
mov dword [ecx], '.dbg'
mov byte [ecx+4], 0
pop edi esi
call create
mov edx,[esp]
mov ecx,edi
sub ecx,edx
call write
call close
pop edi
ret

View File

@ -0,0 +1,573 @@
; flat assembler
; Copyright (c) 1999-2007, Tomasz Grysztar
; All rights reserved.
struc FILEIO
{ .cmd dd ?
.offset dd ?
dd ?
.count dd ?
.buff dd ?
db ?
.name dd ?
};
struc FILEINFO
{ .attr dd ?
.flags dd ?
.cr_time dd ?
.cr_date dd ?
.acc_time dd ?
.acc_date dd ?
.mod_time dd ?
.mod_date dd ?
.size dd ?
}
;file_info_open: dd 0,0,0xffffff,0x20000,0xf0000
fullpath_open: ; db '/RD/1/EXAMPLE.ASM'
times MAX_PATH db 0
;file_info_write: dd 1,0,0,0,0xf0000
fullpath_write:; db '/RD/1/EXAMPLE'
times MAX_PATH db 0
file_info_start:
dd 7
dd 0
dd 0
dd 0
dd 0
fullpath_start: ; db '/RD/1/EXAMPLE'
times MAX_PATH db 0
file_info_debug:
dd 7
dd 0
dd fullpath_start
dd 0, 0
db '/SYS/DEVELOP/MTDBG',0
_ramdisk db '/RD/1/'
filepos dd 0x0
init_memory:
mov ecx, 16*1024*1024
allocate_memory:
mov [memory_setting],ecx
mcall 68, 12
or eax,eax
jz out_of_memory
mov [additional_memory],eax
add eax,[memory_setting]
mov [memory_end],eax
mov eax,[memory_setting]
shr eax,2
add eax,[additional_memory]
mov [additional_memory_end],eax
mov [memory_start],eax
ret
exit_program:
cmp [_mode],NORMAL_MODE
jne @f
mcall 68, 13, [memblock]
jmp still
@@:
or eax,-1
mcall
make_timestamp:
push ebx
mcall 26,9
imul eax,10
pop ebx
ret
get_environment_variable:
mov ecx,[memory_end]
sub ecx,edi
cmp ecx,7
jb out_of_memory
cmp dword[esi],'INCL'
jne .finish
mov esi,_ramdisk
mov ecx,6
cld
rep movsb
.finish:
; stc
ret
alloc_handle:
call make_fullpaths
mov ebx, fileinfos+4
@@:
cmp dword [ebx], -1
jz .found
add ebx, 4+20+MAX_PATH
cmp ebx, fileinfos_end
jb @b
stc
ret
.found:
and dword [ebx+4], 0
and dword [ebx+8], 0
push esi edi ecx
mov esi, fullpath_open
lea edi, [ebx+20]
mov ecx, MAX_PATH
rep movsb
pop ecx edi esi
ret ; CF=0
create:
call alloc_handle
jc .ret
and dword [ebx-4], 0
mov dword [ebx], 2
.ret:
ret
open:
; call make_fullpaths
;; mov eax,fullpath_open
;; DEBUGF '"%s"\n',eax
; mov dword[file_info_open+8],-1
; mcall 58,file_info_open
; or eax,eax ; found
; jz @f
; cmp eax,6
; jne file_error
;@@: mov [filesize],ebx
; clc
; ret
;file_error:
; stc
; ret
call alloc_handle
jc .ret
mov dword [ebx], 5
and dword [ebx+12], 0
mov dword [ebx+16], fileinfo
mov eax, 70
push ebx
mcall
pop ebx
test eax, eax
jnz .fail
mov eax, [fileinfo.size]
mov [ebx-4], eax
and dword [ebx], 0
.ret:
ret
.fail:
or dword [ebx], -1 ; close handle
stc
ret
read:
; pusha
; mov edi,edx
; mov esi,[filepos]
; add esi,0x20000
; cld
; rep movsb
; popa
;; ret
mov [ebx+12], ecx
mov [ebx+16], edx
push ebx
mov eax, 70
mcall
xchg eax, [esp]
add [eax+4], ebx
adc [eax+8], dword 0
mov ebx, eax
pop eax
test eax, eax
jz .ok
cmp eax, 6
jz .ok
stc
.ok:
ret
close:
or dword [ebx], -1
ret
; ebx file handle
; ecx count of bytes to write
; edx pointer to buffer
write:
; pusha
; mov [file_info_write+8],ecx
; mov [file_info_write+12],edx
; mov [filesize],edx
; mov eax,58
; mov ebx,file_info_write
; mcall
; popa
; ret
mov [ebx+12], ecx
mov [ebx+16], edx
push ebx
mov eax, 70
mcall
xchg eax, [esp]
add [eax+4], ebx
adc [eax+8], dword 0
mov ebx, eax
pop eax
mov byte [ebx], 3
cmp eax, 1
cmc
ret
make_fullpaths:
pusha
push edx
mov esi,path ; open
; DEBUGF " '%s'",esi
mov edi,fullpath_open
cld
newc1:
movsb
cmp byte[esi],0;' '
jne newc1
mov esi,[esp]
cmp byte[esi],'/'
jne @f
mov edi,fullpath_open
@@:
lodsb
stosb
cmp al,0
jne @b
; mov ecx,12
; cld
; rep movsb
; mov byte[edi],0
mov esi,path ; write
mov edi,fullpath_write
cld
newc2:
movsb
cmp byte[esi],0;' '
jne newc2
mov esi,[esp]
cmp byte[esi],'/'
jne @f
mov edi,fullpath_write
@@:
lodsb
stosb
cmp al,0
jne @b
; mov ecx,12
; cld
; rep movsb
; mov byte[edi],0
mov esi,path ; start
mov edi,fullpath_start
cld
newc3:
movsb
cmp byte[esi],0;' '
jne newc3
; mov esi,[esp]
pop esi
cmp byte[esi],'/'
jne @f
mov edi,fullpath_start
@@:
lodsb
stosb
cmp al,0
jne @b
; mov ecx,12
; cld
; rep movsb
; mov byte[edi],0
; add esp,4
popa
ret
lseek:
cmp al,0
jnz @f
and dword [ebx+4], 0
and dword [ebx+8], 0
@@: cmp al,2
jnz @f
mov eax, [ebx-4]
mov [ebx+4], eax
and dword [ebx+8], 0
@@: add dword [ebx+4], edx
adc dword [ebx+8], 0
ret
display_character:
pusha
cmp [_mode],NORMAL_MODE
jne @f
cmp dl,13
jz dc2
cmp dl,0xa
jnz dc1
and [textxy],0x0000FFFF
add [textxy], 7 shl 16 +53 and 0xFFFF0000 + 10
dc2:
popa
ret
dc1:
mov eax,[textxy]
cmp ax,word[bottom_right]
ja dc2
shr eax,16
cmp ax,word[bottom_right+2]
ja dc2
mov [dc],dl
mcall 4,[textxy],[sc.work_text],dc,1
add [textxy],0x00060000
popa
ret
@@:
mov eax,63
mov ebx,1
mov cl,dl
mcall
popa
ret
display_string:
pusha
@@:
cmp byte[esi],0
je @f
mov dl,[esi]
call display_character
add esi,1
jmp @b
@@:
popa
ret
display_number:
push ebx
mov ecx,1000000000
xor edx,edx
xor bl,bl
display_loop:
div ecx
push edx
cmp ecx,1
je display_digit
or bl,bl
jnz display_digit
or al,al
jz digit_ok
not bl
display_digit:
mov dl,al
add dl,30h
push ebx ecx
call display_character
pop ecx ebx
digit_ok:
mov eax,ecx
xor edx,edx
mov ecx,10
div ecx
mov ecx,eax
pop eax
or ecx,ecx
jnz display_loop
pop ebx
ret
display_user_messages:
; push [skinh]
; pop [textxy]
; add [textxy], 7 shl 16 +53
mov [displayed_count],0
call show_display_buffer
cmp [displayed_count],1
jb line_break_ok
je make_line_break
mov ax,word[last_displayed]
cmp ax,0A0Dh
je line_break_ok
cmp ax,0D0Ah
je line_break_ok
make_line_break:
mov esi,lf
call display_string
line_break_ok:
ret
display_block:
pusha
@@: mov dl,[esi]
call display_character
inc esi
loop @b
popa
ret
fatal_error:
mov esi,error_prefix
call display_string
pop esi
call display_string
mov esi,error_suffix
call display_string
mov esi,lf
call display_string
mov al,0FFh
jmp exit_program
assembler_error:
call display_user_messages
push dword 0
mov ebx,[current_line]
get_error_lines:
push ebx
test byte [ebx+7],80h
jz display_error_line
mov edx,ebx
find_definition_origin:
mov edx,[edx+12]
test byte [edx+7],80h
jnz find_definition_origin
push edx
mov ebx,[ebx+8]
jmp get_error_lines
display_error_line:
mov esi,[ebx]
call display_string
mov esi,line_number_start
call display_string
mov eax,[ebx+4]
and eax,7FFFFFFFh
call display_number
mov dl,']'
call display_character
pop esi
cmp ebx,esi
je line_number_ok
mov dl,20h
call display_character
push esi
mov esi,[esi]
movzx ecx,byte [esi]
inc esi
call display_block
mov esi,line_number_start
call display_string
pop esi
mov eax,[esi+4]
and eax,7FFFFFFFh
call display_number
mov dl,']'
call display_character
line_number_ok:
mov esi,line_data_start
call display_string
mov esi,ebx
mov edx,[esi]
call open
mov al,2
xor edx,edx
call lseek
mov edx,[esi+8]
sub eax,edx
push eax
xor al,al
call lseek
mov ecx,[esp]
mov edx,[additional_memory]
lea eax,[edx+ecx]
cmp eax,[additional_memory_end]
ja out_of_memory
call read
call close
pop ecx
mov esi,[additional_memory]
get_line_data:
mov al,[esi]
cmp al,0Ah
je display_line_data
cmp al,0Dh
je display_line_data
cmp al,1Ah
je display_line_data
or al,al
jz display_line_data
inc esi
loop get_line_data
display_line_data:
mov ecx,esi
mov esi,[additional_memory]
sub ecx,esi
call display_block
mov esi,cr_lf
call display_string
pop ebx
or ebx,ebx
jnz display_error_line
mov esi,error_prefix
call display_string
pop esi
call display_string
mov esi,error_suffix
call display_string
jmp exit_program
align 4
fileinfo FILEINFO
character db ?,0
bytes_count dd ?
textxy dd 0x000500A0
dc db 0x0
filesize dd 0x0
displayed_count dd ?
last_displayed rb 2
error_prefix db 'error: ',0
error_suffix db '.',0
line_data_start db ':'
cr_lf db 0Dh,0Ah,0
line_number_start db ' [',0
macro dm string { db string,0 }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,130 @@
; flat assembler core variables
; Copyright (c) 1999-2009, Tomasz Grysztar.
; All rights reserved.
; Variables which have to be set up by interface:
memory_start dd ?
memory_end dd ?
additional_memory dd ?
additional_memory_end dd ?
stack_limit dd ?
input_file dd ?
output_file dd ?
symbols_file dd ?
passes_limit dw ?
; Internal core variables:
current_pass dw ?
include_paths dd ?
free_additional_memory dd ?
source_start dd ?
code_start dd ?
code_size dd ?
real_code_size dd ?
written_size dd ?
headers_size dd ?
current_line dd ?
macro_line dd ?
macro_block dd ?
macro_block_line dd ?
macro_block_line_number dd ?
macro_symbols dd ?
struc_name dd ?
struc_label dd ?
instant_macro_start dd ?
parameters_end dd ?
locals_counter rb 8
current_locals_prefix dd ?
anonymous_reverse dd ?
anonymous_forward dd ?
labels_list dd ?
label_hash dd ?
label_leaf dd ?
hash_tree dd ?
org_origin dq ?
org_registers dd ?
org_symbol dd ?
org_start dd ?
undefined_data_start dd ?
undefined_data_end dd ?
counter dd ?
counter_limit dd ?
error_info dd ?
error_line dd ?
error dd ?
display_buffer dd ?
structures_buffer dd ?
number_start dd ?
current_offset dd ?
value dq ?
fp_value rd 8
adjustment dq ?
symbol_identifier dd ?
address_symbol dd ?
address_high dd ?
format_flags dd ?
resolver_flags dd ?
symbols_stream dd ?
number_of_relocations dd ?
number_of_sections dd ?
stub_size dd ?
stub_file dd ?
current_section dd ?
machine dw ?
subsystem dw ?
subsystem_version dd ?
image_base dd ?
image_base_high dd ?
resource_data dd ?
resource_size dd ?
parenthesis_stack dd ?
blocks_stack dd ?
parsed_lines dd ?
logical_value_parentheses dd ?
file_extension dd ?
labels_type db ?
code_type db ?
virtual_data db ?
operand_size db ?
size_override db ?
operand_prefix db ?
rex_prefix db ?
opcode_prefix db ?
base_code db ?
extended_code db ?
supplemental_code db ?
postbyte_register db ?
immediate_size db ?
mmx_size db ?
jump_type db ?
push_size db ?
value_size db ?
address_size db ?
size_declared db ?
value_undefined db ?
value_type db ?
compare_type db ?
logical_value_wrapping db ?
next_pass_needed db ?
macro_status db ?
segment_register db ?
prefixed_instruction db ?
fp_sign db ?
fp_format db ?
output_format db ?
characters rb 100h
converted rb 100h
message rb 200h

View File

@ -0,0 +1,39 @@
; flat assembler version 1.68
; Copyright (c) 1999-2009, Tomasz Grysztar.
; All rights reserved.
;
; This programs is free for commercial and non-commercial use as long as
; the following conditions are adhered to.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are
; met:
;
; 1. Redistributions of source code must retain the above copyright notice,
; this list of conditions and the following disclaimer.
; 2. Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in the
; documentation and/or other materials provided with the distribution.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
; TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
; PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;
; The licence and distribution terms for any publically available
; version or derivative of this code cannot be changed. i.e. this code
; cannot simply be copied and put under another distribution licence
; (including the GNU Public Licence).
VERSION_STRING equ "1.68"
VERSION_MAJOR = 1
VERSION_MINOR = 68

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,57 @@
Visit http://flatassembler.net/ for more information.
version 1.69.06 (Sep 29, 2009)
[-] The prefix 67h for "jecxz" and "loopd" instructions in 64-bit mode wasn't
correctly generated - fixed.
[-] It's no longer possible to define two special segments of the same type
in ELF executables.
version 1.69.05 (Sep 14, 2009)
[+] Allowed to specify branding value (use 3 for Linux) after the
"format ELF executable" setting.
[+] Added "intepreter", "dynamic" and "note" keywords for creation of
special segments in ELF executables.
version 1.69.04 (Sep 7, 2009)
[-] Fixed a bug with REX prefix generation with address of type "rX+rsp".
version 1.69.03 (Aug 03, 2009)
[+] Allowed simplified syntax for "monitor", "mwait", "blendvps", "blendvpd" and
"pblendvb" instructions.
version 1.69.02 (Jul 04, 2009)
[-] Minor bugfixes.
version 1.69.01 (Jul 01, 2009)
[+] Added "movbe" instruction.
[-] "extractps" no longer generates the double 66h prefix.
version 1.69.00 (Jun 23, 2009)
[+] Extended the syntax of "rept" directive to allow numerical expressions
to be calculated by preprocessor in its arguments.
[-] The code of assembler (but not data) has been made position-independent, and
this allowed to use code segmentation in DOS unREAL mode, so the code is
no longer limited to 64 kilobytes.
version 1.68 (Jun 13, 2009)
[+] Added SSSE3 (Supplemental SSE3), SSE4.1, SSE4.2 and SSE4a instructions.
@ -63,11 +114,11 @@ version 1.66 (May 7, 2006)
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
@ -79,9 +130,9 @@ 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
that the condition is true, even though one of the logical values makes no
@ -91,9 +142,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

View File

@ -115,7 +115,12 @@ assembler:
or eax,eax
jz assemble_ok
mov [current_line],eax
jmp near [error]
call error_handler
error_handler:
mov eax,[error]
sub eax,error_handler
add [esp],eax
ret
next_pass:
inc [current_pass]
mov ax,[current_pass]
@ -359,11 +364,13 @@ assemble_line:
mov dword [operand_size],0
mov [opcode_prefix],0
mov [immediate_size],0
call instruction_handler
instruction_handler:
movzx ebx,word [esi]
mov al,[esi+2]
add ebx,assembler
add esi,3
jmp near ebx
add [esp],ebx
ret
instruction_assembled:
mov al,[esi]
cmp al,0Fh
@ -894,7 +901,7 @@ virtual_directive:
mov byte [org_registers+2],ch
mov byte [org_registers+3],cl
call allocate_structure_data
mov word [ebx],virtual_directive-assembler
mov word [ebx],virtual_directive-instruction_handler
not eax
not edx
add eax,1
@ -993,7 +1000,7 @@ repeat_directive:
je zero_repeat
jl negative_repeat
call allocate_structure_data
mov word [ebx],repeat_directive-assembler
mov word [ebx],repeat_directive-instruction_handler
xchg eax,[counter_limit]
mov [ebx+10h],eax
mov eax,1
@ -1038,14 +1045,14 @@ repeat_directive:
jmp instruction_assembled
find_end_repeat:
call find_structure_end
cmp ax,repeat_directive-assembler
cmp ax,repeat_directive-instruction_handler
jne unexpected_instruction
ret
while_directive:
cmp [prefixed_instruction],0
jne unexpected_instruction
call allocate_structure_data
mov word [ebx],while_directive-assembler
mov word [ebx],while_directive-instruction_handler
mov eax,1
xchg eax,[counter]
mov [ebx+10h],eax
@ -1085,7 +1092,7 @@ while_directive:
jmp do_while
find_end_while:
call find_structure_end
cmp ax,while_directive-assembler
cmp ax,while_directive-instruction_handler
jne unexpected_instruction
ret
if_directive:
@ -1105,7 +1112,7 @@ if_directive:
mov al,[esi]
cmp al,1
jne else_true
cmp word [esi+1],if_directive-assembler
cmp word [esi+1],if_directive-instruction_handler
jne else_true
add esi,4
jmp if_directive
@ -1113,7 +1120,7 @@ if_directive:
xor al,al
make_if_structure:
call allocate_structure_data
mov word [ebx],if_directive-assembler
mov word [ebx],if_directive-instruction_handler
mov byte [ebx+2],al
mov eax,[current_line]
mov [ebx+4],eax
@ -1128,7 +1135,7 @@ if_directive:
else_directive:
cmp [prefixed_instruction],0
jne unexpected_instruction
mov ax,if_directive-assembler
mov ax,if_directive-instruction_handler
call find_structure_data
jc unexpected_instruction
cmp byte [ebx+2],0
@ -1137,7 +1144,7 @@ if_directive:
mov al,[esi]
cmp al,1
jne skip_else
cmp word [esi+1],if_directive-assembler
cmp word [esi+1],if_directive-instruction_handler
jne skip_else
add esi,4
call find_else
@ -1161,9 +1168,9 @@ if_directive:
jmp instruction_assembled
find_else:
call find_structure_end
cmp ax,else_directive-assembler
cmp ax,else_directive-instruction_handler
je else_found
cmp ax,if_directive-assembler
cmp ax,if_directive-instruction_handler
jne unexpected_instruction
stc
ret
@ -1172,7 +1179,7 @@ if_directive:
ret
find_end_if:
call find_structure_end
cmp ax,if_directive-assembler
cmp ax,if_directive-instruction_handler
jne unexpected_instruction
ret
find_structure_end:
@ -1195,28 +1202,28 @@ if_directive:
cmp byte [esi],1
jne find_end_directive
mov ax,[esi+1]
cmp ax,prefix_instruction-assembler
cmp ax,prefix_instruction-instruction_handler
je find_end_directive
add esi,4
cmp ax,repeat_directive-assembler
cmp ax,repeat_directive-instruction_handler
je skip_repeat
cmp ax,while_directive-assembler
cmp ax,while_directive-instruction_handler
je skip_while
cmp ax,if_directive-assembler
cmp ax,if_directive-instruction_handler
je skip_if
cmp ax,else_directive-assembler
cmp ax,else_directive-instruction_handler
je structure_end
cmp ax,end_directive-assembler
cmp ax,end_directive-instruction_handler
jne find_end_directive
cmp byte [esi],1
jne find_end_directive
mov ax,[esi+1]
add esi,4
cmp ax,repeat_directive-assembler
cmp ax,repeat_directive-instruction_handler
je structure_end
cmp ax,while_directive-assembler
cmp ax,while_directive-instruction_handler
je structure_end
cmp ax,if_directive-assembler
cmp ax,if_directive-instruction_handler
jne find_end_directive
structure_end:
pop [error_line]
@ -1239,7 +1246,7 @@ if_directive:
jc if_block_skipped
cmp byte [esi],1
jne skip_after_else
cmp word [esi+1],if_directive-assembler
cmp word [esi+1],if_directive-instruction_handler
jne skip_after_else
add esi,4
jmp skip_if_block
@ -1253,15 +1260,15 @@ end_directive:
jne invalid_argument
lods word [esi]
inc esi
cmp ax,virtual_directive-assembler
cmp ax,virtual_directive-instruction_handler
je end_virtual
cmp ax,repeat_directive-assembler
cmp ax,repeat_directive-instruction_handler
je end_repeat
cmp ax,while_directive-assembler
cmp ax,while_directive-instruction_handler
je end_while
cmp ax,if_directive-assembler
cmp ax,if_directive-instruction_handler
je end_if
cmp ax,data_directive-assembler
cmp ax,data_directive-instruction_handler
je end_data
jmp invalid_argument
break_directive:
@ -1275,11 +1282,11 @@ break_directive:
cmp ebx,[additional_memory_end]
je unexpected_instruction
mov ax,[ebx]
cmp ax,repeat_directive-assembler
cmp ax,repeat_directive-instruction_handler
je break_repeat
cmp ax,while_directive-assembler
cmp ax,while_directive-instruction_handler
je break_while
cmp ax,if_directive-assembler
cmp ax,if_directive-instruction_handler
je break_if
add ebx,20h
jmp find_breakable_structure
@ -1688,6 +1695,7 @@ data_file:
pop ebx
mov edx,eax
sub [esp],edx
jc value_out_of_range
position_ok:
cmp byte [esi],','
jne size_ok
@ -1700,6 +1708,8 @@ data_file:
push ebx edx
call get_dword_value
pop edx ebx
cmp eax,[esp]
ja value_out_of_range
mov [esp],eax
size_ok:
xor al,al

View File

@ -76,8 +76,18 @@ convert_expression:
convert_number:
lea eax,[edi-10h]
cmp eax,[labels_list]
mov edx,[memory_end]
cmp [source_start],0
je check_memory_for_number
mov edx,[labels_list]
check_memory_for_number:
cmp eax,edx
jae out_of_memory
mov eax,esp
sub eax,100h
jc stack_overflow
cmp eax,[stack_limit]
jb stack_overflow
cmp byte [esi],'('
je expression_value
inc edi
@ -111,11 +121,6 @@ convert_number:
scas word [edi]
ret
expression_value:
mov eax,esp
sub eax,100h
jc stack_overflow
cmp eax,[stack_limit]
jb stack_overflow
inc esi
push [current_offset]
call convert_expression
@ -125,6 +130,8 @@ convert_number:
jne invalid_expression
ret
symbol_value:
cmp [source_start],0
je preprocessor_value
push edi
mov edi,address_registers
call get_operator
@ -153,6 +160,23 @@ convert_number:
mov byte [edi-1],10h
stos byte [edi]
ret
preprocessor_value:
dec edi
lods byte [esi]
cmp al,1Ah
jne invalid_value
lods byte [esi]
mov cl,al
mov ch,10b
call get_preprocessor_symbol
jc invalid_value
push esi
mov esi,[edx+8]
push [current_offset]
call convert_expression
pop [current_offset]
pop esi
ret
get_number:
xor ebp,ebp
@ -1043,7 +1067,12 @@ calculate_expression:
jmp calculation_loop
timestamp_label:
call make_timestamp
jmp make_dword_label_value
make_qword_label_value:
stos dword [edi]
mov eax,edx
stos dword [edi]
add edi,0Ch
jmp calculation_loop
predefined_label:
or eax,eax
jz current_offset_label

View File

@ -133,7 +133,7 @@ formatter:
mov [edi],ecx
or dword [edi+4],-1
sub edi,ecx
cmp edi,[esp]
cmp edi,[current_offset]
jbe out_of_memory
mov [display_buffer],edi
mov esi,[memory_end]
@ -1301,7 +1301,7 @@ data_directive:
or ecx,ecx
jnz data_already_defined
call allocate_structure_data
mov word [ebx],data_directive-assembler
mov word [ebx],data_directive-instruction_handler
mov [ebx+2],al
mov edx,[current_line]
mov [ebx+4],edx
@ -3591,6 +3591,18 @@ elf_formatter:
format_elf_exe:
add esi,2
or [format_flags],1
cmp byte [esi],'('
jne elf_exe_brand_ok
inc esi
cmp byte [esi],'.'
je invalid_value
push edx
call get_byte_value
cmp [value_type],0
jne invalid_use_of_symbol
pop edx
mov [edx+7],al
elf_exe_brand_ok:
mov [image_base],8048000h
cmp byte [esi],80h
jne elf_exe_base_ok
@ -3643,6 +3655,18 @@ format_elf_exe:
format_elf64_exe:
add esi,2
or [format_flags],1
cmp byte [esi],'('
jne elf64_exe_brand_ok
inc esi
cmp byte [esi],'.'
je invalid_value
push edx
call get_byte_value
cmp [value_type],0
jne invalid_use_of_symbol
pop edx
mov [edx+7],al
elf64_exe_brand_ok:
mov [image_base],400000h
mov [image_base_high],0
cmp byte [esi],80h
@ -3748,6 +3772,8 @@ elf_segment:
mov byte [ebx],1
mov word [ebx+1Ch],1000h
elf_segment_flags:
cmp byte [esi],1Eh
je elf_segment_type
cmp byte [esi],19h
jne elf_segment_flags_ok
lods word [esi]
@ -3766,6 +3792,25 @@ elf_segment:
jnz setting_already_specified
or [ebx+18h],ah
jmp elf_segment_flags
elf_segment_type:
cmp byte [ebx],1
jne setting_already_specified
lods word [esi]
mov ecx,[number_of_sections]
jecxz elf_segment_type_ok
mov edx,[code_start]
add edx,34h
scan_elf_segment_types:
cmp edx,[symbols_stream]
jae elf_segment_type_ok
cmp [edx],ah
je data_already_defined
add edx,20h
loop scan_elf_segment_types
elf_segment_type_ok:
mov [ebx],ah
mov word [ebx+1Ch],1
jmp elf_segment_flags
elf_segment_flags_ok:
mov eax,edi
sub eax,[code_start]
@ -3824,8 +3869,11 @@ elf_segment:
sub eax,edx
mov [ebx+10h],eax
mov eax,[ebx+8]
cmp byte [ebx],1
jne elf_segment_position_ok
add eax,[ebx+14h]
add eax,0FFFh
elf_segment_position_ok:
and eax,not 0FFFh
ret
elf64_segment:
@ -3850,6 +3898,8 @@ elf_segment:
mov byte [ebx],1
mov word [ebx+30h],1000h
elf64_segment_flags:
cmp byte [esi],1Eh
je elf64_segment_type
cmp byte [esi],19h
jne elf64_segment_flags_ok
lods word [esi]
@ -3868,6 +3918,25 @@ elf_segment:
jnz setting_already_specified
or [ebx+4],ah
jmp elf64_segment_flags
elf64_segment_type:
cmp byte [ebx],1
jne setting_already_specified
lods word [esi]
mov ecx,[number_of_sections]
jecxz elf64_segment_type_ok
mov edx,[code_start]
add edx,40h
scan_elf64_segment_types:
cmp edx,[symbols_stream]
jae elf64_segment_type_ok
cmp [edx],ah
je data_already_defined
add edx,38h
loop scan_elf64_segment_types
elf64_segment_type_ok:
mov [ebx],ah
mov word [ebx+30h],1
jmp elf64_segment_flags
elf64_segment_flags_ok:
mov ecx,edi
sub ecx,[code_start]
@ -3929,17 +3998,16 @@ elf_segment:
mov [ebx+20h],eax
mov eax,[ebx+10h]
mov edx,[ebx+10h+4]
cmp byte [ebx],1
jne elf64_segment_position_ok
add eax,[ebx+28h]
adc edx,0
sub eax,1
sbb edx,0
shrd eax,edx,12
shr edx,12
add eax,1
add eax,0FFFh
adc edx,0
shld edx,eax,12
shl eax,12
elf64_segment_position_ok:
and eax,not 0FFFh
ret
close_elf_exe:
test [format_flags],8
jnz close_elf64_exe
@ -4149,8 +4217,26 @@ dump_symbols:
sub [esi+12],eax
prepare_next_preprocessed_line:
add esi,16
call skip_foreign_line
skip_preprocessed_line:
lods byte [esi]
cmp al,1Ah
je skip_preprocessed_symbol
cmp al,3Bh
je skip_preprocessed_symbol
cmp al,22h
je skip_preprocessed_string
or al,al
jnz skip_preprocessed_line
jmp prepare_preprocessed_source
skip_preprocessed_string:
lods dword [esi]
add esi,eax
jmp skip_preprocessed_line
skip_preprocessed_symbol:
lods byte [esi]
movzx eax,al
add esi,eax
jmp skip_preprocessed_line
preprocessed_source_ok:
mov esi,[labels_list]
mov ebp,edi

View File

@ -104,15 +104,15 @@ parser:
stos word [edi]
mov al,dl
stos byte [edi]
cmp bx,if_directive-assembler
cmp bx,if_directive-instruction_handler
je parse_block
cmp bx,repeat_directive-assembler
cmp bx,repeat_directive-instruction_handler
je parse_block
cmp bx,while_directive-assembler
cmp bx,while_directive-instruction_handler
je parse_block
cmp bx,end_directive-assembler
cmp bx,end_directive-instruction_handler
je parse_end_directive
cmp bx,else_directive-assembler
cmp bx,else_directive-instruction_handler
je parse_else
common_parse:
call parse_line_contents
@ -159,9 +159,9 @@ parser:
shl eax,16
push eax
inc [blocks_stack]
cmp bx,if_directive-assembler
cmp bx,if_directive-instruction_handler
je parse_if
cmp bx,while_directive-assembler
cmp bx,while_directive-instruction_handler
je parse_while
call parse_line_contents
jmp parse_next_line
@ -188,11 +188,11 @@ parser:
lods byte [esi]
or al,al
jnz extra_characters_on_line
cmp bx,if_directive-assembler
cmp bx,if_directive-instruction_handler
je close_parsing_block
cmp bx,repeat_directive-assembler
cmp bx,repeat_directive-instruction_handler
je close_parsing_block
cmp bx,while_directive-assembler
cmp bx,while_directive-instruction_handler
je close_parsing_block
jmp parse_next_line
close_parsing_block:
@ -202,7 +202,7 @@ parser:
jne unexpected_instruction
dec [blocks_stack]
pop eax edx
cmp bx,if_directive-assembler
cmp bx,if_directive-instruction_handler
jne parse_next_line
test al,1100b
jz parse_next_line
@ -251,7 +251,7 @@ parser:
parse_else:
cmp [blocks_stack],0
je unexpected_instruction
cmp word [esp+2],if_directive-assembler
cmp word [esp+2],if_directive-instruction_handler
jne unexpected_instruction
lods byte [esi]
or al,al
@ -264,7 +264,7 @@ parser:
call get_instruction
jc extra_characters_on_line
pop edi
cmp bx,if_directive-assembler
cmp bx,if_directive-instruction_handler
jne extra_characters_on_line
test byte [esp],100b
jnz skip_true_condition_else
@ -311,15 +311,15 @@ parser:
lea esi,[esi+ecx+1]
jmp skip_parsing_line
skip_parsing_instruction:
cmp bx,if_directive-assembler
cmp bx,if_directive-instruction_handler
je skip_parsing_block
cmp bx,repeat_directive-assembler
cmp bx,repeat_directive-instruction_handler
je skip_parsing_block
cmp bx,while_directive-assembler
cmp bx,while_directive-instruction_handler
je skip_parsing_block
cmp bx,end_directive-assembler
cmp bx,end_directive-instruction_handler
je skip_parsing_end_directive
cmp bx,else_directive-assembler
cmp bx,else_directive-instruction_handler
je skip_parsing_else
skip_parsing_contents:
lods byte [esi]
@ -369,11 +369,11 @@ parser:
lods byte [esi]
or al,al
jnz extra_characters_on_line
cmp bx,if_directive-assembler
cmp bx,if_directive-instruction_handler
je close_skip_parsing_block
cmp bx,repeat_directive-assembler
cmp bx,repeat_directive-instruction_handler
je close_skip_parsing_block
cmp bx,while_directive-assembler
cmp bx,while_directive-instruction_handler
je close_skip_parsing_block
jmp skip_parsing
close_skip_parsing_block:
@ -385,7 +385,7 @@ parser:
pop eax edx
test al,1
jz skip_parsing
cmp bx,if_directive-assembler
cmp bx,if_directive-instruction_handler
jne parse_next_line
test al,10000b
jz parse_next_line
@ -394,15 +394,15 @@ parser:
mov eax,[current_line]
stos dword [edi]
inc [parsed_lines]
mov eax,1 + (end_directive-assembler) shl 8
mov eax,1 + (end_directive-instruction_handler) shl 8
stos dword [edi]
mov eax,1 + (if_directive-assembler) shl 8
mov eax,1 + (if_directive-instruction_handler) shl 8
stos dword [edi]
jmp parse_next_line
skip_parsing_else:
cmp [blocks_stack],0
je unexpected_instruction
cmp word [esp+2],if_directive-assembler
cmp word [esp+2],if_directive-instruction_handler
jne unexpected_instruction
lods byte [esi]
or al,al
@ -415,7 +415,7 @@ parser:
call get_instruction
jc extra_characters_on_line
pop edi
cmp bx,if_directive-assembler
cmp bx,if_directive-instruction_handler
jne extra_characters_on_line
mov al,[esp]
test al,1
@ -432,7 +432,7 @@ parser:
stos dword [edi]
inc [parsed_lines]
parse_else_if:
mov eax,1 + (if_directive-assembler) shl 8
mov eax,1 + (if_directive-instruction_handler) shl 8
stos dword [edi]
jmp parse_if
skip_parsing_pure_else:
@ -451,21 +451,21 @@ parser:
parse_line_contents:
mov [parenthesis_stack],0
parse_instruction_arguments:
cmp bx,prefix_instruction-assembler
cmp bx,prefix_instruction-instruction_handler
je allow_embedded_instruction
cmp bx,times_directive-assembler
cmp bx,times_directive-instruction_handler
je parse_times_directive
cmp bx,end_directive-assembler
cmp bx,end_directive-instruction_handler
je allow_embedded_instruction
cmp bx,label_directive-assembler
cmp bx,label_directive-instruction_handler
je parse_label_directive
cmp bx,segment_directive-assembler
cmp bx,segment_directive-instruction_handler
je parse_label_directive
cmp bx,load_directive-assembler
cmp bx,load_directive-instruction_handler
je parse_load_directive
cmp bx,extrn_directive-assembler
cmp bx,extrn_directive-instruction_handler
je parse_extrn_directive
cmp bx,public_directive-assembler
cmp bx,public_directive-instruction_handler
je parse_public_directive
parse_argument:
lea eax,[edi+100h]

View File

@ -37,6 +37,7 @@ preprocessor:
mov eax,[additional_memory_end]
mov [labels_list],eax
xor eax,eax
mov [source_start],eax
mov [display_buffer],eax
mov [hash_tree],eax
mov [macro_status],al
@ -375,12 +376,14 @@ get_directive:
ret
directive_ok:
lea esi,[edx+ebp]
call directive_handler
directive_handler:
pop ecx
movzx eax,word [ebx]
add eax,preprocessor
add eax,ecx
clc
ret
preprocess_line:
mov eax,esp
sub eax,100h
@ -756,24 +759,20 @@ add_preprocessor_symbol:
define_fix_constant:
add edx,5
add esi,2
push edx esi
mov esi,edx
call skip_parameters
xchg esi,[esp]
push edx
mov ch,11b
jmp define_preprocessor_constant
define_equ_constant:
add esi,3
push esi
call process_equ_constants
push esi
mov esi,[struc_name]
mov ch,10b
define_preprocessor_constant:
mov byte [esi-2],3Bh
mov cl,[esi-1]
call add_preprocessor_symbol
pop esi ebx
pop ebx
mov ecx,edi
dec ecx
sub ecx,ebx
@ -790,34 +789,11 @@ define_symbolic_constant:
call add_preprocessor_symbol
movzx eax,byte [esi-1]
add esi,eax
push esi edx
call skip_parameters
pop edx ebx
lea ecx,[esi-1]
sub ecx,ebx
mov [edx+8],ebx
lea ecx,[edi-1]
sub ecx,esi
mov [edx+8],esi
mov [edx+12],ecx
jmp line_preprocessed
skip_parameters:
lods byte [esi]
or al,al
jz parameters_skipped
cmp al,'{'
je parameters_skipped
cmp al,22h
je skip_quoted_parameter
cmp al,1Ah
jne skip_parameters
lods byte [esi]
movzx eax,al
add esi,eax
jmp skip_parameters
skip_quoted_parameter:
lods dword [esi]
add esi,eax
jmp skip_parameters
parameters_skipped:
ret
define_struc:
mov ch,1
@ -959,8 +935,25 @@ define_instant_macro:
mov [instant_macro_start],esi
cmp [base_code],10h
je prepare_match
call skip_parameters
instant_macro_parameters_skipped:
skip_parameters:
lods byte [esi]
or al,al
jz parameters_skipped
cmp al,'{'
je parameters_skipped
cmp al,22h
je skip_quoted_parameter
cmp al,1Ah
jne skip_parameters
lods byte [esi]
movzx eax,al
add esi,eax
jmp skip_parameters
skip_quoted_parameter:
lods dword [esi]
add esi,eax
jmp skip_parameters
parameters_skipped:
dec esi
mov [parameters_end],esi
lods byte [esi]
@ -973,7 +966,7 @@ prepare_match:
call skip_pattern
mov [value_type],80h+10b
call process_symbolic_constants
jmp instant_macro_parameters_skipped
jmp parameters_skipped
skip_pattern:
lods byte [esi]
or al,al
@ -1522,15 +1515,9 @@ use_instant_macro:
jae do_match
cmp [base_code],0
jne do_irp
call get_number
jc invalid_value
or ebp,ebp
jnz invalid_value
cmp dword [edi+4],0
jne value_out_of_range
mov eax,[edi]
cmp eax,80000000h
jae value_out_of_range
call precalculate_value
cmp eax,0
jl value_out_of_range
push [free_additional_memory]
push [macro_symbols]
mov [macro_symbols],0
@ -1558,16 +1545,10 @@ use_instant_macro:
cmp al,':'
jne rept_counter_added
push edx
call get_number
jc invalid_value
or ebp,ebp
jnz invalid_value
cmp dword [edi+4],0
jne value_out_of_range
mov eax,[edi]
call precalculate_value
mov edx,eax
add edx,[counter_limit]
jc value_out_of_range
jo value_out_of_range
pop edx
mov dword [edx+8],eax
lods byte [esi]
@ -1606,6 +1587,21 @@ use_instant_macro:
mov ecx,edx
call move_data
jmp initial_preprocessing_ok
precalculate_value:
push edi
call convert_expression
mov al,')'
stosb
push esi
mov esi,[esp+4]
call calculate_expression
mov eax,[edi]
mov ecx,[edi+4]
pop esi edi
cdq
cmp edx,ecx
jne value_out_of_range
ret
do_irp:
cmp byte [esi],1Ah
jne invalid_macro_arguments
@ -1977,10 +1973,10 @@ process_macro:
replace_macro_symbol:
pop edi eax
mov ecx,[edx+8]
and ecx,not 80000000h
mov edx,[edx+12]
or edx,edx
jz replace_macro_counter
and ecx,not 80000000h
xchg esi,edx
call move_data
mov esi,edx
@ -2057,6 +2053,12 @@ process_macro:
inc edi
jmp multiple_macro_counter_values
store_number_symbol:
cmp ecx,0
jge numer_symbol_sign_ok
neg ecx
mov al,'-'
stos byte [edi]
numer_symbol_sign_ok:
mov ax,1Ah
stos word [edi]
push edi

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,7 @@
; cannot simply be copied and put under another distribution licence
; (including the GNU Public Licence).
VERSION_STRING equ "1.68"
VERSION_STRING equ "1.69.06"
VERSION_MAJOR = 1
VERSION_MINOR = 68

View File

@ -44,8 +44,8 @@ simple_instruction_64bit:
simple_extended_instruction_64bit:
cmp [code_type],64
jne illegal_instruction
mov al,48h
stos byte [edi]
mov byte [edi],48h
inc edi
simple_extended_instruction:
mov ah,al
mov al,0Fh
@ -472,8 +472,8 @@ mov_instruction:
mov [base_code],0A2h
store_mov_address32:
call store_instruction_code
push instruction_assembled
jmp store_address_32bit_value
call store_address_32bit_value
jmp instruction_assembled
mov_mem_address16_al:
call store_segment_prefix_if_necessary
call address_16bit_prefix
@ -492,8 +492,8 @@ mov_instruction:
mov [base_code],0A2h
store_mov_address64:
call store_instruction_code
push instruction_assembled
jmp store_address_64bit_value
call store_address_64bit_value
jmp instruction_assembled
mov_mem_ax:
test ch,22h
jnz mov_mem_address16_ax
@ -3284,6 +3284,7 @@ loop_instruction:
cmp [code_type],64
jne invalid_operand_size
call get_address_qword_value
call loop_counter_size
call calculate_jump_offset
mov ecx,edx
cdq
@ -4893,6 +4894,7 @@ sse_instruction:
cmp [immediate_size],-1
jne sse_ok
call take_additional_xmm0
mov [immediate_size],0
sse_ok:
jmp instruction_ready
sse_xmmreg_xmmreg:
@ -4913,12 +4915,13 @@ sse_instruction:
cmp [immediate_size],-1
jne sse_nomem_ok
call take_additional_xmm0
mov [immediate_size],0
sse_nomem_ok:
jmp nomem_instruction_ready
take_additional_xmm0:
lods byte [esi]
cmp al,','
jne invalid_operand
cmp byte [esi],','
jne additional_xmm0_ok
inc esi
lods byte [esi]
cmp al,10h
jne invalid_operand
@ -4928,6 +4931,7 @@ sse_instruction:
jne invalid_operand_size
test al,al
jnz invalid_operand
additional_xmm0_ok:
ret
ps_dq_instruction:
@ -5483,12 +5487,11 @@ extractps_instruction:
mov [postbyte_register],al
pop ebx
mov al,bh
cmp al,8
je extractps_store
cmp al,4
je mmx_nomem_imm8
cmp al,8
jne invalid_operand_size
extractps_store:
call operand_autodetect
call operand_64bit
jmp mmx_nomem_imm8
insertps_instruction:
mov [opcode_prefix],66h
@ -5874,6 +5877,10 @@ movnti_instruction:
jmp instruction_ready
monitor_instruction:
mov [postbyte_register],al
cmp byte [esi],0
je monitor_instruction_store
cmp byte [esi],0Fh
je monitor_instruction_store
lods byte [esi]
call get_size_operator
cmp al,10h
@ -6074,6 +6081,7 @@ crc32_instruction:
cmp al,','
jne invalid_operand
mov [operand_size],0
call operand_64bit
lods byte [esi]
call get_size_operator
cmp al,10h
@ -6105,6 +6113,57 @@ crc32_instruction:
popcnt_instruction:
mov [opcode_prefix],0F3h
jmp bs_instruction
movbe_instruction:
mov [supplemental_code],al
mov [extended_code],38h
mov [base_code],0Fh
lods byte [esi]
call get_size_operator
cmp al,'['
je movbe_mem
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,10h
; je movbe_reg_reg
cmp al,'['
jne invalid_argument
call get_address
mov al,[operand_size]
call operand_autodetect
jmp instruction_ready
; movbe_reg_reg:
; lods byte [esi]
; call convert_register
; mov bl,al
; mov al,ah
; call operand_autodetect
; jmp nomem_instruction_ready
movbe_mem:
inc [supplemental_code]
call get_address
push edx ebx ecx
lods byte [esi]
cmp al,','
jne invalid_operand
lods byte [esi]
call get_size_operator
cmp al,10h
jne invalid_operand
lods byte [esi]
call convert_register
mov [postbyte_register],al
pop ecx ebx edx
mov al,[operand_size]
call operand_autodetect
jmp instruction_ready
simple_vmx_instruction:
mov ah,al
@ -6705,15 +6764,6 @@ store_instruction:
cmp [code_type],64
jne invalid_address_size
address_prefix_ok:
test bh,1000b
jz base_code_ok
or [rex_prefix],41h
base_code_ok:
test bl,1000b
jz index_code_ok
or [rex_prefix],42h
index_code_ok:
call store_instruction_code
cmp bl,44h
je swap_base_with_index
cmp bl,84h
@ -6727,6 +6777,15 @@ store_instruction:
cmp bl,84h
je invalid_address
base_register_ok:
test bh,1000b
jz base_code_ok
or [rex_prefix],41h
base_code_ok:
test bl,1000b
jz index_code_ok
or [rex_prefix],42h
index_code_ok:
call store_instruction_code
or cl,cl
jz only_base_register
base_and_index: