Well, the Friendly Manual has a pretty good run-down on it:
http://www.nasm.us/xdoc/2.09.08/html/nasmdoc9.html#section-9.1"global" and "extern" are the keys to it. A symbol - function or variable - which exists in your file, that you wish to make known to the outside world, is "global". A symbol - function or variable - which is used in your code, but exists someplace else, is "extern". (some assemblers use "public" and "extrn") This applies to languages other than C, BTW - I think I have an example of an asm function that can be called from Fortran!
There's the question of "how do we spell it". Almost everybody besides ELF spells it "_main" and "_printf". ELF spells it "main" and "printf". OpenWatcom C spells it "main_" and "prinf_"! Lord knows what C++ is going to do with it - declare your asm function as 'extern "C" myfunc', I think. The section(s) in the Friendly Manual mentions that you may wish to use a macro to do this conversion. Better yet (IMO) is to write it as "main" and "printf", and use the "--prefix _ " and/or "--postfix _" command line options to put the underscores where your compiler expects. Strictly speaking, I think this is a "linker requirement" - the compiler has to put the underscores the same places we do, but it amounts to the same thing...
Push the parameters (right to left, for C), and "call _foof" ("_foof" being my idea of how C would spell "foo"
). That's about it...
A couple of "clues"... "printf" always expects floats to be double precision (8 bytes, 64 bits), and "printf" doesn't print anything until the buffer is flushed.
What part(s) are you having trouble with?
Best,
Frank