Cogs and Levers A blog full of technical stuff

Windows Development with FASM

In this post, I’ll walk through the steps required to bootstrap your development experience against the Win32 API using the Flat Assembler.

Prerequisites

Everything is provided for you when you download the fasmw package, including libraries, include files. fasmw even includes a linker pre-geared for windows as your target.

Test program

Here’s the code to present a message box.

include 'win32ax.inc'

.code

	start:

		invoke MessageBox, HWND_DESKTOP, 'This is a test', 'Hey, Hey!', MB_OK
		invoke ExitProcess, 0

.end start

Everything is provided to you through win32ax.inc. This can be swapped out easily enough with a 64 bit counterpart if you’re targeting different architectures.

Assembling and linking

Now that you’ve got your source file, hello.asm you can produce an object file with the following:

C:\src> fasm hello.asm

That’s all there is to it. You’ll now have an exe available to you to run. The only gotcha is giving fasm a hint as to where your include files are, and you do this through the INCLUDE environment variable:

SET INCLUDE=C:\fasmw\include