News:

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

Main Menu

64 bit Poasm window example

Started by Vortex, September 21, 2016, 05:31:50 AM

Previous topic - Next topic

Vortex

The attached project displays the classical blank window created with CreateWindowEx. The source code is based on the Win64_2 example supplied with HJWasm package.

jj2007


hutch--

#2
Compliments Erol, nice clean code. I moved it to the 64 bit section so more people can see it.

LATER : I just had a good read of Pelle's help file and POASM has some very good features, when I have enough ML64 stuff going I may end up doing some work in POASM as there are many useful things it can do.

LATER AGAIN : Erol, I have a question for you, I changed the linker option to /LARGEADDRESSAWARE without the :NO but it would not assemble. I there a way to get this option working so that you can allocate very large memory ?

jj2007

It is on by default, see http://forum.pellesc.de/index.php?topic=1355.0

TWell

use rip for LARGEADDRESSAWARE version.

hutch--


jj2007

Quote from: TWell on September 21, 2016, 04:51:42 PM
use rip for LARGEADDRESSAWARE version.

chokes on include SimpleWnd.inc (which is not in the archive)

TWell


Vortex

Hi Hutch,

I didn't knew the Relative Addressing notation and this is why I was not able to specify the LARGEADDRESSAWARE option. With thanks to TWell, the problem is solved easily. I managed to move the strings in the .data section to the stack to avoid the Relative Addressing but this is not a practical solution :
.model flat,fastcall

include SimpleWnd.inc

.code

start PROC PARMAREA=4*QWORD

LOCAL hInstance:QWORD
LOCAL CommandLine:QWORD
   
    invoke GetModuleHandleA,NULL
    mov    hInstance,rax
    invoke GetCommandLineA
    mov    CommandLine,rax

    mov    rax,'ssalCdW'
    push   rax
    mov    rax,'wodniW'
    push   rax
    lea    rax,[rsp+8]      ; the hPrevInst parameter used to store
                            ; the pointers to the strings in the stack
                           
    invoke WinMain,hInstance,rax,CommandLine,SW_SHOWDEFAULT
    add    rsp,2*8

    invoke ExitProcess,rax
.
.
.
start ENDP


Attached is this version of the code.

Vortex

I simplified the code to move only the two uninitialized variables to the stack :

.data

ClassName  db "WndClass",0
AppName    db "Window",0

.data?

hInstance   QWORD ?
CommandLine QWORD ?

.code

start PROC PARMAREA=4*QWORD

LOCAL hInstance:QWORD
LOCAL CommandLine:QWORD


The source code is assembled without using the Relative Addressing rip expression.

hutch--

Thanks Erol, this one works fine and with the /LARGEADDRESSAWARE its capable of allocating and accessing very large memory. I don't have the exact details but I know from the work on ML64 that some mnemonics cannot be used with /LARGEADDRESSAWARE as they required "fixups" from 32 bit addressing mode. I wonder if anyone can impose on Pelle to tweak this limitation as POASM is a good tool that has a very good feature set.

TWell

simple version for startupWinMainCRTStartup PROC PARMAREA=4*QWORD
    invoke GetModuleHandleA,NULL
    mov    rcx,rax
    invoke GetCommandLineA
    invoke WinMain,rcx,NULL,rax,SW_SHOWDEFAULT
    invoke ExitProcess,rax
WinMainCRTStartup ENDP
even that GetCommandLineA can be called where you really need it