Re: [AD] 3.9.31 breaks MSVC 4 |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Isaac Cruz <icruzbal@xxxxxxxxxx> writes:
> OK, I have started moving my code to a -s file. I have a little question
> about accessing members of a structure. Example: to access lpSurface
> member of DDSURFACEDESC, I have done this:
>
> movl ARG1, %eax /* eax = &src_desc (ARG1) */
> movl 36(%eax), %eax /* eax = src_desc.lpSurface */
>
> is it right?
That's fine (assuming that 36 is the right offset, of course :-)
To make that sort of code a bit more readable, you can write at the top
of the file:
#define lpSurface 36
and then:
movl lpSurface(%eax), %eax
Or if you want to go for the ultimate in automation, edit
src/i386/asmdef.c, and add a line to print out this offset, eg:
fprintf(f, "#define lpSurface %d\n", (int)offsetof(DDSURFACEDESC, lpSurface));
This way the define automatically propagates from the C compiler (which
obviously knows the offset), through to asmdef.exe, which then generates
asmdef.inc, which is included by the asm source files.
There probably isn't much point doing this for DDraw structures, as those
aren't ever going to change around, but it is important if you want to
access fields from Allegro structures like the BITMAP, to make sure the
asm code stays in sync when new fields are added.
--
Shawn Hargreaves - shawn@xxxxxxxxxx - http://www.talula.demon.co.uk/
"A binary is barely software: it's more like hardware on a floppy disk."