I use nasm and gcc so it possible to use a different assembler
and still link the c code. tasm for dos is easy to
pickup, tasm32 might be harder to find. You also need
to assemble to your compiler's object format I think. Nasm
supports a number of these ,-f elf is what I use on linux.
This should work on linux
Code:
/* t.h */
int f(int a, int b);
/* main.c */
#include <stdio.h>
#include "t.h"
int main(void)
{
printf("4 + 3 = %d\n", f(4, 3));
return 0;
}
/* t.asm */
section .text
global f
f:
push ebp
mov ebp, esp
mov eax, [ebp+8] ; eax = a
mov ecx, [ebp+12] ; ecx = b
add eax, ecx ; return in eax
.exit:
leave
ret