2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by NicAx64
0

what does the assembler do is just convert the assembly language
source file into a object file. file name ended with .a .obj .o like extension.

I'm using nasm and suggest you too use it.With this command like you
assembling it to a object file.

nasm -f elf HelloWorld.asm

and you need a linker , I have mingw installed in my windows machine
so I suggested to use mingw ld linker to link this.But you need extra
libraries to pass to use the functions like _printf , so that we use the
gcc ( GNU C compiler's fontend for 'ld') , but actually 'ld' is using.

J:\EXERCISES\Assembly\hello>
J:\EXERCISES\Assembly\hello>nasm -f elf  HelloWorld.asm

J:\EXERCISES\Assembly\hello>gcc HelloWorld.o -o HelloWorld.exe -e _main

J:\EXERCISES\Assembly\hello>HelloWorld
hello, World

J:\EXERCISES\Assembly\hello>

Compile it and see yourself,This is the code for HelloWorld.asm,

global _main
	extern _printf 
	
	section .text
_main: 
	push message
	call _printf 
	add  esp , 4
	ret
message:
	db 'hello, World',10,0

NOTE: when you using a symbol as an entry point that symbol should
be global, and also you can specify the entry point using -e option in the
ld linker.

I think other linkers also give you to explicitly specify the entry point
of your program.

Download nasm and install mingw and do it by yourself. Best regards.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.