flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > FASM w listing, preprocessor, symbol export & more~

Author
Thread Post new topic Reply to topic
wht36



Joined: 18 Sep 2005
Posts: 106
wht36 22 Dec 2010, 06:13
This patch adds the following options to the main FASM.EXE (windows only)

Code:
-i <file>  include file in processing
-e export all labels and variables for debugging
-f dump symbolic info to .fas file
-l dump assembly listing to .lst file
-o dump preprocessor output to .out file    


Note: There are already separate tools to generate preprocessor & listing output in the TOOLS folder. This is patch is for those who prefer everything in one executable. The patch can also export symbols for debugging and automatically searches FASM home path for include files.

The basic patch went like this
Code:
start:
.
.
.
  call    preprocessor
;vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 call    process_fasm_flags
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    call    parser
      call    assembler
   call    formatter
;vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    test    [fasm_flags],4
      jz      finish_listing
      call    listing
    finish_listing:
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.
.
.
     jmp     exit_program

;vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
process_fasm_flags:
        cmp   byte [include_files],0
        jz      create_export_section
        ...
        ... loop through include files
        ...
create_export_section:
   test    [fasm_flags],export_option_flag
     jz      write_preprocessor_file
       ...
       ... parse preprocessor output and create export file
       ... run preprocessor on export file to create export section
       ...
write_preprocessor_file
        test    [fasm_flags],preprocessor_option_flag
       jz      write_symbol_file
        ...
        ... convert preprocessor output to text and write to .out file
        ...
write_symbol_file:
 cmp     [fasm_flags],fas_option_flag
        jb      done_processing_fasm_flags
  mov     eax,'fas'
 call    create_output_file_extension
        mov     [symbols_file],edx
done_processing_fasm_flags:   
    ret
 
create_output_file_extension:
.
.
.
        ret

listing: ;copied from listing.inc
    mov     edx,[symbols_file]
  call    open
.
.
.
;        mov     edx,[listing_file]
  mov     eax,'lst'
 call    create_output_file_extension
        call    create
.
.
.
  load_file:
.
.
.
    call    read_
.
.
.
        ret

  alloc:
.
.
.
  free:
.
.
.
  read_:
.
.
.     retn

;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.
.
.

get_params:
.
.
.
    cmp     al,'S'
    je      symbols_option
;vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv 
  or      al,'a'-'A'
      mov     ah,preproc_flag
     cmp     al,'o'
    je      set_fasm_flags

  mov     ah,fas_flag
 cmp     al,'f'
    je      set_fasm_flags
.
.
.
   set_fasm_flags:
        or   [fasm_flags],ah
        jmp  find_param
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    bad_params:
.
.
.
       db ' -s <file>     dump symbolic information for debugging',0Dh,0Ah
;vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv 
       db ' -f            dump symbolic information to .fas for debugging',0Dh,0Ah
...
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.
.
.
_bytes_suffix db ' bytes.',0Dh,0Ah,0

;vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv 
fasm_flags db 0
...
...
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.
.
.
start_time dd ?

;vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv  
  input dd ?
...
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^    


Hmm, my follow up post are getting too many, sorry about that Sad. Is there a way to delete them? I will put the newest version here from now on.


Description: FASM windows console v1.69.32 with command line options for generating listing, preprocessor and symbol export, as well as including files and using the INCLUDE folder from the FASM program path.
Download
Filename: FASM 1.69.32 w listing, preprocessor, symbol export, include, home path.7z
Filesize: 132.32 KB
Downloaded: 530 Time(s)



Last edited by wht36 on 02 Feb 2013, 20:05; edited 17 times in total
Post 22 Dec 2010, 06:13
View user's profile Send private message Reply with quote
wht36



Joined: 18 Sep 2005
Posts: 106
wht36 22 Dec 2010, 13:59
Nevermind, I figured out why. I forgot to include the read procedure from system.inc in the TOOLS folder. The updated source can be downloaded below. It basically adds the following options
Code:
-f dump symbolic info to .fas file
-l dump assembly listing to .lst file
-o dump preprocessor output to .out file
    


Description: Extract to SOURCE\WIN32 and assemble.
Download
Filename: FASM with listing & preprocessor output.7z
Filesize: 5.49 KB
Downloaded: 602 Time(s)

Post 22 Dec 2010, 13:59
View user's profile Send private message Reply with quote
wht36



Joined: 18 Sep 2005
Posts: 106
wht36 23 Dec 2010, 14:00
Update. I've added an option to create an export section in the final output exe with all the labels and variables used so that you can symbolically debug the exe in Ollydbg. Only tested on the FASM.ASM original source.
Code:
-e export all labels and variables for debugging
-f dump symbolic info to .fas file
-l dump assembly listing to .lst file
-o dump preprocessor output to .out file     


Description:
Download
Filename: FASM with listing, preprocessor, symbol export output.7z
Filesize: 6.35 KB
Downloaded: 545 Time(s)

Post 23 Dec 2010, 14:00
View user's profile Send private message Reply with quote
wht36



Joined: 18 Sep 2005
Posts: 106
wht36 23 Dec 2010, 21:07
Another update. Added option to have include files. Use one include file per -i switch. Include files and input file will be processed in the sequence that they occur on the command line. e.g. -i include2.inc proggie.asm -i include1.inc will assemble proggie.exe by first processing include2.inc, followed by proggie.asm, followed by include1.inc.
Code:
-i <file>  include file in processing
-e export all labels and variables for debugging
-f dump symbolic info to .fas file
-l dump assembly listing to .lst file
-o dump preprocessor output to .out file    


Description: Extract FASM32.ASM to SOURCE\WIN32 and assemble. Can rename FASM32.EXE to FASM.EXE if you want.
Download
Filename: FASM with listing, preprocessor, symbol export, and multiple includes.7z
Filesize: 6.55 KB
Downloaded: 619 Time(s)

Post 23 Dec 2010, 21:07
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20519
Location: In your JS exploiting you and your system
revolution 24 Dec 2010, 01:22
So SSSO is no go. Crying or Very sad
Post 24 Dec 2010, 01:22
View user's profile Send private message Visit poster's website Reply with quote
wht36



Joined: 18 Sep 2005
Posts: 106
wht36 24 Dec 2010, 02:17
Unfortunately the output won't be the same with -e option because for symbolic debugging the symbol exports have to be embedded in the exe (in the export section) for Ollydbg to display them. The other options should not affect the final exe output (other than the timestamp in the file header).
Post 24 Dec 2010, 02:17
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20519
Location: In your JS exploiting you and your system
revolution 24 Dec 2010, 02:39
-i is the SSSO killer and would bring us back to the ugly days of TASM style command line craziness just to get something to assemble.
Post 24 Dec 2010, 02:39
View user's profile Send private message Visit poster's website Reply with quote
wht36



Joined: 18 Sep 2005
Posts: 106
wht36 24 Dec 2010, 03:51
Very Happy I suppose -i would indeed be the SSSO killer. I've never used TASM before so haven't experienced that craziness. Process-wise, -i here works exactly the same as the include directive at the beginning/end of the source file (depending on whether -i is placed before or after the source file). A program that does a similar thing is the FA commandline extension for FASM program by Tomasz http://board.flatassembler.net/topic.php?t=9948 which Tomasz also says is non-SSSO compliant Very Happy. Personally I will probably never use -i. In fact I like to use as few includes as possible. I just vaguely remembered that someone wanted that feature sometime ago and the way to do it came like a "light bulb" to me so I couldn't resist doing it~ Sorry~
Post 24 Dec 2010, 03:51
View user's profile Send private message Reply with quote
wht36



Joined: 18 Sep 2005
Posts: 106
wht36 24 Dec 2010, 08:45
Update. This version will search the INCLUDE folder in FASM's homepath for include files, so you don't need to set the INCLUDE environment variable to FASM\INCLUDE anymore.


Description: This version searches FASM's homepath\INCLUDE folder for include files.
Download
Filename: FASM with listing, preprocessor, symbol export, includes, and home path.7z
Filesize: 6.8 KB
Downloaded: 599 Time(s)

Post 24 Dec 2010, 08:45
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4354
Location: Now
edfed 31 Jan 2011, 12:37
F8 would be really nice for .LST generation, because .FAS file is not really usefull for the lambda coder like me. .LST really means something, directlly useable is fasm editor.

the process that would be very nice with listing file generation under fasm IDE is to open the fresh generated .LST file in a new tab.
Post 31 Jan 2011, 12:37
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4354
Location: Now
edfed 14 Feb 2011, 17:07
UP!!!

fasm <source> -L option
as an official feature of fasm, fasmw, fasmd, etc.. Very Happy

it rests SSSO compliant because, .LST should not considered as an output, but as a debug ressource.

is that planned as the debug F8 menuitem in fasmw?

if this feature is present in next days, i will be able to document it. Smile
else, it will be a serious lack... Sad
Post 14 Feb 2011, 17:07
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.