News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

masm 10 vs 11

Started by bomz, January 22, 2013, 09:45:06 AM

Previous topic - Next topic

bomz

#105
Vortex
Thanks for link.
Quote@echo off
color 9F
if "%~1"=="" goto End
cd /d %~dp0
type %~nx1>nul
rem copy %~nx1 tmp.tmp
SetLocal EnableDelayedExpansion
echo LIBRARY %~n1>%~n1.def
echo ;__NO_NOISE__>%~n1.asm
echo .386>>%~n1.asm
echo .model flat,stdcall>>%~n1.asm
echo option casemap :none>>%~n1.asm
echo .code>>%~n1.asm
echo LibMain proc hInstDLL:DWORD, reason:DWORD, unused:DWORD>>%~n1.asm
echo mov eax, 1 >>%~n1.asm
echo ret>>%~n1.asm
echo LibMain endp>>%~n1.asm
for /f "skip=2 tokens=1,2,3,4 delims= " %%w in ('FIND /I "PROTO " %~nx1') do (
   if not %%w==LibMain (
   set procname=%%w
   set private=!procname:~0,1!
   if not !private!==^; (
   set private=
   if %%w==DllUnload set private= PRIVATE
   if %%w==DllInitialize set private= PRIVATE
   echo EXPORTS !procname!!private!>>%~n1.def
      set string=%%y
      set string1=%%z
      if not "%%y"=="STDCALL" (
      if not "%%y"=="C" (
      if not "%%y"=="" (
      set string=
      set string1=%%y
      )
      )
      )
      if not "!string1!"=="" (
      for /f "tokens=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26 delims=:" %%a in ("!string1!") do (
         if not "%%a"=="" set string=!string!param01:%%a
         if not "%%b"=="" set string=!string!param02:%%b
         if not "%%c"=="" set string=!string!param03:%%c
         if not "%%d"=="" set string=!string!param04:%%d
         if not "%%e"=="" set string=!string!param05:%%e
         if not "%%f"=="" set string=!string!param06:%%f
         if not "%%g"=="" set string=!string!param07:%%g
         if not "%%h"=="" set string=!string!param08:%%h
         if not "%%i"=="" set string=!string!param09:%%i
         if not "%%j"=="" set string=!string!param10:%%j
         if not "%%k"=="" set string=!string!param11:%%k
         if not "%%l"=="" set string=!string!param12:%%l
         if not "%%m"=="" set string=!string!param13:%%m
         if not "%%n"=="" set string=!string!param14:%%n
         if not "%%o"=="" set string=!string!param15:%%o
         if not "%%p"=="" set string=!string!param16:%%p
         if not "%%q"=="" set string=!string!param17:%%q
         if not "%%r"=="" set string=!string!param18:%%r
         if not "%%s"=="" set string=!string!param19:%%s
         if not "%%t"=="" set string=!string!param20:%%t
         if not "%%u"=="" set string=!string!param21:%%u
         if not "%%v"=="" set string=!string!param22:%%v
         if not "%%w"=="" set string=!string!param23:%%w
         if not "%%x"=="" set string=!string!param24:%%x
         if not "%%y"=="" set string=!string!param25:%%y
         if not "%%z"=="" set string=!string!param26:%%z
            )
         )
   echo !procname! proc !string!>>%~n1.asm
   echo ret>>%~n1.asm
   echo !procname! endp>>%~n1.asm
)
)
)
echo end LibMain>>%~n1.asm
\masm32\bin\ml.exe /c /coff /Cp %~n1.asm
\masm32\bin\Link.exe /noentry /subsystem:windows /dll /def:%~n1.def %~n1.obj
del %~n1.dll
del %~n1.obj
del %~n1.exp
del %~n1.def
del %~n1.asm
:End
pause

bomz

awk script, thanks for Alex_Piggy. works very very quickly

@echo off
color 9F
if "%~1"=="" exit /b
cd /d %~dp0
awk -v "NAME=%~n1" -f script.awk "%~1"
\masm32\bin\ml.exe /c /coff /Cp %~n1.asm
\masm32\bin\Link.exe /noentry /subsystem:windows /dll /def:%~n1.def %~n1.obj
del %~n1.dll
del %~n1.obj
del %~n1.exp
del %~n1.def
del %~n1.asm
pause


BEGIN {
deffile=NAME".def";
asmfile=NAME".asm";
print "LIBRARY "NAME>deffile;
print ";__NO_NOISE__\n.386\n.model flat,stdcall\noption casemap :none\n.code\nLibMain proc hInstDLL:DWORD, reason:DWORD, unused:DWORD\nmov eax, 1 \nret\nLibMain endp" > asmfile;
}
/PROTO/{
procname = $1;
if (procname==";;;;") next;
if (procname == "DllUnload" || procname == "DllInitialize") private= " PRIVATE";
if (procname != "LibMain") {
print "EXPORTS",procname""private>>deffile;
if ($3 != "STDCALL" && $3 != "C" && $3 != "" ) {string="";string1=$3;string_out="";} else {string=$3; string1=$4;string_out=string" ";}
i = split(string1,part,":");
for(j = 1; j < i; j++) string_out=sprintf(string_out "param%0.2d"":"part[j+1],j);
print procname " proc " string_out>>asmfile;
print "ret">>asmfile;
print procname " endp">>asmfile;
}
}
END {
print "end LibMain">>asmfile;
}

http://gnuwin32.sourceforge.net/packages/gawk.htm

Vortex

Hi bomz,

Supporting Windows with UNIX\Linux command-line tools is a nice idea.

bomz

It's not me idea. I use big forum with live bat theme where wide use sed and awk, I ask how better make bat file and Alex do me this script.
last version - ignore all string with first ; sign after tabs or spaces
BEGIN {
deffile=NAME".def";
asmfile=NAME".asm";
print "LIBRARY "NAME>deffile;
print ";__NO_NOISE__\n.386\n.model flat,stdcall\noption casemap :none\n.code\nLibMain proc hInstDLL:DWORD, reason:DWORD, unused:DWORD\nmov eax, 1 \nret\nLibMain endp" > asmfile;
}
/PROTO/{
procname = $1;
"if (procname ~ /^[\x20\x09]*;/ ) next;"
if (procname == "DllUnload" || procname == "DllInitialize") private= " PRIVATE";
if (procname != "LibMain") {
print "EXPORTS",procname""private>>deffile;
if ($3 != "STDCALL" && $3 != "C" && $3 != "" ) {string="";string1=$3;string_out="";} else {string=$3; string1=$4;string_out=string" ";}
i = split(string1,part,":");
for(j = 1; j < i; j++) string_out=sprintf(string_out "param%0.2d"":"part[j+1],j);
print procname " proc " string_out>>asmfile;
print "ret">>asmfile;
print procname " endp">>asmfile;
}
}
END {
print "end LibMain">>asmfile;
}

bomz

The main that script allow easy see what it do, and easy change it properties. the includes from kmdkit have another structure for ex

Vortex

Hi bomz,

I know that the idea exists since long time. I wanted to appreciate your efforts supporting the batch file with those external tools.

bomz



Alex interested in task with practical application, ask me a lot about libs (i don't know anything) and I think makes useful script for masm

bomz

masm32.lib create good with ml.exe 6 and ml.exe 10, but with ml.exe 8 (different version I try three) one mistake occurs during assembling fptoa.asm fptoa2.asm
call PowerOf10
string 204,206
this proc inside atofp.asm. How decide this?

I try invoke, includelib....

jj2007

Hi bomz,

You could be a bit more precise with your error messages ;-)

No problems with ML 6.14 and JWasm.

PowerOf10   proto   ; ML 8, 9: error A2006:undefined symbol : PowerOf10
fbstp [esp]   ; ML 8, 9, 10: error A2023:instruction operand must have size

bomz

Quote***********
ASCII build
***********

Assembling: fptoa.asm
fptoa.asm(207) : error A2006: undefined symbol : PowerOf10
Assembling: fptoa2.asm
fptoa2.asm(205) : error A2006: undefined symbol : PowerOf10
Assembling: frame3d.asm
Assembling: framegrp.asm

in this two codes atofp.asm atofp2.asm only
PowerOf10 proto
so stringscall PowerOf10 calls errors

proc PowerOf10 in file atofp.asm
PowerOf10 PROC public

    mov ecx, eax
    .IF (SDWORD PTR eax < 0)
neg eax
    .ENDIF

    fld1

    mov dl, al
    and edx, 0fh
    .IF (!ZERO?)
lea edx, [edx+edx*4]
fld ten_1[edx*2][-10]
fmulp st(1), st
    .ENDIF

    mov dl, al
    shr dl, 4
    and edx, 0fh
    .IF (!ZERO?)
lea edx, [edx+edx*4]
fld ten_16[edx*2][-10]
fmulp st(1), st
    .ENDIF

    mov dl, ah
    and edx, 1fh
    .IF (!ZERO?)
lea edx, [edx+edx*4]
fld ten_256[edx*2][-10]
fmulp st(1), st
    .ENDIF

    .IF (SDWORD PTR ecx < 0)
fdivp st(1), st
    .ELSE
fmulp st(1), st
    .ENDIF

    ret

PowerOf10 ENDP


I think that ml 6 and 8 during compiling only check function declaration (???), when full masm32.lib creates atofp.asm atofp2.asm call proc from atofp.asm

ml.exe 8.0.50727.100 free on microsoft site. I try it and 8.0.50727.762 and 8.0.50727.42 from 2005 studio

dedndave

you can ty this.....

in the files fptoa.asm and fptoa2.asm
.486
.model flat
      option casemap :none  ; case sensitive

        EXTERNDEF PowerOf10:NEAR


add an externdef

bomz

not public? what this declair in few word please. proto delete?

bomz

EXTERNDEF PowerOf10:NEAR
Quote***********
ASCII build
***********

Assembling: fptoa.asm
fptoa.asm(49) : error A2112: PROC and prototype calling conventions conflict
Assembling: fptoa2.asm
fptoa2.asm(49) : error A2112: PROC and prototype calling conventions conflict
Assembling: frame3d.asm
Assembling: framegrp.asm


EXTERNDEF PowerOf10:PUBLIC
Quote***********
ASCII build
***********

Assembling: fptoa.asm
fptoa.asm(11) : error A2008: syntax error : PUBLIC
fptoa.asm(208) : error A2006: undefined symbol : PowerOf10
Assembling: fptoa2.asm
fptoa2.asm(11) : error A2008: syntax error : PUBLIC
fptoa2.asm(206) : error A2006: undefined symbol : PowerOf10
Assembling: frame3d.asm
Assembling: framegrp.asm
EXTERNDEF PowerOf10:FAR
Quote***********
ASCII build
***********

Assembling: fptoa.asm
fptoa.asm(49) : error A2112: PROC and prototype calling conventions conflict
Assembling: fptoa2.asm
fptoa2.asm(49) : error A2112: PROC and prototype calling conventions conflict
Assembling: frame3d.asm
Assembling: framegrp.asm
EXTERNDEF PowerOf10:FAR
;PowerOf10 PROTO

Quote***********
ASCII build
***********

Assembling: fptoa.asm
fptoa.asm(208) : error A2004: symbol type conflict
Assembling: fptoa2.asm
fptoa2.asm(206) : error A2004: symbol type conflict
Assembling: frame3d.asm
Assembling: framegrp.asm

dedndave

try this
    EXTERNDEF PowerOf10

i didn't try it, so i can't say
maybe it needs a PROTO

scratch that - it already has a PROTO
maybe that's the problem   :P

bomz

EXTERNDEF PowerOf10:NEAR
;PowerOf10   proto

Quote***********
ASCII build
***********

Assembling: fptoa.asm
Assembling: fptoa2.asm
Assembling: frame3d.asm
Assembling: framegrp.asm

now need check it with ml10. may be you have little code to check this two proc calling?

with ml.exe10 - OK