Mail Archives: djgpp/1996/06/26/09:49:02
Xref: | news2.mv.net comp.os.msdos.djgpp:5407
|
From: | Shawn Hargreaves <slh100 AT york DOT ac DOT uk>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Using Structures in Assembly
|
Date: | Wed, 26 Jun 1996 09:48:39 +0100
|
Organization: | The University of York, UK
|
Lines: | 31
|
Message-ID: | <Pine.SGI.3.91.960626092512.1959A-100000@tower.york.ac.uk>
|
NNTP-Posting-Host: | tower.york.ac.uk
|
Mime-Version: | 1.0
|
In-Reply-To: | <31D00541.3729@tiac.net>
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
On Tue, 25 Jun 1996, Nick Collier wrote:
> I am trying to convert some TASM code to AT+T syntax for use with djgpp.
> How can I use a structure that gets used by a function coded in
> assembly. Do need to use the offsets from the beginning of the structure
> or can I use .globl in someway to do this. Or are both these completely
> wrong. Please help.
I ran into this problem with Allegro, and came up with a solution which,
although not particularly elegant, seems to work ok.
I wrote a little C program which #includes all my header files, so it can
see the definitions of all my structures, and then writes a load of
offsets as #defines into a text file (eg. fprintf("#define MEMBER_NAME
%d\n", offsetof(structure, member)). If you compile your asm code with a
capital .S, so it gets run through the C preprocessor, you can #include
this file in the asm code and use these constants, eg. movl ptr, %esi ;
cmpl $0, MEMBER(%esi).
It's not very clean or simple, but you can set make up to rebuild the
offset header whenever your C headers change, and it makes it relatively
easy to share structures between C and asm without having two sets of
definitions that can get out of sync with each other...
/*
* Shawn Hargreaves. Why is 'phonetic' spelt with a ph?
* Check out Allegro and FED on http://www.york.ac.uk/~slh100/
*/
- Raw text -