www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/20/21:23:33

Date: Sat, 20 Sep 1997 13:24:35 +0000 ( )
From: "Gurunandan R. Bhat" <grbhat AT unigoa DOT ernet DOT in>
To: Rob Kramer <tapq4 AT central DOT susx DOT ac DOT uk>
Cc: djgpp AT delorie DOT com
Subject: Re: Calling C functions from assembly?
In-Reply-To: <5vtmka$9ma$1@infa.central.susx.ac.uk>
Message-Id: <Pine.LNX.3.91.970920131425.1831A-100000@aditya.unigoa.ernet.in>
Mime-Version: 1.0


On 19 Sep 1997, Rob Kramer wrote:

> 
> Hi All,
> 
> Can anyone tell me how I can call C functions from assembly code

You can refer to any external symbol (function name or variable name)
declared in a C file by prepending an underscore to the symbol and
declaring it as a global symbol. For example to call printf from within an
assembly routine declare it as so:

.globl _printf

and use it like so:

call _printf

> (or point me to an example)? 

lots, really. take any C code which calls an extern function and compile 
it with the -S option to see the assembly version of your code.

> I want to call a packet driver's software interrupt from
> within my assembly code, using the __dpmi_int() function. 

then 
.globl ___dpmi_int    #note 3 underscores
..
..
call ___dpmi_int

taking care to push arguments on the stack correctly
I must warn you however that I too am new to assembly 

Hope this helps

- Raw text -


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