News:

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

using masm32 lib

Started by Jimg, July 29, 2005, 03:33:21 PM

Previous topic - Next topic

ToutEnMasm

Hello,
I try to explain another time,
The macro it's an easy way for loading libraries and there Prototypes.
When there is only prototypes in the kernel32.inc, for example,the macro work well.
But the file masm32.inc have a macro in it,MakeIP,and ml have an internal error with it.
If we put other's macros in the include files join to the libraries,the same error occure.
The more simple macro is this one,that work very well.
                     ToutEnMasm


LIB MACRO nomsansext:VARARG
FOR nom,<nomsansext>
include \masm32\include\nom.inc
includelib \masm32\lib\nom.lib
ENDM
ENDM




MazeGen

Thanks ToutEnMasm, I got it finally :red

BTW, ML 8.00 beta2 contains the same bug:

Quote
Assembling: tmp.asm

MASM : fatal error A1016: Internal error
Microsoft (R) Macro Assembler Version 8.00.50215.44
Copyright (C) Microsoft Corporation.  All rights reserved.

It also prints nice crash dump...

Jimg

The internal assembly error is caused by using a for loop, and within that loop including a file that has a macro in it.  It has nothing to do with MakeIP itself, just the fact that it is a macro.  This is a bug in masm itself.  Moving MakeIP solves the problem for masm32.inc, but including another library with macros, for example debug, brings the problem right back.  Too bad we have to create our own loop to get around the problem.

Opps, previous answer while I was editing.

ToutEnMasm

Re,
You can send this internal error to microsoft.The beta version of ml (visual studio) have a special option to made It.
     ToutEnMasm

Jimg

You also get the same error using a while loop in place of the manual inc/test/goto in the new macro.

Jimg

This probably has something to do with this from the masm documentation:
QuoteThe assembler performs parameter substitution at each level of
     nesting. Therefore, you must add an extra ampersand before or
     after a macro parameter for each level of MACRO nesting or
     FOR/FORC/REPEAT/WHILE nesting.

Jimg

The new uselib macro could be cleaned up a bit though-

    uselibs MACRO args:VARARG
      LOCAL acnt,buffer,var,lbl,buf1
      acnt = argcount(args)
      var = 1
    :lbl
      buffer equ getarg(var,args)

      buf1 CATSTR <include \masm32\include\>,buffer,<.inc>
      buf1

      buf1 CATSTR <includelib \masm32\lib\>,buffer,<.lib>
      buf1

      var = var + 1
      IF var LE acnt
        goto lbl
      ENDIF
    ENDM


ToutEnMasm

re,
I try your macro

minus.asm(42) : fatal error A1000: cannot open file : \masm32\include\getarg(??0002,kernel32,gdi32,user32,Comctl32,masm32,comdlg32,shell32,oleaut32,ole32,msvcrt,imagehlp,perso32).inc

I try my best english,but I couldn't understand wat is an extra ampersand  ? (in the doc you copy)
                           ToutEnMasm






PBrennick

That was the problem with the first version from Hutch.  Did you do the change correctly?  Jimg's version works fine on my machine.

Make sure you have replaced your version of macro.asm with the one Hutch posted in this topic.  Just pasting Jimg's macro into the old macro.asm will not work.

hth,
Paul
The GeneSys Project is available from:
The Repository or My crappy website

Jimg

I'm probably wrong about the ampersand thing.  It seemed possible at the time, but perhaps not now.

Also, you did notice I changed the name of the macro in the one I posted (uselibs vs. uselib)?

And Macros.asm is required for both of these, also.

hutch--

Karel,

There is nothing wrong with the makeIP macro, its a side effect of using the "\" character in a path inside a FOR loop, thats why I changed the loop to a label with a goto instead.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ToutEnMasm

OK,
The last macros.asm (in the image of masm32) is needed.
uselib use two macros argcount and getarg  to replace the loop FOR ....
All is clear.
Now it's work,without internal error.
                                ToutEnMasm

Jimg

QuoteThere is nothing wrong with the makeIP macro, its a side effect of using the "\" character in a path inside a FOR loop, thats why I changed the loop to a label with a goto instead.
The original slash problem is easily fixed by putting in a double slash  (\\masm32\\include\\)  etc.

The real problem is still doing an include of a file inside a for loop where the the included file contains macros.

PBrennick

Jimg,
Could you please point me to the documentation that talks about the problem of running a macro from within a FOR loop?

Thank you in advance and thank you for your macro optimizations.
Paul
The GeneSys Project is available from:
The Repository or My crappy website

Jimg

Hi Paul-

Look in masm32.hlp, topic= Nested Macros

Here's another one for you:

We could also get rid of the CATSTRs by making our own getarg internally.  That way we can use the result directly-

    uselibs MACRO args:VARARG
      LOCAL acnt,buffer,var,lbl,cnt
      acnt = argcount(args)
      var = 1
    :lbl
      cnt = 0
      FOR arg, <args>
        cnt = cnt + 1
        IF cnt EQ var
          buffer TEXTEQU <arg>     ;; set "txt" to content of arg num
          EXITM
        ENDIF
      ENDM
      %include \\masm32\\include\\buffer.inc
      %includelib \\masm32\\lib\\buffer.lib
      var = var + 1
      IF var LE acnt
        goto lbl
      ENDIF
    ENDM