Mail Archives: djgpp/1996/06/16/18:09:07
Xref: | news2.mv.net comp.os.msdos.djgpp:5045
|
From: | Shawn Hargreaves <slh100 AT york DOT ac DOT uk>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Help new user with linking problems...
|
Date: | Sun, 16 Jun 1996 10:41:55 +0100
|
Organization: | The University of York, UK
|
Lines: | 32
|
Message-ID: | <Pine.SGI.3.91.960616102823.10098A-100000@sgi1.york.ac.uk>
|
NNTP-Posting-Host: | sgi1.york.ac.uk
|
Mime-Version: | 1.0
|
In-Reply-To: | <4pvael$dic@status.gen.nz>
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
On Sat, 15 Jun 1996, Bruce Foley wrote:
> I want to be able to write external assembler routines to supplement
> my main C program. With this in mind, I wrote a simple AT&T module
> and assembled it with "as", producing a .o object file.
> By looking at other code, it appears that all I need to do is declare
> the routine as .global to make it accessable to a C program.
> I then wrote a simple C program that prototypes the external routine
> as extern, but I get an "undefined reference" error message in my C
> program when linking. What am I doing wrong?
Did you remember to prefix your asm function with an underbar? GCC
automatically does this to all C functions. In your .s file, put:
.globl _asm_routine
_asm_routine:
ret
And in your .c file, put:
extern void asm_routine();
asm_routine();
/*
* Shawn Hargreaves. Why is 'phonetic' spelt with a ph?
* Check out Allegro and FED on http://www.york.ac.uk/~slh100/
*/
- Raw text -