Loading
Russian
Polish
Mikołaj Hajduk's Homepage

Multiline comments in FASM

C
reation and intensive testing of applications written with FASM often needs to comment a big fragments of the code. By default FASM accepts only one-line comments, starting with ; (semicolon) symbol and ending on the last character of the line. If you are writing programs in high-level languages, you have ability to use multiline comments, as for example in C/C++, where commented code is contained between /* and */ symbols. Above mentioned facts inspired me to rebuild FASM preprocessor such way which will give a possibility to use multiline comments in programs written with this language.

Caution: this article is presented here only for archival purposes because it describes corrections made in the 'preproce.inc' file for the 1.67.* version of FASM and doesn't take into account any further changes of the FASM preprocessor.

Solution of multiline comments problem presented below is the best as a most low-level and overtakes any other "solutions" based on FASM macros mechanism.

History of the project

In May 2007 I made necessary improvements in 'preproce.inc' file (FASM preprocessor) and result of this work was shown on the FASM and WASM.RU forums. Next Mr_Silent made some changes in this code which correct numeration of code lines in compiled file (this is very important particularly in these cases, when compiler displays syntax error messages). Final result of our efforts Reader can see on this page.

Installation

Copy modified file 'preproce.inc' to the directory 'FASM\SOURCES' and recompile sources of FASM compiler used in actual OS. Windows' users should remember about actualization of executables 'FASM.EXE' and 'FASMW.EXE', placed in the 'FASM' directory, with newer (patched) versions.

Source

Here you can download an archive with the patched file 'preproce.inc':

Example of use

Here is an example of simple program written with FASM which shows new possibilities given by multiline comments.

include '%fasminc%\win32ax.inc'

.code
	
; Classic FASM one-line comment.
	
start:
	invoke	MessageBox, HWND_DESKTOP, "Hi! I'm the example program!", "Win32 Assembly", MB_OK
		
	/*		
	Multiline C/C++ style comment.
		
	invoke	MessageBox, HWND_DESKTOP, "Good bye!", "Win32 Assembly", MB_OK		
	*/

	invoke	/* C/C++ style comment placed inside the code line. */ ExitProcess, 0

.end start
© 2007-2020, Mikołaj Hajduk | Last modified: 2020-03-05 19:47:19 CET