Hello, world! in FASM

Narue 0 Tallied Votes 1K Views Share

Some languages are hard to get started in. FASM appears to be one of these languages because the documentation is not detailed enough for a beginner. That's a shame because FASM is (in my opinion) one of the better assemblers. The following snippet is a simple Hello, world! program which FASM will directly output an executable on Windows.

The C run-time library is used by accessing the msvcrt DLL, so a linker isn't necessary.

format PE console
entry start

include 'C:\fasm\include\win32a.inc'

;======================================
section '.data' data readable writeable
;======================================

hello_msg db 'Hello, world!',0

;=======================================
section '.code' code readable executable
;=======================================

start:
	ccall	[printf],hello_msg
	ccall	[getchar]
	stdcall	[ExitProcess],0

;====================================
section '.idata' import data readable
;====================================

library kernel,'kernel32.dll',\
        msvcrt,'msvcrt.dll'

import kernel,\
       ExitProcess,'ExitProcess'

import msvcrt,\
       printf,'printf',\
       getchar,'_fgetchar'
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.