News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

masm64 development

Started by Siekmanski, October 29, 2016, 06:55:08 PM

Previous topic - Next topic

Siekmanski

I knew this day would come, finally I joined the masm64 development scene.  :biggrin:
Because I didn't want to install visual studio 2015, I stripped the assembler, linker etc. from the vs2015.com_enu.iso.
The missing .dll's I got from vc_redist.x64.exe

After setting up the RadASM editor for masm64 I noticed that polink.exe created smaller exe's than link.exe.
Are there some things to be aware of choosing between them ?
Creative coders use backward thinking techniques as a strategy.

Mikl__

Hi, Siekmanski!
QuoteI didn't want to install visual studio 2015, I stripped the assembler, linker etc. from the vs2015.com_enu.iso.
The missing .dll's I got from vc_redist.x64.exe
After setting up the RadASM editor for masm64
Can you tell step by step what you do for it?
What is version of the polink.exe that you used?
If you will use the stub-file of your own production then minimal size of DOS header that can attach the polink.exe is 64 bytes
Use the option \STUB:stubby.exe
There is example of my stubby.exe
00: 4D 5A 90 00-03 00 00 00-04 00 00 00-FF FF 00 00
10: B8 00 00 00-00 00 00 00-40 00 00 00-00 00 00 00
20: 00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00
30: 00 00 00 00-00 00 00 00-00 00 00 00-40 00 00 00

jj2007

#2
You can perfectly write 64-bit code with HJWasm or AsmC and polink (from the Masm32 SDK) alone. For example, in RichMasm, menu File/New Masm source, "Dual 32/64 bit console/GUI templates that compile both as 64 and 32-bit applications" is a simple Window that builds fine with all our assemblers and polink (btw also as 32-bit). It does build also with link.exe version 10, but it will crash with the wrong options, see reply #5 below.

There is also the crippleware thread; the biggest problem imho is that we now have, thanks to Hutch, a fairly complete 64-bit SDK, with the only caveat that it will work only for Microsoft's crippleware assembler, because the others will choke on things like .if eax{=eax.

In contrast, RichMasm uses the Masm32 includes to produce a set of macros and includes (JBasic.inc) that work perfectly for both 32- and 64-bit code. When used with HJWasm/AsmC, you have the usual high level stuff, .if / .else /.endif with standard .if eax>=edx syntax etc., when used with ML64, you need jxx label instead, which is fine for hello world proggies imho but a PITA for real projects.

JBasic.inc features jinvoke, an invoke substitute that does check your parameter list and will choke if you provide CreateWindowEx with ten instead of eleven parameters. However, it has only limited macro support (Switch_, Print, Input, Chr$, Str$, Hex$, Val, MsgBox, ...). On the bright side, it does have a powerful debug macro, see deb.

Siekmanski

Polink.exe is from the MASM64 package from Hutch (Pelles Linker, Version 8.00.2)
Link.exe is from Microsoft (R) Incremental Linker Version 14.00.23026.0

Used the "template" example from the MASM64 package.

linked with Polink 6.656 bytes (makeit.bat -> Polink.exe /SUBSYSTEM:WINDOWS /ENTRY:entry_point /LARGEADDRESSAWARE)
linked with Link   8.704 bytes (msmake.bat -> Link.exe /SUBSYSTEM:WINDOWS /ENTRY:entry_point /LARGEADDRESSAWARE)
Creative coders use backward thinking techniques as a strategy.

Siekmanski

I have to do some more reading about 64-bit coding to catch up with you guys...
Creative coders use backward thinking techniques as a strategy.

jj2007

One odd thing I have discovered right now:
exe size for JBasic GUI template
5632 linkv10 with /MERGE:.rdata=.data
4608 linkv10 without merge options

4608 polink with /MERGE:.rdata=.data
5632 polink without merge options

5632 linkv10 with /MERGE:.data=.rdata, crashes
4608 polink with /MERGE:.data=.rdata, works fine


Sizes are bigger if you add e.g. align:16 as suggested by Mikl__ below ::)

The 4608 bytes are for an application with an icon, a menu and and an edit control. Built as 32-bit code, it will have 4096 bytes.

Mikl__

If you will use Polink.exe option /ALIGN:number (Specifies the alignment of each section.) where nuber is 2N then your program will tiny size
if number less 16 then POLINK: fatal error: /ALIGN value less then section alignment (16) if you wont section alignment < 16 then then you will processe polink by any binary editor, for polink ver 8 is located here:
40FB44: cmp ecx,[edx+18h]
40FB47: jge .40FB5C    jge --> jmp

hutch--

Marinus,

POLINK delivers slightly smaller executables and is a very good up to date linker and about the only problem I have seen is Avast AV does not properly understand its exe header. Microsoft LINK works fine and on larger sized exe/DLL files it does not matter. I know the Watcom clone folks are not happy about what can be done in ML64 but it seems with enough massaging it can be made to behave and it is easily powerful enough to write /LARGEADDRESSAWARE 64 bit code.

The project that I am working on is purely 64 bit, MASM32 does 32 bit fine, the 64 bit project is not cluttered with left over from 16 and 32 bit code and in my case a chance do do a number of things differently than the 1998 design that is implicit in MASM32. The other thing is you will quickly get used to not having to bother with prototypes and this saves you a lot of messing around during development.

As far as using small alignments, I have done one in the example code but I would not trust non standard aligned headers as you invite problems from both AV scanners and the OS.

TWell

#8
@jj2007
polink adds IMAGE_SCN_MEM_WRITE to .rdata and MS link don't, so globals are read-only ?

command file for VS2015_COM_ENU DVD ml64 version 12
EXPAND D:\packages\vc_compilerCore86\vc_CompilerCore86.cab /f:WinC_compiler_x86_amd64_ml64.exe_F .
REN WinC_compiler_x86_amd64_ml64.exe_F ml64.exe
EXPAND D:\packages\vc_compilerCore86\vc_CompilerCore86.cab /f:WinC_compiler_x86_amd64_link.exe_F .
REN WinC_compiler_x86_amd64_link.exe_F link.exe
EXPAND D:\packages\vc_compilerCore86\vc_CompilerCore86.cab /f:WinC_compiler_x86_mspdb120.dll_F .
REN WinC_compiler_x86_mspdb120.dll_F mspdb120.dll
pause

Siekmanski

Thank you guys,
It's an issue of difference in section alignment if I understand it correctly ?
For now I'll be using link.exe to please the viruskillers.  :biggrin:

TWell,
I've got it all up and running with these files,

vs2015.com_enu.iso\packages\VisualC_D14\VC_Tools.X64.Nat\cab1.cab

link.exe_G_zu.0MYf5KXFu3YylVhqKShrCc_x86
link.exe.config_TKsDdjbkv28UzbctqFbVN12pDnU_x86
ml64.exe__KsGyXB1mrE_Ah3fibPFNGDezSo_x86
Creative coders use backward thinking techniques as a strategy.

hutch--

You will need to hook RC.EXE as well although Pelle's PORC works just as well.

Siekmanski

Quote from: hutch-- on October 29, 2016, 09:45:02 PM
You will need to hook RC.EXE as well although Pelle's PORC works just as well.

Yes, I've got all the other files,
RC.exe
RCDLL.DLL
cvtres.exe
dumpbin.exe
editbin.exe

Ready to do some serious 64-bit coding.  :t
Did some tests, and it's working like a charm.  :biggrin:
Creative coders use backward thinking techniques as a strategy.

Mikl__

for normal work of ml64.exe will require yet files
  • msobj80.dll
  • mspdb80.dll
  • msvcp80.dll
  • msvcp90.dll
  • msvcr80.dll
  • msvcr90.dll

Siekmanski

Hi Mikl__,

Yes, already downloaded "vc_redist.x64.exe" for all the .dll's  :t
Creative coders use backward thinking techniques as a strategy.

TWell

#14
Minimum set for Win8.1 x64EXPAND D:\packages\VisualC_D14\VC_CRT.Redist.X64\cab1.cab /f:msvcp140.dll_ifHt4HeXyMwkX_p0puveXbCqAsQ_x86 .
REN msvcp140.dll_ifHt4HeXyMwkX_p0puveXbCqAsQ_x86 msvcp140.dll
EXPAND D:\packages\VisualC_D14\VC_CRT.Redist.X64\cab1.cab /f:vcruntime140.dll_SHB7a61JhWOdG1TrxpyIJuf0GXg_x86 .
REN vcruntime140.dll_SHB7a61JhWOdG1TrxpyIJuf0GXg_x86 vcruntime140.dll
EXPAND D:\packages\VisualC_D14\VC_Tools.X64.Base\cab1.cab /f:mspdbcore.dll_sJxy9D0nQBVeYc4iMwrqKhkZG74_x86 .
REN mspdbcore.dll_sJxy9D0nQBVeYc4iMwrqKhkZG74_x86 mspdbcore.dll
EXPAND D:\packages\VisualC_D14\VC_Tools.X64.Nat\cab1.cab /f:link.exe_G_zu.0MYf5KXFu3YylVhqKShrCc_x86 .
REN link.exe_G_zu.0MYf5KXFu3YylVhqKShrCc_x86 link.exe
EXPAND D:\packages\VisualC_D14\VC_Tools.X64.Nat\cab1.cab /f:ml64.exe__KsGyXB1mrE_Ah3fibPFNGDezSo_x86 .
REN ml64.exe__KsGyXB1mrE_Ah3fibPFNGDezSo_x86 ml64.exe
additional
EXPAND D:\packages\VisualC_D14\VC_Tools.X64.Base\cab1.cab /f:cvtres.exe_NN4iYBvT1dGJxNbMkWZ_F_RTlUc_x86 .
REN cvtres.exe_NN4iYBvT1dGJxNbMkWZ_F_RTlUc_x86 cvtres.exe
EXPAND D:\packages\Windows_SDK\69661e20556b3ca9456b946c2c881ddd.cab /f:fileb0feb18810072348bb0a472f8ca86e6 .
REN fileb0feb18810072348bb0a472f8ca86e6 rc.exe
EXPAND D:\packages\Windows_SDK\69661e20556b3ca9456b946c2c881ddd.cab /f:fila92f5991787067245feba6d4e4750171 .
REN fila92f5991787067245feba6d4e4750171 rcdll.dll