News:

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

Main Menu

problem building a 64 bits executable

Started by TouEnMasm, December 12, 2014, 06:13:51 AM

Previous topic - Next topic

TouEnMasm

Hello,
I have made a set of header files for 64 bits
To test them,i use sample provided with jwasm Win64_8.asm
I have just replace the definitions by the include.
The problem is that he don't want to run.
I have made verifies on the prototypes,on the structure without finding any error.
Help !
Fa is a musical note to play with CL

TouEnMasm

found:
just use link without adding libraries

Quote
Link  /SUBSYSTEM:WINDOWS /DEBUG /debugtype:cv /OUT:%FILE%.exe *.obj %FILE%.bin

It seems also that the link option /NXCOMPAT:NO could help
Fa is a musical note to play with CL

Gunther

Hi ToutEnMasm,

you could use GoLink as an alternative, too. You can find usage examples here and here.

Gunther
You have to know the facts before you can distort them.

TouEnMasm

Thanks for answer
My first attempt was a little confused with header path (I have mixed 32 and 64 headers).
Fa is a musical note to play with CL

Gunther

Quote from: ToutEnMasm on December 12, 2014, 07:21:38 PM
My first attempt was a little confused with header path (I have mixed 32 and 64 headers).

That's indeed a bit confused and a bad idea. But you found the error and that counts.

Gunther
You have to know the facts before you can distort them.

TouEnMasm


I have re-posted the sample working (show a window and an image) using the include.
Now it's the messagebox who don't want to work,it's in the message directory.
This one seems to be more difficult to find.
Fa is a musical note to play with CL

qWord

You must align the stack on program entry.
I'm wondering, why this strange type XMASM? Types like HBITMAP, HINSTANCE, LPTSTR, HWND, HANDLE, ... should be usable?
MREAL macros - when you need floating point arithmetic while assembling!

TouEnMasm

Quote
XMASM?

XMASM typedef ptr    ;dword size in 32 bits,64 in X64

align the stack ?
Must be done on the window sample,and the messagebox don't work
Fa is a musical note to play with CL

qWord

Quote from: ToutEnMasm on December 13, 2014, 02:47:59 AM
XMASM typedef ptr    ;dword size in 32 bits,64 in X64
yes, but Windows's "natural" pointer- and handle types should have the same behavior.

Quote from: ToutEnMasm on December 13, 2014, 02:47:59 AMalign the stack ?
lookout for fastcall calling convention.
The stack is align to 8, when reaching the start-label, but it must be aligned to 16 when calling APIs. Also you must (at least) allocate the shadow space for RCX, RDX, r8 and r9:
start:
add rsp,-(8 + 4 * 8) ; - (align + shadow space)

MREAL macros - when you need floating point arithmetic while assembling!

TouEnMasm

Quote
start:
add rsp,-(8 + 4 * 8) ; - (align + shadow space)
:t
It wasn't in the samples of jwasm and solve the two problems

I don't see what you call  "natural" pointer,the one i need change is size just  adding .X64
This avoid to made header for 32 and header for 64
Fa is a musical note to play with CL

TouEnMasm


I try to do a simple thing:
Quote
mov rax,45612587h
Don't seem to be allowed ?????
Fa is a musical note to play with CL

habran


mov rax,45612587h
000000013F6D11C9 48 C7 C0 87 25 61 45 mov         rax,45612587h
Cod-Father

Gunther

Hi ToutEnMasm,

Quote from: ToutEnMasm on December 13, 2014, 06:35:17 PM
Quote
mov rax,45612587h
Don't seem to be allowed ?????

no, it's allowed, see also Habran's answer.

Gunther
You have to know the facts before you can distort them.

TouEnMasm

I have the sample without include wo works (b61710b4 48c7c087256145  mov     rax,45612587h)
Put it in the WndProc or after start,same result
The message sample work with this instruction and the header
But the one with include (who show the window and work) just failed to run ,what Happen ??????

The question seems to be,How allocate the stack for a PROC ?
I had try to increase at start,but it doesn't work.

Quote
WinMain proc FRAME hInst:XMASM, hPrevInst:XMASM, CmdLine:XMASM, CmdShow:DWORD

    LOCAL wc:WNDCLASSEX
    LOCAL msg:MSG
    LOCAL hwnd:XMASM
    ;---------- miss something here  --------
Fa is a musical note to play with CL

TWell

sub rsp, 4 * sizeof QWORD ?
4 is for shadow for first 4 parameters
Can't say how locals are handled by assembler.