delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/19/15:26:53

Message-Id: <199807191925.UAA09667@sable.ox.ac.uk>
Comments: Authenticated sender is <mert0407 AT sable DOT ox DOT ac DOT uk>
From: George Foot <george DOT foot AT merton DOT oxford DOT ac DOT uk>
To: Jorge Morgado <morgado AT mail DOT telepac DOT pt>
Date: Sun, 19 Jul 1998 20:24:52 +0000
MIME-Version: 1.0
Subject: Re: Assembler whit djgpp ?
Reply-to: george DOT foot AT merton DOT oxford DOT ac DOT uk
CC: djgpp AT delorie DOT com

On 18 Jul 98 at 16:02, Jorge Morgado wrote:

>     How do I work whit .s files?
>     What is the sintaxe, in particular how do I define a function in an .s
> file, them compile it whit as, and how can I call that function from my c
> file?

The syntax is the AT&T syntax, not Intel's syntax, so you might have 
to adapt yourself a bit.  See Brennan's guide to inline assembly for 
details:

    http://brennan.home.ml.org/djgpp/djgpp-asm.html

That document describes inline assembly though, which isn't what you're 
doing.  Only read the section on basic inline assembly; the extended 
syntax is only relevant to inline assembly, while most of the points 
in the basic section of that tutorial also apply to .S files.

If you want some more information specifically about writing .S
files, you might like to look at something I wrote a while ago. It's
information I gathered from some posts to this mailing list, from
looking through the djgpp and Allegro sources, from examining gcc's
output, and (to some extent) from reading documentation.  It
describes quite a few issues, including how to write functions, how
to access parameters, which registers you must preserve, how to set
up a stack frame and use local variable space, and how to add
debugging information so symify says something useful when your
program crashes inside your assembly language functions.

As I said above, though, it's based mainly on trial-and-error and 
observation of what other people (and the compiler) do.  YMMV.

The URL is:

    http://users.ox.ac.uk/~mert0407/asmfuncs.txt

I hope you find it useful.

-- 
george DOT foot AT merton DOT oxford DOT ac DOT uk

- Raw text -


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