News:

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

Main Menu

Can one 64-bit source be assembled both with ML64 and HJWasm?

Started by jj2007, July 11, 2016, 11:32:28 PM

Previous topic - Next topic

jj2007

Now the good news is: Yes, this snippet assembles with both assembler families, provided you set the useML flag correctly:
option casemap:none
useML=0
ife useML
.x64 ; create 64 bit code; ML64 chokes
.model flat, stdcall ; 32 bit memory model (??????)
endif

ExitProcess PROTO :DWORD
includelib \masm64\lib\kernel32.lib

.code
start proc
  sub rsp, 28h
  mov rcx, 12345h
  call ExitProcess
start endp

end


The bad news is that all members of the Watcom family produce this linker error:

fatal error LNK1107: invalid or corrupt file: cannot read at 0xC1

Any clue why this happens, and how it can be avoided?

P.S.: If I use -win64 for JWasm, I get LINK : error LNK2001: unresolved external symbol start
Empty64.obj : error LNK2019: unresolved external symbol _ExitProcess@8 referenced in function _start@0


ML64 is tolerant, it just issues an ugly warning:MASM : warning A4018:invalid command-line option : -win64

Vortex

Hi Jochen,

Enabling the useML flag activates the STDCALL calling convention and you get decorated symbols. This the problem. \masm64\lib\kernel32.lib does not contain decorated symbols.


\PellesC\bin\podump.exe /SYMBOLS test.obj

Dump of test.obj

File type: OBJ

SYMBOL TABLE
0000 00000000 DEBUG  notype      filename     | .file
     test.asm
0002 00000000 SECT1  notype      static       | .text
     length of section   10, #relocations    1, #linenumbers    0
0004 00000000 SECT2  notype      static       | .data
     length of section    0, #relocations    0, #linenumbers    0
0006 00000000 SECT3  notype      static       | .drectve
     length of section   19, #relocations    0, #linenumbers    0
0008 00000000 UNDEF  notype ()   external     | _ExitProcess@8
0009 00000000 SECT1  notype ()   external     | _start@0


\PellesC\bin\podump.exe /EXPORTS \masm64\Lib\kernel32.lib | find "ExitProcess"

kernel32.dll: ExitProcess (ExitProcess)


_ExitProcess@8 is mangled while ExitProcess and the other symbols in the library are not decorated.

rrr314159

I assembled the same code with ML and JWasm for months, but by the time HJWasm existed I had stopped using ML. There's an example window Win64_2.asm at http://masm32.com/board/index.php?topic=3988.0. The zip includes makeJ.bat and makeM.bat. I had similar problems with include files as you're having, there was always a work-around, but finally I decided the best work-around was to stop using ML. Anyway I posted a few more examples back in those days, if interested.
I am NaN ;)

jj2007

Thanks, Vortex and rrr :icon14:

In the meantime, I got it working. The -win64 option for *jw* and AsmC did the trick.