delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/29/13:15:48

From: Andrew Crabtree <andrewc AT typhoon DOT rose DOT hp DOT com>
Message-Id: <199704291653.AA297362818@typhoon.rose.hp.com>
Subject: Re: nasm
To: p DOT steele AT ic DOT ac DOT uk (Peter Steele)
Date: Tue, 29 Apr 1997 9:53:37 PDT
Cc: djgpp AT delorie DOT com
In-Reply-To: <3365B836.146235B9@ic.ac.uk>; from "Peter Steele" at Apr 29, 97 9:58 am

> 
> Can some please tell me how to functions that have been compiled in asm
> language with nasm so I can use them in my c code.

If your using C then remember to prepend your functions with an
underscore

C printf becomes
ASM _printf

If you are using C++ then you will need to follow the name mangling 
rules (I think).

Arguments are passed to functions from left to right on the stack, so

in NASM (assuming int args)

[ESP+4] = first arg.
[ESP+8] = 2nd arg

on entry to your function.

Most return values go in EAX.  Floats probably go in ST(0) but I'm not sure.

Andrew






- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019