From: marcov@stack.nl   
      
   On 2005-04-08, Jim Leonard wrote:   
   >   
   > His loop unrolling example is fine. In fact, Macros are most useful if   
   > you do a lot of repetive things in loops and want to eliminate the   
   > overhead without writing very messy source. Macros are excellent for   
   > replacing things like this:   
      
   three examples:   
      
   1. inlining   
      
   > Procedure SwapB(var a,b:byte);   
   > var   
   > x:byte;   
   > begin   
   > x:=a;   
   > a:=b;   
   > b:=x;   
   > end;   
   >   
   > ...into this:   
   >   
   > MACRO SwapB (etc.)   
      
   solution: simply make sure you use a compiler than can inline.   
      
   2. 16-bit<>32-bit assembler   
   solution: don't use 16-bit assembler in this day and age. 16-bit programs   
   won't run on anything in 64-bit mode btw, so it slowly getting time to phase   
   them out.   
      
   > ...which lets me use "LOAD_32_BITS" without having to worry what target   
   > I was compiling for, and things like this:   
   >   
   > MyTable LABEL BYTE   
   > Value = StartVal   
   > NumEntries = EndVal - StartVal + 1   
   > REPT NumEntries   
   > db Value   
   > Value = Value + 1   
   > ENDM   
   >   
   > ...which automatically create a table, filled with values. If your   
   > macro compiler (which should really be called a macro pre-processor)   
   > can do these things, then I am sure you it will be very successful.   
      
   3. table generation   
      
   But do you require/like such thing to be in source? I typically have some   
   pascal .inc generators in such case and do something like this:   
      
   A. make builds generators   
   B. generators get called and create .incs   
   C. main program is compiled and includes the generated .inc   
      
   The advantage of this:   
   - no garbage in source.   
   - no other programs necessary except compiler and MAKE (which is quite   
    universal)   
   - full pascal compiler, dialect and performace available for the generation   
    (e.g. encryption dictionaries can be time intensive)   
   - make is usable for much more than this.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|