Wednesday, April 18, 2012

How to compile NASM assembly language programs in 32 bit & 64 bit Linux

FOR 32 BIT PROCESSORS,


1. nasm -f elf <filename.asm>
2. ld -s -o <filename> <filename.o>
3. ./<filename>

FOR 64 BIT PROCESSORS,


change the 1st step as

nasm -f elf64 <filename.asm>


IF YOU ARE USING C FUNCTIONS IN THE PROGRAM.

(like printf, scanf...)


FOR 32 BIT PROCESSORS,


1. nasm -f elf <filename.asm>
2. gcc -s -o <filename> <filename.o>
3. ./<filename>

FOR 64 BIT PROCESSORS,


change 2nd step as

gcc -m32 -s -o <filename> <filename.o>

No comments:

Post a Comment