Re: [AD] 3.9.31 breaks MSVC 4

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Isaac Cruz <icruzbal@xxxxxxxxxx> writes:
>> Eventually I want to move all the MSVC asm into external GNU format
>> files, which is needed so that a native Mingw32 build can share it.
> 
> I had thought of this, but there are some problems:
> How to call DirectX from .s files?

Do you need to? At least judging from what of your code I've seen, surely 
the update_window_32_to_16() function could stay in C for the DirectX 
calls (which are all the init and cleanup code), and then just call an 
asm function for doing the body of the copy? It looks like everything 
inside your asm{} block is very clean code that would convert quite 
easily...

> How to call a function of a .s from a C file?

Allegro defines some macros to do that portably across different 
compilers. Basically you include "asmdefs.inc" in the .s file, then use 
FUNC() to declare your function, and ARG1, ARG2, etc, to pull arguments 
off the stack. Eg:

   int add(int a, int b)
   {
      return a+b;
   }

would be written as:

   FUNC(add)
      # standard stack frame entry
      pushl %ebp
      movl %esp, %ebp

      # here push ebx, esi, or edi if you clobber them
      # (calling conventions don't require storing eax, ecx, or edx)

      movl ARG1, %eax
      addl ARG2, %eax

      # pop ebx, esi, or edi if you pushed them before

      # standard stack frame exit
      movl %ebp, %esp
      popl %ebp
      ret

> How to use local data inside a function in asm (an easier method than 
> sub esp, x)? 

You have to end up doing it that way, but you just need one subtract from 
esp in the init code to allocate space, and then you can use #define to 
name all your local variables. The code in src/i386/sprite.inc is a good 
example: S_TGAP, S_LGAP, etc, are all allocated on the stack during 
START_SPRITE_DRAW().

> If these problems have solutions, I will move my MMX functions to a .s 
> file

I'd be happy to do that for you if you don't know or want to learn AT&T 
asm syntax: it's an easy process to convert once you are used to it, and 
I've had plenty of practice :-) So it would only take me a few minutes to 
adjust even if you write the code in MSVC inline format.

Are you happy with this change in principle, though? It does make the asm 
code harder for you to edit if you aren't used to AT&T syntax, but on the 
other hand we do need it at some point for the Mingw32 build, and IMHO a 
total conversion would be simpler than maintaining two copies of the same 
code, or having to provide a C fallback for the Mingw32 version...



-- 
Shawn Hargreaves - shawn@xxxxxxxxxx - http://www.talula.demon.co.uk/
"A binary is barely software: it's more like hardware on a floppy disk."



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/