I sort of experiemented with it on dos and got this to work.
I guess it works with the underscore since it's the coff object format I think.
For a test using the command line do
nasm -f coff tmp.asm
gcc -o prog main.c tmp.o
Code:
; tmp.asm
section .data
msg: db "Hello World!", 10, 0
section .text
extern _printf
global _print_hello
_print_hello:
push ebp
mov ebp, esp
push dword msg
call _printf
add esp, 4
leave
ret
Code:
/* tmp.h */
#ifndef TMP_H__
#define TMP_H__
#ifdef __cplusplus
extern "C" {
#endif
void print_hello(void);
#ifdef __cplusplus
}
#endif
Code:
/* main.c */
#include "tmp.h"
int main(void)
{
print_hello();
return 0;
}