News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Multiple Versions

Started by V Coder, October 06, 2005, 05:23:11 AM

Previous topic - Next topic

V Coder

Greetings. I have a program written with parallel modules optimized for Pentium MMX, Pentium III, Pentium 4 and Athlon XP. It tests for processor and launches the appropriate main routine. If SSE2 then use Pentium 4 routine (will also run this routine on Pentium M and Athlon 64), else if SSE then if AMD then Athlon XP else use Pentium III, else if MMX then use Pentium MMX (will also run this routine on AMD K6-2, etc).

The other subroutines/routines, handlers in the program are identical. So, instead of having to maintain and complile 4 different programs when making a change for example to the save routine, I only need to make one change. Instead of four HLA programs about 30KB each compiling to 25KB exe, Now just one 68KB program compiling to 33KB. Good so far. That saves half the disk space.

Now this program is used in distributed computing, the manual way. I compile different versions to tackle different parts of the set. 15 in fact. But as you can imagine, each version differs only in about 10 instructions (mutiplied by four for the four different processor optimized modules). I have thus written each program as a 1K file with the 10 statements as a #macro, plus a single #include to include the main program, which expands the macro at the four points. This brings down the total source file size to 68+15 instead of 15*68. Executable sizes do not change. Disk space reduced by two thirds.

I batch the 15 different HLA files. Is there any way of writing instead a single HLA file with all the macros that results in the creation of all 15 files?

Thanks.

Randall Hyde

Quote from: V Coder on October 06, 2005, 05:23:11 AM
Greetings. I have a program written with parallel modules optimized for Pentium MMX, Pentium III, Pentium 4 and Athlon XP. It tests for processor and launches the appropriate main routine. If SSE2 then use Pentium 4 routine (will also run this routine on Pentium M and Athlon 64), else if SSE then if AMD then Athlon XP else use Pentium III, else if MMX then use Pentium MMX (will also run this routine on AMD K6-2, etc).

The other subroutines/routines, handlers in the program are identical. So, instead of having to maintain and complile 4 different programs when making a change for example to the save routine, I only need to make one change. Instead of four HLA programs about 30KB each compiling to 25KB exe, Now just one 68KB program compiling to 33KB. Good so far. That saves half the disk space.

Now this program is used in distributed computing, the manual way. I compile different versions to tackle different parts of the set. 15 in fact. But as you can imagine, each version differs only in about 10 instructions (mutiplied by four for the four different processor optimized modules). I have thus written each program as a 1K file with the 10 statements as a #macro, plus a single #include to include the main program, which expands the macro at the four points. This brings down the total source file size to 68+15 instead of 15*68. Executable sizes do not change. Disk space reduced by two thirds.

I batch the 15 different HLA files. Is there any way of writing instead a single HLA file with all the macros that results in the creation of all 15 files?

Thanks.

Have you considered using the #while or #for directives to make 15 copies of the program in one source file?
Cheers,
Randy Hyde

V Coder

Thanks for the response. I have read the material but am still a bit confused. Please provide a simple example of a source code that would compile to form two executable files from a single compilation statement?

Thanks.

Sevag.K

This is probably not what you want, but here's an example that produces 3 output files, each compiled a different way.

The idea behind it is to have only 1 source with conditional assembly producing several different executables.  But all of this could easily be done with a makefile so I don't know if it's worth anything.


program multiout;

begin multiout;

#if ( @defined ( buildit ) )
#system ( "hla multiout -d_ic1 -e:multiout01.exe")
#system ( "hla multiout -d_ic2 -e:multiout02.exe")
#endif

#if ( @defined ( _ic1 ))
mov (eax, ebx);
#elseif ( @defined ( _ic2))
mov (eax, ecx);
#else
mov (eax, edx);
#endif


end multiout;


to build:
hla multiout -dbuildit

If you have a lot of these, you can write macros to replace the #if (@defined ...


#macro ifp4;
#if ( @defined ( p4 ))
#endmacro
...

ifp4
mov (eax, ebx);
#endif


V Coder

#4
Thanks.

Just what I needed. It will be convoluted to expand it like that in one file with the #system idea, but I can use #if (@defined to decide which of my macros to use...

I will still need to use a batch file, but each line will define a different variable for selecting each macro.

Thanks again.

Update: I incorporated that idea to produce a single .hla file which creates the different .exe when compiled.
#if (@defined (_A))
  #macro check;
   ...
  #endmacro;
  ?fname:="_A";

#elseif (@defined (_B))
  #macro check;
   ...
  #endmacro;
  ?fname:="_B";

...
#else // Full
  #macro check;
   ...
  #endmacro;
  ?fname:="_Full";

#system ("hla XFull -d_A -e:X_A.exe X.rc comctl32.lib -w")
#system ("hla XFull -d_B -e:X_B.exelX.rc comctl32.lib -w")

#endif