Codebase list fasm / ec6ff8d
Merge tag 'upstream/1.71.39' Upstream version 1.71.39 Tomasz Buchert 8 years ago
26 changed file(s) with 748 addition(s) and 311 deletion(s). Raw diff Collapse all Expand all
Binary diff not shown
413413 priority value will be calculated first, you can of course change this
414414 behavior by putting some parts of expression into parenthesis. The "+", "-",
415415 "*" and "/" are standard arithmetical operations, "mod" calculates the
416 remainder from division. The "and", "or", "xor", "shl", "shr" and "not"
417 perform the same logical operations as assembly instructions of those names.
418 The "rva" and "plt" are special unary operators that perform conversions
419 between different kinds of addresses, they can be used only with few of the
420 output formats and their meaning may vary (see 2.4).
421 The arithmetical and logical calculations are usually processed as if they
416 remainder from division. The "and", "or", "xor", "shl", "shr", "bsf", "bsr"
417 and "not" perform the same bit-logical operations as assembly instructions of
418 those names. The "rva" and "plt" are special unary operators that perform
419 conversions between different kinds of addresses, they can be used only with
420 few of the output formats and their meaning may vary (see 2.4).
421 The arithmetical and bit-logical calculations are processed as if they
422422 operated on infinite precision 2-adic numbers, and assembler signalizes an
423423 overflow error if because of its limitations it is not table to perform the
424424 required calculation, or if the result is too large number to fit in either
425 signed or unsigned range for the destination unit size. However "not", "xor"
426 and "shr" operators are exceptions from this rule - if the value specified
427 by numerical expression has to fit in a unit of specified size, and the
428 arguments for operation fit into that size, the operation will be performed
429 with precision limited to that size.
425 signed or unsigned range for the destination unit size.
430426 The numbers in the expression are by default treated as a decimal, binary
431427 numbers should have the "b" letter attached at the end, octal number should
432428 end with "o" letter, hexadecimal numbers should begin with "0x" characters
453449 characters. So "1.0", "1E0" and "1f" define the same floating point value,
454450 while simple "1" defines an integer value.
455451
456 Table 1.4 Arithmetical and logical operators by priority
452 Table 1.4 Arithmetical and bit-logical operators by priority
457453 /-------------------------\
458454 | Priority | Operators |
459455 |==========|==============|
469465 |----------|--------------|
470466 | 5 | not |
471467 |----------|--------------|
472 | 6 | rva plt |
468 | 6 | bsf bsr |
469 |----------|--------------|
470 | 7 | rva plt |
473471 \-------------------------/
474472
475473
39443942 some commas, such argument should be enclosed between "<" and ">" characters.
39453943 If it contains more than one "<" character, the same number of ">" should be
39463944 used to tell that the value of argument ends.
3945 When the name of the last argument of macroinstruction is followed by "&"
3946 character, this argument consumes everything up to the end of line, including
3947 commas.
39473948 "purge" directive allows removing the last definition of specified
39483949 macroinstruction. It should be followed by one or more names of
39493950 macroinstructions, separated with commas. If such macroinstruction has not
46414642 followed by the minimum version of system that the executable is targeted to
46424643 (specified in form of floating-point value). Optional "DLL" and "WDM" keywords
46434644 mark the output file as a dynamic link library and WDM driver respectively,
4644 and the "large" keyword marks the executable as able to handle addresses
4645 larger than 2 GB.
4645 the "large" keyword marks the executable as able to handle addresses larger
4646 than 2 GB and the "NX" keyword signalizes that the executable conforms to the
4647 restriction of not executing code residing in non-executable sections.
46464648 After those settings can follow the "at" operator and a numerical expression
46474649 specifying the base of PE image and then optionally "on" operator followed by
46484650 the quoted string containing file name selects custom MZ stub for PE program
00
11 ; flat assembler interface for DOS
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 format MZ
113113 mov [symbols_file],0
114114 mov [memory_setting],0
115115 mov [passes_limit],100
116 mov [definitions_pointer],predefinitions
116117 push ds
117118 mov ds,[psp_segment]
118119 mov esi,81h
168169 je passes_option
169170 cmp al,'P'
170171 je passes_option
172 cmp al,'d'
173 je definition_option
174 cmp al,'D'
175 je definition_option
171176 cmp al,'s'
172177 je symbols_option
173178 cmp al,'S'
237242 ja invalid_option
238243 mov [es:passes_limit],dx
239244 jmp find_param
245 definition_option:
246 lodsb
247 cmp al,20h
248 je definition_option
249 cmp al,0Dh
250 je bad_params
251 or al,al
252 jz bad_params
253 dec esi
254 push edi
255 mov edi,[es:definitions_pointer]
256 call convert_definition_option
257 mov [es:definitions_pointer],edi
258 pop edi
259 jc invalid_option
260 jmp find_param
240261 symbols_option:
241262 mov [es:symbols_file],edi
242263 find_symbols_file_name:
256277 pop ds
257278 cmp [input_file],0
258279 je no_input_file
280 mov eax,[definitions_pointer]
281 mov byte [eax],0
282 mov [initial_definitions],predefinitions
259283 clc
260284 ret
261285 bad_params:
263287 no_input_file:
264288 stc
265289 ret
290 convert_definition_option:
291 mov ecx,edi
292 xor al,al
293 stosb
294 copy_definition_name:
295 lodsb
296 cmp al,'='
297 je copy_definition_value
298 cmp al,20h
299 je bad_definition_option
300 cmp al,0Dh
301 je bad_definition_option
302 or al,al
303 jz bad_definition_option
304 stosb
305 inc byte [es:ecx]
306 jnz copy_definition_name
307 bad_definition_option:
308 stc
309 ret
310 copy_definition_value:
311 lodsb
312 cmp al,20h
313 je definition_value_end
314 cmp al,0Dh
315 je definition_value_end
316 or al,al
317 jz definition_value_end
318 cmp al,'\'
319 jne definition_value_character
320 cmp byte [esi],20h
321 jne definition_value_character
322 lodsb
323 definition_value_character:
324 stosb
325 jmp copy_definition_value
326 definition_value_end:
327 dec esi
328 xor al,al
329 stosb
330 clc
331 ret
266332
267333 include '..\version.inc'
268334
269335 _logo db 'flat assembler version ',VERSION_STRING,24h
270 _copyright db 'Copyright (c) 1999-2014, Tomasz Grysztar',0Dh,0Ah,0
336 _copyright db 'Copyright (c) 1999-2015, Tomasz Grysztar',0Dh,0Ah,0
271337
272338 _usage db 0Dh,0Ah
273339 db 'usage: fasm <source> [output]',0Dh,0Ah
274340 db 'optional settings:',0Dh,0Ah
275 db ' -m <limit> set the limit in kilobytes for the available memory',0Dh,0Ah
276 db ' -p <limit> set the maximum allowed number of passes',0Dh,0Ah
277 db ' -s <file> dump symbolic information for debugging',0Dh,0Ah
341 db ' -m <limit> set the limit in kilobytes for the available memory',0Dh,0Ah
342 db ' -p <limit> set the maximum allowed number of passes',0Dh,0Ah
343 db ' -d <name>=<value> define symbolic variable',0Dh,0Ah
344 db ' -s <file> dump symbolic information for debugging',0Dh,0Ah
278345 db 0
279346 _memory_prefix db ' (',0
280347 _memory_suffix db ' kilobytes memory)',0Dh,0Ah,0
345412
346413 memory_setting dd ?
347414 start_time dd ?
415 definitions_pointer dd ?
348416 params rb 100h
417 predefinitions rb 100h
349418
350419 mode dw ?
351420 real_mode_segment dw ?
00
11 ; flat assembler interface for DOS
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 segment modes use16
00
11 ; flat assembler interface for DOS
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 go32:
438438 jmp exit_program
439439 assembler_error:
440440 call display_user_messages
441 mov ebx,[current_line]
442 test ebx,ebx
443 jz display_error_message
441444 push dword 0
442 mov ebx,[current_line]
443445 get_error_lines:
444446 mov eax,[ebx]
445447 cmp byte [eax],0
543545 pop ebx
544546 or ebx,ebx
545547 jnz display_error_line
548 display_error_message:
546549 mov esi,error_prefix
547550 call display_string
548551 pop esi
00
11 ; flat assembler interface for Linux
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 format ELF executable 3
114114 add ebx,8
115115 dec ecx
116116 jz bad_params
117 mov [definitions_pointer],predefinitions
117118 get_param:
118119 mov esi,[ebx]
119120 mov al,[esi]
139140 je passes_option
140141 cmp al,'P'
141142 je passes_option
143 cmp al,'d'
144 je definition_option
145 cmp al,'D'
146 je definition_option
142147 cmp al,'s'
143148 je symbols_option
144149 cmp al,'S'
181186 jnz get_param
182187 cmp [input_file],0
183188 je bad_params
189 mov eax,[definitions_pointer]
190 mov byte [eax],0
191 mov [initial_definitions],predefinitions
184192 clc
185193 ret
194 definition_option:
195 cmp byte [esi],0
196 jne get_definition
197 dec ecx
198 jz bad_params
199 add ebx,4
200 mov esi,[ebx]
201 get_definition:
202 push edi
203 mov edi,[definitions_pointer]
204 call convert_definition_option
205 mov [definitions_pointer],edi
206 pop edi
207 jc bad_params
208 jmp next_param
186209 symbols_option:
187210 cmp byte [esi],0
188211 jne get_symbols_setting
218241 invalid_option_value:
219242 stc
220243 ret
244 convert_definition_option:
245 mov edx,edi
246 xor al,al
247 stosb
248 copy_definition_name:
249 lodsb
250 cmp al,'='
251 je copy_definition_value
252 cmp al,20h
253 je bad_definition_option
254 or al,al
255 jz bad_definition_option
256 stosb
257 inc byte [edx]
258 jnz copy_definition_name
259 bad_definition_option:
260 stc
261 ret
262 copy_definition_value:
263 lodsb
264 cmp al,20h
265 je definition_value_end
266 or al,al
267 jz definition_value_end
268 stosb
269 jmp copy_definition_value
270 definition_value_end:
271 dec esi
272 xor al,al
273 stosb
274 clc
275 ret
221276
222277 include 'system.inc'
223278
224279 include '..\version.inc'
225280
226 _copyright db 'Copyright (c) 1999-2014, Tomasz Grysztar',0xA,0
281 _copyright db 'Copyright (c) 1999-2015, Tomasz Grysztar',0xA,0
227282
228283 _logo db 'flat assembler version ',VERSION_STRING,0
229284 _usage db 0xA
230285 db 'usage: fasm <source> [output]',0xA
231286 db 'optional settings:',0xA
232 db ' -m <limit> set the limit in kilobytes for the available memory',0Dh,0Ah
233 db ' -p <limit> set the maximum allowed number of passes',0Dh,0Ah
234 db ' -s <file> dump symbolic information for debugging',0Dh,0Ah
287 db ' -m <limit> set the limit in kilobytes for the available memory',0Dh,0Ah
288 db ' -p <limit> set the maximum allowed number of passes',0Dh,0Ah
289 db ' -d <name>=<value> define symbolic variable',0Dh,0Ah
290 db ' -s <file> dump symbolic information for debugging',0Dh,0Ah
235291 db 0
236292 _memory_prefix db ' (',0
237293 _memory_suffix db ' kilobytes memory)',0xA,0
261317
262318 command_line dd ?
263319 memory_setting dd ?
320 definitions_pointer dd ?
264321 environment dd ?
265322 timestamp dq ?
266323 start_time dd ?
269326 last_displayed db ?
270327 character db ?
271328
329 predefinitions rb 1000h
272330 buffer rb 1000h
00
11 ; flat assembler interface for Linux
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 O_ACCMODE = 0003o
284284 assembler_error:
285285 mov [con_handle],2
286286 call display_user_messages
287 mov ebx,[current_line]
288 test ebx,ebx
289 jz display_error_message
287290 push dword 0
288 mov ebx,[current_line]
289291 get_error_lines:
290292 mov eax,[ebx]
291293 cmp byte [eax],0
377379 pop ebx
378380 or ebx,ebx
379381 jnz display_error_line
382 display_error_message:
380383 mov esi,error_prefix
381384 call display_string
382385 pop esi
00
11 ; flat assembler interface for Win32
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 format PE console
8181 mov [memory_setting],0
8282 mov [passes_limit],100
8383 call [GetCommandLine]
84 mov [definitions_pointer],predefinitions
8485 mov esi,eax
8586 mov edi,params
8687 find_command_start:
154155 je passes_option
155156 cmp al,'P'
156157 je passes_option
158 cmp al,'d'
159 je definition_option
160 cmp al,'D'
161 je definition_option
157162 cmp al,'s'
158163 je symbols_option
159164 cmp al,'S'
220225 ja bad_params
221226 mov [passes_limit],dx
222227 jmp find_param
228 definition_option:
229 lodsb
230 cmp al,20h
231 je definition_option
232 cmp al,0Dh
233 je bad_params
234 or al,al
235 jz bad_params
236 dec esi
237 push edi
238 mov edi,[definitions_pointer]
239 call convert_definition_option
240 mov [definitions_pointer],edi
241 pop edi
242 jc bad_params
243 jmp find_param
223244 symbols_option:
224245 mov [symbols_file],edi
225246 find_symbols_file_name:
236257 all_params:
237258 cmp [input_file],0
238259 je bad_params
260 mov eax,[definitions_pointer]
261 mov byte [eax],0
262 mov [initial_definitions],predefinitions
263 clc
264 ret
265 convert_definition_option:
266 mov ecx,edi
267 xor al,al
268 stosb
269 copy_definition_name:
270 lodsb
271 cmp al,'='
272 je copy_definition_value
273 cmp al,20h
274 je bad_definition_option
275 cmp al,0Dh
276 je bad_definition_option
277 or al,al
278 jz bad_definition_option
279 stosb
280 inc byte [ecx]
281 jnz copy_definition_name
282 bad_definition_option:
283 stc
284 ret
285 copy_definition_value:
286 lodsb
287 cmp al,20h
288 je definition_value_end
289 cmp al,0Dh
290 je definition_value_end
291 or al,al
292 jz definition_value_end
293 cmp al,'\'
294 jne definition_value_character
295 cmp byte [esi],20h
296 jne definition_value_character
297 lodsb
298 definition_value_character:
299 stosb
300 jmp copy_definition_value
301 definition_value_end:
302 dec esi
303 xor al,al
304 stosb
239305 clc
240306 ret
241307
259325
260326 include '..\version.inc'
261327
262 _copyright db 'Copyright (c) 1999-2014, Tomasz Grysztar',0Dh,0Ah,0
328 _copyright db 'Copyright (c) 1999-2015, Tomasz Grysztar',0Dh,0Ah,0
263329
264330 _logo db 'flat assembler version ',VERSION_STRING,0
265331 _usage db 0Dh,0Ah
266332 db 'usage: fasm <source> [output]',0Dh,0Ah
267333 db 'optional settings:',0Dh,0Ah
268 db ' -m <limit> set the limit in kilobytes for the available memory',0Dh,0Ah
269 db ' -p <limit> set the maximum allowed number of passes',0Dh,0Ah
270 db ' -s <file> dump symbolic information for debugging',0Dh,0Ah
334 db ' -m <limit> set the limit in kilobytes for the available memory',0Dh,0Ah
335 db ' -p <limit> set the maximum allowed number of passes',0Dh,0Ah
336 db ' -d <name>=<value> define symbolic variable',0Dh,0Ah
337 db ' -s <file> dump symbolic information for debugging',0Dh,0Ah
271338 db 0
272339 _memory_prefix db ' (',0
273340 _memory_suffix db ' kilobytes memory)',0Dh,0Ah,0
282349 con_handle dd ?
283350 memory_setting dd ?
284351 start_time dd ?
352 definitions_pointer dd ?
285353 bytes_count dd ?
286354 displayed_count dd ?
287355 character db ?
289357
290358 params rb 1000h
291359 options rb 1000h
360 predefinitions rb 1000h
292361 buffer rb 4000h
293362
294363 stack 10000h
00
11 ; flat assembler interface for Win32
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 CREATE_NEW = 1
314314 assembler_error:
315315 mov [con_handle],STD_ERROR_HANDLE
316316 call display_user_messages
317 mov ebx,[current_line]
318 test ebx,ebx
319 jz display_error_message
317320 push dword 0
318 mov ebx,[current_line]
319321 get_error_lines:
320322 mov eax,[ebx]
321323 cmp byte [eax],0
407409 pop ebx
408410 or ebx,ebx
409411 jnz display_error_line
412 display_error_message:
410413 mov esi,error_prefix
411414 call display_string
412415 pop esi
00
11 ; flat assembler core
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 assembler:
328328 cmp eax,0Fh
329329 jb invalid_use_of_symbol
330330 je reserved_word_used_as_symbol
331 mov edx,[eax+8]
332 push edx
333 cmp [current_pass],0
334 je get_constant_value
335 test dl,4
336 jnz get_constant_value
337 mov cx,[current_pass]
338 cmp cx,[eax+16]
339 je get_constant_value
340 or dl,4
341 mov [eax+8],dl
342 get_constant_value:
343 push eax
344 mov al,byte [esi-1]
345331 push eax
346332 or [size_override],-1
347333 call get_value
348334 pop ebx
349 mov ch,bl
350 pop ebx
351 pop ecx
352 test cl,4
353 jnz constant_referencing_mode_ok
354 and byte [ebx+8],not 4
355 constant_referencing_mode_ok:
356335 xor cl,cl
357336 mov ch,[value_type]
358337 cmp ch,3
452431 or byte [ebx+0Ah],2
453432 jmp continue_line
454433 assemble_instruction:
455 ; mov [operand_size],0
456 ; mov [size_override],0
457 ; mov [operand_prefix],0
458 ; mov [opcode_prefix],0
434 ; mov [operand_size],0
435 ; mov [size_override],0
436 ; mov [operand_prefix],0
437 ; mov [opcode_prefix],0
459438 and dword [operand_size],0
460 ; mov [rex_prefix],0
461 ; mov [vex_required],0
462 ; mov [vex_register],0
463 ; mov [immediate_size],0
439 ; mov [rex_prefix],0
440 ; mov [vex_required],0
441 ; mov [vex_register],0
442 ; mov [immediate_size],0
464443 and dword [rex_prefix],0
465444 call instruction_handler
466445 instruction_handler:
00
11 ; flat assembler core
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 avx_single_source_pd_instruction:
00
11 ; flat assembler core
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 out_of_memory:
2323 jmp general_error
2424 format_limitations_exceeded:
2525 push _format_limitations_exceeded
26 jmp general_error
27 invalid_definition:
28 push _invalid_definition
2629 general_error:
2730 cmp [symbols_file],0
2831 je fatal_error
00
11 ; flat assembler core
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 calculate_expression:
1010 cmp byte [esi],'.'
1111 je convert_fp
1212 calculation_loop:
13 mov eax,[tagged_blocks]
14 sub eax,0Ch
15 cmp eax,edi
16 jbe out_of_memory
1317 lods byte [esi]
1418 cmp al,1
1519 je get_byte_number
3438 sub edi,14h
3539 mov ebx,edi
3640 sub ebx,14h
37 cmp al,0E0h
41 cmp al,0F0h
3842 je calculate_rva
39 cmp al,0E1h
43 cmp al,0F1h
4044 je calculate_plt
4145 cmp al,0D0h
4246 je calculate_not
47 cmp al,0E0h
48 je calculate_bsf
49 cmp al,0E1h
50 je calculate_bsr
4351 cmp al,083h
4452 je calculate_neg
4553 mov dx,[ebx+8]
621629 xor [ebx],eax
622630 xor [ebx+4],edx
623631 xor [ebx+13],cl
624 jz calculation_loop
625 or cl,cl
626 jz xor_size_check
627 xor eax,[ebx]
628 xor edx,[ebx+4]
629 xor_size_check:
630 mov cl,[value_size]
631 cmp cl,1
632 je xor_byte_result
633 cmp cl,2
634 je xor_word_result
635 cmp cl,4
636 je xor_dword_result
637 cmp cl,6
638 je xor_pword_result
639 cmp cl,8
640 jne calculation_loop
641 xor edx,[ebx+4]
642 js xor_result_truncated
643 jmp calculation_loop
644 xor_pword_result:
645 test edx,0FFFF0000h
646 jnz calculation_loop
647 cmp word [ebx+6],-1
648 jne calculation_loop
649 xor dx,[ebx+4]
650 jns calculation_loop
651 not word [ebx+6]
652 jmp xor_result_truncated
653 xor_dword_result:
654 test edx,edx
655 jnz calculation_loop
656 cmp dword [ebx+4],-1
657 jne calculation_loop
658 xor eax,[ebx]
659 jns calculation_loop
660 not dword [ebx+4]
661 jmp xor_result_truncated
662 xor_word_result:
663 test edx,edx
664 jnz calculation_loop
665 test eax,0FFFF0000h
666 jnz calculation_loop
667 cmp dword [ebx+4],-1
668 jne calculation_loop
669 cmp word [ebx+2],-1
670 jne calculation_loop
671 xor ax,[ebx]
672 jns calculation_loop
673 not dword [ebx+4]
674 not word [ebx+2]
675 jmp xor_result_truncated
676 xor_byte_result:
677 test edx,edx
678 jnz calculation_loop
679 test eax,0FFFFFF00h
680 jnz calculation_loop
681 cmp dword [ebx+4],-1
682 jne calculation_loop
683 cmp word [ebx+2],-1
684 jne calculation_loop
685 cmp byte [ebx+1],-1
686 jne calculation_loop
687 xor al,[ebx]
688 jns calculation_loop
689 not dword [ebx+4]
690 not word [ebx+2]
691 not byte [ebx+1]
692 xor_result_truncated:
693 mov byte [ebx+13],0
694632 jmp calculation_loop
695633 shr_negative:
696634 mov byte [edi+13],0
759697 calculate_shr:
760698 cmp byte [edi+13],0
761699 jne shr_negative
762 cmp byte [ebx+13],0
763 je do_shr
764 mov al,[value_size]
765 cmp al,1
766 je shr_negative_byte
767 cmp al,2
768 je shr_negative_word
769 cmp al,4
770 je shr_negative_dword
771 cmp al,6
772 je shr_negative_pword
773 cmp al,8
774 jne do_shr
775 shr_negative_qword:
776 test byte [ebx+7],80h
777 jz do_shr
778 shr_truncated:
779 mov byte [ebx+13],0
780 do_shr:
781700 mov edx,[ebx+4]
782701 mov eax,[ebx]
783702 cmp dword [edi+4],0
807726 mov dword [ebx],eax
808727 mov dword [ebx+4],eax
809728 jmp calculation_loop
810 shr_negative_byte:
811 cmp dword [ebx+4],-1
812 jne do_shr
813 cmp word [ebx+2],-1
814 jne do_shr
815 cmp byte [ebx+1],-1
816 jne do_shr
817 test byte [ebx],80h
818 jz do_shr
819 not dword [ebx+4]
820 not word [ebx+2]
821 not byte [ebx+1]
822 jmp shr_truncated
823 shr_negative_word:
824 cmp dword [ebx+4],-1
825 jne do_shr
826 cmp word [ebx+2],-1
827 jne do_shr
828 test byte [ebx+1],80h
829 jz do_shr
830 not dword [ebx+4]
831 not word [ebx+2]
832 jmp shr_truncated
833 shr_negative_dword:
834 cmp dword [ebx+4],-1
835 jne do_shr
836 test byte [ebx+3],80h
837 jz do_shr
838 not dword [ebx+4]
839 jmp shr_truncated
840 shr_negative_pword:
841 cmp word [ebx+6],-1
842 jne do_shr
843 test byte [ebx+5],80h
844 jz do_shr
845 not word [ebx+6]
846 jmp shr_truncated
847729 calculate_not:
848730 cmp word [edi+8],0
849731 jne invalid_expression
851733 je not_ok
852734 call recoverable_misuse
853735 not_ok:
854 mov al,[value_size]
855 cmp al,1
856 je not_byte
857 cmp al,2
858 je not_word
859 cmp al,4
860 je not_dword
861 cmp al,6
862 je not_pword
863 cmp al,8
864 je not_qword
865736 not dword [edi]
866737 not dword [edi+4]
867738 not byte [edi+13]
868739 add edi,14h
869740 jmp calculation_loop
870 not_qword:
871 not dword [edi]
872 not dword [edi+4]
873 finish_not:
874 mov byte [edi+13],0
741 calculate_bsf:
742 cmp word [edi+8],0
743 jne invalid_expression
744 cmp byte [edi+12],0
745 je bsf_ok
746 call recoverable_misuse
747 bsf_ok:
748 xor ecx,ecx
749 bsf eax,[edi]
750 jnz finish_bs
751 mov ecx,32
752 bsf eax,[edi+4]
753 jnz finish_bs
754 cmp byte [edi+13],0
755 jne finish_bs
756 bs_overflow:
757 call recoverable_overflow
875758 add edi,14h
876759 jmp calculation_loop
877 not_byte:
878 cmp dword [edi+4],0
879 jne not_qword
880 cmp word [edi+2],0
881 jne not_qword
882 cmp byte [edi+1],0
883 jne not_qword
884 not byte [edi]
885 jmp finish_not
886 not_word:
887 cmp dword [edi+4],0
888 jne not_qword
889 cmp word [edi+2],0
890 jne not_qword
891 not word [edi]
892 jmp finish_not
893 not_dword:
894 cmp dword [edi+4],0
895 jne not_qword
896 not dword [edi]
897 jmp finish_not
898 not_pword:
899 cmp word [edi+6],0
900 jne not_qword
901 not word [edi+4]
902 not dword [edi]
903 jmp finish_not
760 calculate_bsr:
761 cmp word [edi+8],0
762 jne invalid_expression
763 cmp byte [edi+12],0
764 je bsr_ok
765 call recoverable_misuse
766 bsr_ok:
767 cmp byte [edi+13],0
768 jne bs_overflow
769 mov ecx,32
770 bsr eax,[edi+4]
771 jnz finish_bs
772 xor ecx,ecx
773 bsr eax,[edi]
774 jz bs_overflow
775 finish_bs:
776 add eax,ecx
777 xor edx,edx
778 mov [edi],eax
779 mov [edi+4],edx
780 mov [edi+13],dl
781 add edi,14h
782 jmp calculation_loop
904783 calculate_neg:
905784 cmp byte [edi+8],0
906785 je neg_first_register_ok
13481227 je byte_positive
13491228 cmp edx,-1
13501229 jne range_exceeded
1351 cmp eax,-80h
1230 cmp eax,-100h
13521231 jb range_exceeded
13531232 ret
13541233 byte_positive:
13921271 je word_positive
13931272 cmp edx,-1
13941273 jne range_exceeded
1395 cmp eax,-8000h
1274 cmp eax,-10000h
13961275 jb range_exceeded
13971276 ret
13981277 word_positive:
14241303 je dword_positive
14251304 cmp edx,-1
14261305 jne range_exceeded
1427 bt eax,31
1428 jnc range_exceeded
14291306 ret
14301307 dword_positive:
14311308 test edx,edx
14431320 mov edx,[edi+4]
14441321 cmp byte [edi+13],0
14451322 je pword_positive
1446 cmp edx,-8000h
1323 cmp edx,-10000h
14471324 jb range_exceeded
14481325 ret
14491326 pword_positive:
14571334 check_qword_value:
14581335 mov eax,[edi]
14591336 mov edx,[edi+4]
1460 cmp byte [edi+13],0
1461 je qword_positive
1462 cmp edx,-80000000h
1463 jb range_exceeded
1464 qword_positive:
14651337 ret
14661338 get_count_value:
14671339 mov [value_size],8
16821554 cmp bh,0F4h
16831555 jne invalid_address
16841556 cmp [free_address_range],0
1685 jne check_qword_value
1686 jmp check_dword_value
1557 je check_dword_value
1558 mov eax,[edi]
1559 mov edx,[edi+4]
1560 ret
16871561 check_rip_relative_address:
16881562 mov eax,[edi]
16891563 cdq
00
11 ; flat assembler core
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 convert_expression:
7676 ret
7777
7878 convert_number:
79 lea eax,[edi-10h]
79 lea eax,[edi+20h]
8080 mov edx,[memory_end]
8181 cmp [source_start],0
8282 je check_memory_for_number
128128 pop [current_offset]
129129 lods byte [esi]
130130 cmp al,')'
131 jne invalid_expression
131 je subexpression_closed
132 dec esi
133 mov al,'!'
134 stosb
135 subexpression_closed:
132136 ret
133137 symbol_value:
134138 cmp [source_start],0
00
11 ; flat assembler core
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 formatter:
34933493 shr eax,8
34943494 stos dword [edi]
34953495 xor eax,eax
3496 stos dword [edi]
3497 stos dword [edi]
3496 push edx
3497 mov edx,[esi+4]
3498 add edx,[image_base]
3499 xchg eax,[edx]
3500 stos dword [edi]
3501 cmp byte [esi],1
3502 je addend_64bit
3503 pop edx
3504 sar eax,31
3505 stos dword [edi]
3506 jmp relocation_entry_ok
3507 addend_64bit:
3508 xor eax,eax
3509 xchg eax,[edx+4]
3510 stos dword [edi]
3511 pop edx
34983512 relocation_entry_ok:
34993513 add esi,0Ch
35003514 jmp convert_relocations
00
11 ; flat assembler interface for Unix/libc
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 format ELF
127127 mov [symbols_file],0
128128 mov [memory_setting],0
129129 mov [passes_limit],100
130
131
130132 mov ecx,[argc]
131133 mov ebx,[argv]
132134 add ebx,4
133135 dec ecx
134136 jz bad_params
137 mov [definitions_pointer],predefinitions
135138 get_param:
136139 mov esi,[ebx]
137140 mov al,[esi]
157160 je passes_option
158161 cmp al,'P'
159162 je passes_option
163 cmp al,'d'
164 je definition_option
165 cmp al,'D'
166 je definition_option
160167 cmp al,'s'
161168 je symbols_option
162169 cmp al,'S'
199206 jnz get_param
200207 cmp [input_file],0
201208 je bad_params
209 mov eax,[definitions_pointer]
210 mov byte [eax],0
211 mov [initial_definitions],predefinitions
202212 clc
203213 ret
214 definition_option:
215 cmp byte [esi],0
216 jne get_definition
217 dec ecx
218 jz bad_params
219 add ebx,4
220 mov esi,[ebx]
221 get_definition:
222 push edi
223 mov edi,[definitions_pointer]
224 call convert_definition_option
225 mov [definitions_pointer],edi
226 pop edi
227 jc bad_params
228 jmp next_param
204229 symbols_option:
205230 cmp byte [esi],0
206231 jne get_symbols_setting
238263 invalid_option_value:
239264 stc
240265 ret
266 convert_definition_option:
267 mov edx,edi
268 xor al,al
269 stosb
270 copy_definition_name:
271 lodsb
272 cmp al,'='
273 je copy_definition_value
274 cmp al,20h
275 je bad_definition_option
276 or al,al
277 jz bad_definition_option
278 stosb
279 inc byte [edx]
280 jnz copy_definition_name
281 bad_definition_option:
282 stc
283 ret
284 copy_definition_value:
285 lodsb
286 cmp al,20h
287 je definition_value_end
288 or al,al
289 jz definition_value_end
290 stosb
291 jmp copy_definition_value
292 definition_value_end:
293 dec esi
294 xor al,al
295 stosb
296 clc
297 ret
241298
242299 include 'system.inc'
243300
244301 include '..\version.inc'
245302
246 _copyright db 'Copyright (c) 1999-2014, Tomasz Grysztar',0xA,0
303 _copyright db 'Copyright (c) 1999-2015, Tomasz Grysztar',0xA,0
247304
248305 _logo db 'flat assembler version ',VERSION_STRING,0
249306 _usage db 0xA
250307 db 'usage: fasm <source> [output]',0xA
251308 db 'optional settings:',0xA
252 db ' -m <limit> set the limit in kilobytes for the available memory',0Dh,0Ah
253 db ' -p <limit> set the maximum allowed number of passes',0Dh,0Ah
254 db ' -s <file> dump symbolic information for debugging',0Dh,0Ah
309 db ' -m <limit> set the limit in kilobytes for the available memory',0Dh,0Ah
310 db ' -p <limit> set the maximum allowed number of passes',0Dh,0Ah
311 db ' -d <name>=<value> define symbolic variable',0Dh,0Ah
312 db ' -s <file> dump symbolic information for debugging',0Dh,0Ah
255313 db 0
256314 _memory_prefix db ' (',0
257315 _memory_suffix db ' kilobytes memory)',0xA,0
281339 argv dd ?
282340 stack_frame dd ?
283341 memory_setting dd ?
342 definitions_pointer dd ?
284343 start_time dd ?
285344 timestamp dq ?
286345 con_handle dd ?
288347 last_displayed db ?
289348 character db ?
290349
350 predefinitions rb 1000h
291351 buffer rb 1000h
00
11 ; flat assembler interface for Unix/libc
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 extrn malloc
220220 assembler_error:
221221 mov [con_handle],2
222222 call display_user_messages
223 mov ebx,[current_line]
224 test ebx,ebx
225 jz display_error_message
223226 push dword 0
224 mov ebx,[current_line]
225227 get_error_lines:
226228 mov eax,[ebx]
227229 cmp byte [eax],0
313315 pop ebx
314316 or ebx,ebx
315317 jnz display_error_line
318 display_error_message:
316319 mov esi,error_prefix
317320 call display_string
318321 pop esi
00
11 ; flat assembler core
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 _out_of_memory db 'out of memory',0
00
11 ; flat assembler core
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 parser:
12571257 inc esi
12581258 cmp byte [esi-1],'$'
12591259 je get_org_origin_id
1260 sub esi,ecx
1260 sub esi,2
12611261 jmp find_label
12621262 get_current_offset_id:
12631263 xor eax,eax
13621362 cmp al,30h
13631363 jb name_first_char_ok
13641364 cmp al,39h
1365 jbe invalid_name
1365 jbe numeric_name
13661366 name_first_char_ok:
13671367 cmp al,'$'
13681368 jne check_for_reserved_word
1369 cmp ecx,1
1370 jne invalid_name
1369 numeric_name:
1370 add esi,ecx
13711371 reserved_word:
13721372 mov eax,0Fh
13731373 pop edi
00
11 ; flat assembler core
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 preprocessor:
4141 mov [hash_tree],eax
4242 mov [error],eax
4343 mov [macro_status],al
44 mov [current_line],eax
45 mov esi,[initial_definitions]
46 test esi,esi
47 jz predefinitions_ok
48 process_predefinitions:
49 movzx ecx,byte [esi]
50 test ecx,ecx
51 jz predefinitions_ok
52 inc esi
53 lea eax,[esi+ecx]
54 push eax
55 mov ch,10b
56 call add_preprocessor_symbol
57 pop esi
58 mov edi,[memory_start]
59 mov [edx+8],edi
60 convert_predefinition:
61 cmp edi,[memory_end]
62 jae out_of_memory
63 lods byte [esi]
64 or al,al
65 jz predefinition_converted
66 cmp al,20h
67 je convert_predefinition
68 mov ah,al
69 mov ebx,characters
70 xlat byte [ebx]
71 or al,al
72 jz predefinition_separator
73 cmp ah,27h
74 je predefinition_string
75 cmp ah,22h
76 je predefinition_string
77 mov byte [edi],1Ah
78 scas word [edi]
79 xchg al,ah
80 stos byte [edi]
81 mov ebx,characters
82 xor ecx,ecx
83 predefinition_symbol:
84 lods byte [esi]
85 stos byte [edi]
86 xlat byte [ebx]
87 or al,al
88 loopnzd predefinition_symbol
89 neg ecx
90 cmp ecx,255
91 ja invalid_definition
92 mov ebx,edi
93 sub ebx,ecx
94 mov byte [ebx-2],cl
95 found_predefinition_separator:
96 dec edi
97 mov ah,[esi-1]
98 predefinition_separator:
99 xchg al,ah
100 or al,al
101 jz predefinition_converted
102 cmp al,20h
103 je convert_line_data
104 cmp al,3Bh
105 je invalid_definition
106 cmp al,5Ch
107 je predefinition_backslash
108 stos byte [edi]
109 jmp convert_predefinition
110 predefinition_string:
111 mov al,22h
112 stos byte [edi]
113 scas dword [edi]
114 mov ebx,edi
115 copy_predefinition_string:
116 lods byte [esi]
117 stos byte [edi]
118 or al,al
119 jz invalid_definition
120 cmp al,ah
121 jne copy_predefinition_string
122 lods byte [esi]
123 cmp al,ah
124 je copy_predefinition_string
125 dec esi
126 dec edi
127 mov eax,edi
128 sub eax,ebx
129 mov [ebx-4],eax
130 jmp convert_predefinition
131 predefinition_backslash:
132 mov byte [edi],0
133 lods byte [esi]
134 or al,al
135 jz invalid_definition
136 cmp al,20h
137 je invalid_definition
138 cmp al,3Bh
139 je invalid_definition
140 mov al,1Ah
141 stos byte [edi]
142 mov ecx,edi
143 mov ax,5C01h
144 stos word [edi]
145 dec esi
146 group_predefinition_backslashes:
147 lods byte [esi]
148 cmp al,5Ch
149 jne predefinition_backslashed_symbol
150 stos byte [edi]
151 inc byte [ecx]
152 jmp group_predefinition_backslashes
153 predefinition_backslashed_symbol:
154 cmp al,20h
155 je invalid_definition
156 cmp al,22h
157 je invalid_definition
158 cmp al,27h
159 je invalid_definition
160 cmp al,3Bh
161 je invalid_definition
162 mov ah,al
163 mov ebx,characters
164 xlat byte [ebx]
165 or al,al
166 jz predefinition_backslashed_symbol_character
167 mov al,ah
168 convert_predefinition_backslashed_symbol:
169 stos byte [edi]
170 xlat byte [ebx]
171 or al,al
172 jz found_predefinition_separator
173 inc byte [ecx]
174 jz invalid_definition
175 lods byte [esi]
176 jmp convert_predefinition_backslashed_symbol
177 predefinition_backslashed_symbol_character:
178 mov al,ah
179 stos byte [edi]
180 inc byte [ecx]
181 jmp convert_predefinition
182 predefinition_converted:
183 mov [memory_start],edi
184 sub edi,[edx+8]
185 mov [edx+12],edi
186 jmp process_predefinitions
187 predefinitions_ok:
44188 mov esi,[input_file]
45189 mov edx,esi
46190 call open
77221 mov [ebx],eax
78222 call use_postponed_macro
79223 pop edx
80 jmp process_postponed_list
224 cmp [macro_status],0
225 je process_postponed_list
226 mov eax,[error_line]
227 mov [current_line],eax
228 jmp incomplete_macro
81229 preprocessing_finished:
82230 mov [source_start],edi
83231 ret
274422 jne backslashed_symbol
275423 stos byte [edi]
276424 inc byte [ecx]
425 jz name_too_long
277426 jmp group_backslashes
278427 no_end_quote:
279428 mov byte [ebx-5],0
8951044 inc esi
8961045 add esi,eax
8971046 lods byte [esi]
1047 cmp al,':'
1048 je macro_argument_with_default_value
8981049 cmp al,'='
8991050 je macro_argument_with_default_value
9001051 cmp al,'*'
9031054 macro_argument_end:
9041055 cmp al,','
9051056 je skip_macro_arguments
1057 cmp al,'&'
1058 je macro_arguments_finisher
9061059 cmp al,']'
9071060 jne end_macro_arguments
908 lods byte [esi]
9091061 not ebp
1062 macro_arguments_finisher:
1063 lods byte [esi]
9101064 end_macro_arguments:
9111065 or ebp,ebp
9121066 jnz invalid_macro_arguments
9161070 je found_macro_block
9171071 jmp invalid_macro_arguments
9181072 macro_argument_with_default_value:
919 or [default_argument_value],-1
1073 or [skip_default_argument_value],-1
9201074 call skip_macro_argument_value
9211075 inc esi
9221076 jmp macro_argument_end
9551109 jz argument_value_end
9561110 cmp al,','
9571111 je argument_value_end
958 cmp [default_argument_value],0
1112 cmp [skip_default_argument_value],0
9591113 je invalid_macro_arguments
9601114 cmp al,'{'
1115 je argument_value_end
1116 cmp al,'&'
9611117 je argument_value_end
9621118 or ebp,ebp
9631119 jz invalid_macro_arguments
9741130 je argument_string
9751131 cmp al,1Ah
9761132 je argument_symbol
977 cmp [default_argument_value],0
1133 cmp [skip_default_argument_value],0
9781134 je simple_argument
9791135 cmp al,'{'
1136 je argument_value_end
1137 cmp al,'&'
9801138 je argument_value_end
9811139 or ebp,ebp
9821140 jz simple_argument
10551213 xor ecx,ecx
10561214 call add_preprocessor_symbol
10571215 mov eax,[current_line]
1216 mov [error_line],eax
10581217 mov [edx+12],eax
10591218 pop esi
10601219 mov [edx+8],esi
10621221 and al,0F0h
10631222 or al,1
10641223 mov [macro_status],al
1065 mov eax,[current_line]
1066 mov [error_line],eax
10671224 lods byte [esi]
10681225 or al,al
10691226 jz line_preprocessed
15571714 je next_argument
15581715 cmp al,']'
15591716 je next_arguments_group
1717 cmp al,'&'
1718 je arguments_end
15601719 dec esi
15611720 jmp arguments_end
15621721 next_argument:
15771736 mov eax,[counter_limit]
15781737 call add_macro_symbol
15791738 add esi,ecx
1739 xor eax,eax
1740 mov [default_argument_value],eax
1741 cmp byte [esi],'*'
1742 je required_value
1743 cmp byte [esi],':'
1744 je get_default_value
1745 cmp byte [esi],'='
1746 jne default_value_ok
1747 get_default_value:
1748 inc esi
1749 mov [default_argument_value],esi
1750 or [skip_default_argument_value],-1
1751 call skip_macro_argument_value
1752 jmp default_value_ok
1753 required_value:
1754 inc esi
1755 or [default_argument_value],-1
1756 default_value_ok:
15801757 xchg esi,ebx
15811758 mov [edx+12],esi
1582 mov [default_argument_value],0
1759 mov [skip_default_argument_value],0
1760 cmp byte [ebx],'&'
1761 je greedy_macro_argument
15831762 call skip_macro_argument_value
15841763 call finish_macro_argument
1764 jmp got_macro_argument
1765 greedy_macro_argument:
1766 call skip_foreign_line
1767 dec esi
1768 mov eax,[edx+12]
1769 mov ecx,esi
1770 sub ecx,eax
1771 mov [edx+8],ecx
1772 got_macro_argument:
15851773 xchg esi,ebx
1586 cmp byte [esi],'='
1587 je argument_with_default_value
1588 cmp byte [esi],'*'
1774 cmp dword [edx+8],0
15891775 jne macro_argument_ok
1590 cmp dword [edx+8],0
1776 mov eax,[default_argument_value]
1777 or eax,eax
1778 jz macro_argument_ok
1779 cmp eax,-1
15911780 je invalid_macro_arguments
1592 inc esi
1781 mov [edx+12],eax
1782 call finish_macro_argument
15931783 macro_argument_ok:
15941784 ret
15951785 finish_macro_argument:
16041794 argument_value_length_ok:
16051795 mov [edx+8],ecx
16061796 ret
1607 argument_with_default_value:
1608 inc esi
1609 push esi
1610 or [default_argument_value],-1
1611 call skip_macro_argument_value
1612 pop eax
1613 cmp dword [edx+8],0
1614 jne macro_argument_ok
1615 mov [edx+12],eax
1616 call finish_macro_argument
1617 jmp macro_argument_ok
16181797 arguments_end:
16191798 cmp byte [ebx],0
16201799 jne invalid_macro_arguments
17401919 lods byte [esi]
17411920 cmp [base_code],1
17421921 ja irps_name_ok
1922 cmp al,':'
1923 je irp_with_default_value
17431924 cmp al,'='
17441925 je irp_with_default_value
17451926 cmp al,'*'
17511932 jmp irp_parameters_start
17521933 irp_with_default_value:
17531934 xor ebp,ebp
1754 or [default_argument_value],-1
1935 or [skip_default_argument_value],-1
17551936 call skip_macro_argument_value
1937 cmp byte [esi],','
1938 jne invalid_macro_arguments
17561939 inc esi
17571940 jmp irp_parameters_start
17581941 irps_name_ok:
00
11 ; flat assembler core
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 dump_symbols:
00
11 ; flat assembler core
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 include_variable db 'INCLUDE',0
6363 single_operand_operators:
6464 db 1,'+',82h
6565 db 1,'-',83h
66 db 3,'bsf',0E0h
67 db 3,'bsr',0E1h
6668 db 3,'not',0D0h
67 db 3,'plt',0E1h
68 db 3,'rva',0E0h
69 db 3,'plt',0F1h
70 db 3,'rva',0F0h
6971 db 0
7072
7173 directive_operators:
00
11 ; flat assembler core variables
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 ; Variables which have to be set up by interface:
1212
1313 stack_limit dd ?
1414
15 initial_definitions dd ?
1516 input_file dd ?
1617 output_file dd ?
1718 symbols_file dd ?
4142 struc_label dd ?
4243 instant_macro_start dd ?
4344 parameters_end dd ?
45 default_argument_value dd ?
4446 locals_counter rb 8
4547 current_locals_prefix dd ?
4648 anonymous_reverse dd ?
132134 adjustment_sign db ?
133135
134136 macro_status db ?
135 default_argument_value db ?
137 skip_default_argument_value db ?
136138 prefixed_instruction db ?
137139 formatter_symbols_allowed db ?
138140 free_address_range db ?
00
11 ; flat assembler version 1.71
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44 ;
55 ; This programs is free for commercial and non-commercial use as long as
3232 ; cannot simply be copied and put under another distribution licence
3333 ; (including the GNU Public Licence).
3434
35 VERSION_STRING equ "1.71.22"
35 VERSION_STRING equ "1.71.39"
3636
3737 VERSION_MAJOR = 1
3838 VERSION_MINOR = 71
00
11 ; flat assembler core
2 ; Copyright (c) 1999-2014, Tomasz Grysztar.
2 ; Copyright (c) 1999-2015, Tomasz Grysztar.
33 ; All rights reserved.
44
55 simple_instruction_except64:
555555 cmp [value_type],4
556556 jae long_immediate_not_encodable
557557 jmp mov_mem_imm_32bit_store
558 mov_mem_imm_nosize:
559 call recoverable_unknown_size
558560 mov_mem_imm_8bit:
559561 call get_byte_value
560562 mov byte [value],al
572574 pop ecx ebx edx
573575 call store_instruction_with_imm16
574576 jmp instruction_assembled
575 mov_mem_imm_nosize:
576 call recoverable_unknown_size
577577 mov_mem_imm_32bit:
578578 call operand_32bit
579579 call get_dword_value
965965 cmp [value_type],4
966966 jae long_immediate_not_encodable
967967 jmp test_mem_imm_32bit_store
968 test_mem_imm_nosize:
969 call recoverable_unknown_size
968970 test_mem_imm_8bit:
969971 call get_byte_value
970972 mov byte [value],al
982984 pop ecx ebx edx
983985 call store_instruction_with_imm16
984986 jmp instruction_assembled
985 test_mem_imm_nosize:
986 call recoverable_unknown_size
987987 test_mem_imm_32bit:
988988 call operand_32bit
989989 call get_dword_value
46104610 call get_size_operator
46114611 cmp al,10h
46124612 je movq_mmreg_reg
4613 cmp al,'['
4614 jne invalid_operand
46134615 call get_address
46144616 test [operand_size],not 8
46154617 jnz invalid_operand_size
00
11 Visit http://flatassembler.net/ for more information.
2
3
4 version 1.71.39 (Mar 11, 2015)
5
6 [-] Minor bug fix.
7
8
9 version 1.71.38 (Mar 09, 2015)
10
11 [-] Minor bug fixes.
12
13
14 version 1.71.37 (Mar 03, 2015)
15
16 [-] Fixed a crash caused by incorrect handling of any error in definition
17 provided through "-d" switch.
18
19
20 version 1.71.36 (Feb 26, 2015)
21
22 [-] Fixed a small bug with "irp" directive.
23
24
25 version 1.71.35 (Feb 25, 2015)
26
27 [-] Corrected a flaw that caused a crash when processing incomplete macro
28 definitions within the "postpone" block.
29
30
31 version 1.71.34 (Feb 17, 2015)
32
33 [-] Fixed a recently introduced bug that caused assembler to hang when a
34 missing closing parenthesis error was encountered.
35
36
37 version 1.71.33 (Jan 09, 2015)
38
39 [+] Default value for macroinstruction parameter can now be defined with ":"
40 character as an alternative to "=".
41
42
43 version 1.71.32 (Jan 04, 2015)
44
45 [+] Brought back the "-d" switch for command line.
46
47
48 version 1.71.31 (Dec 08, 2014)
49
50 [-] Removed dependence on size context for expression operators like NOT and XOR.
51
52 [-] Relaxed range checking to allow extended negative range for all sizes.
53
54
55 version 1.71.30 (Dec 07, 2014)
56
57 [-] Clearing the instruction data field when filling the addend for 64-bit ELF
58 relocaiton.
59
60
61 version 1.71.29 (Dec 05, 2014)
62
63 [-] Supressed error message when parsing some malformed expressions that do not
64 get evaluated.
65
66
67 version 1.71.28 (Dec 01, 2014)
68
69 [-] The addend field of relocation structure for 64-bit ELF format is now filled with
70 correct information.
71
72
73 version 1.71.27 (Nov 18, 2014)
74
75 [-] Corrected initial predictions of immediate size for "mov" and "test" instructions
76 (this may sometimes help to generate smaller code).
77
78
79 version 1.71.26 (Nov 12, 2014)
80
81 [-] Fixed a bug introduced by previous version that allowed address values to
82 bypass range checks.
83
84
85 version 1.71.25 (Nov 03, 2014)
86
87 [-] Fixed a bug that cause valued of argument starting with "<" character to be
88 incorrectly processed when the parameter in question was marked with "&"
89 character.
90
91
92 version 1.71.24 (Oct 27, 2014)
93
94 [+] In the definition of macroinstruction the last argument can now be followed by
95 "&" character to indicate that this argument can be filled with all the remaining
96 contents of line that called the macro. This feature cannot be combined with a
97 multi-value arguments.
98
99
100 version 1.71.23 (Oct 21, 2014)
101
102 [+] Added "bsf" and "bsr" operators to numerical expressions.
103
104 [-] Removed the restriction that disallowed numerical constant to
105 forward-reference its own value.
2106
3107
4108 version 1.71.22 (Sep 28, 2014)