Variations on Hello, world!

Narue

FASM can output an executable PE directly, but sometimes you want to output an object file for linking with modules in other languages. The following program can be used to link with the C library of the GCC compiler with the following commands:

C:\>fasm hello.asm hello.obj
C:\>gcc hello.obj -o hello.exe

It's almost like magic! :)

255 Views
About the Author
format MS COFF

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

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

hello_msg db 'Hello, world!',0

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

public _main
extrn '_printf' as printf


_main:
	ccall	printf,hello_msg
	xor	eax,eax
	ret
Be a part of the DaniWeb community

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