As I'm still running 32-bit hardware, I'm not entirely certain what 64-bit Linux will (or will not) allow you to do. I'm pretty sure you can still run 32-bit code with no problem. You shouldn't need to install 32-bit Linux. However, your gcc and ld will (I think) be expecting to generate 64-bit code, unless instructed otherwise. I think adding "-m32" to a gcc command line, and "-melf-i386" to an ld command line will accomplish that...
I agree that you'd be better off to start by learning 32-bit assembly first - mainly because tutorials for 64-bit coding seem to ASSume that you know 32-bit, and mainly address the changes for 64-bit (many!).
For a 32-bit tutorial, try:
http://www.drpaulcarter.com/pcasm/In order to be portable between Windows/Linux/etc., this uses the C library (printf and scanf mostly) for I/O. Make sure to get the Linux version of the example code! As I recall, the first thing you'll need to do is assemble asm_io.asm. To Nasm, "-f elf" and "-f elf32" are the same thing. Dr. Carter's instructions probably say "-f elf", but you might want to use "-f elf32" for "clarity"(?).
nasm -f elf32 -d ELF_TYPE asm_io.asm
The "ELF_TYPE" definition simply changes "_printf" to "printf", etc. As you probably know, gcc and ld don't use underscores on external symbols. Nasm has a feature (added after Dr. Carter wrote his book) which will do the "opposite" - you write "main" and "printf", etc., and "--prefix _" will add leading underscores to make it "portable" to Windows, and if you're using Watcom C, "--postfix" will add trailing underscores...
That should give you asm_io.o (if all goes well) which you can link with your asm gem, providing functions read_int, print_int, print_string, etc. (see the source for all of them) that you can use...
Then assemble first.asm...
nasm -f elf32 -d ELF_TYPE first.asm
... and link it with driver.c and asm_io.o from above. driver.c just calls asm_main, the entrypoint of your assembly code...
gcc -m32 -o first driver.c first.o asm_io.o
If that doesn't work, pay attention to what goes wrong and get back to us.
There's a list of other tutorials (not all for Nasm) at:
http://asm.sourceforge.net/resources.html#tutorialsThe first one, by Konstantin Boldyshev (who first straighened me out on how to do asm in Linux) looks quite good!
When you get ready to move to 64-bit, there's an example here:
http://callumscode.com/blog/3I know there's a "better" one - more examples - but I can't find the bookmark at the moment. Anyone?
Best,
Frank