Author Topic: 64 bit Poasm window example  (Read 7292 times)

Vortex

  • Member
  • *****
  • Posts: 2768
64 bit Poasm window example
« on: September 21, 2016, 05:31:50 AM »
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

  • Member
  • *****
  • Posts: 13871
  • Assembly is fun ;-)
    • MasmBasic
Re: 64 bit Poasm window example
« Reply #1 on: September 21, 2016, 07:21:54 AM »
Very nice, Erol :t

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10572
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: 64 bit Poasm window example
« Reply #2 on: September 21, 2016, 08:21:19 AM »
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 ?
« Last Edit: September 21, 2016, 12:07:38 PM by hutch-- »
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13871
  • Assembly is fun ;-)
    • MasmBasic
Re: 64 bit Poasm window example
« Reply #3 on: September 21, 2016, 04:26:24 PM »

TWell

  • Member
  • ****
  • Posts: 743
Re: 64 bit Poasm window example
« Reply #4 on: September 21, 2016, 04:51:42 PM »
use rip for LARGEADDRESSAWARE version.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10572
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: 64 bit Poasm window example
« Reply #5 on: September 21, 2016, 05:02:45 PM »
Thanks Tim, works fine here.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13871
  • Assembly is fun ;-)
    • MasmBasic
Re: 64 bit Poasm window example
« Reply #6 on: September 21, 2016, 06:27:55 PM »
use rip for LARGEADDRESSAWARE version.

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

TWell

  • Member
  • ****
  • Posts: 743
Re: 64 bit Poasm window example
« Reply #7 on: September 21, 2016, 06:43:55 PM »
It is in Vortex example.

Vortex

  • Member
  • *****
  • Posts: 2768
Re: 64 bit Poasm window example
« Reply #8 on: September 22, 2016, 04:52:30 AM »
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 :
Code: [Select]
.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

  • Member
  • *****
  • Posts: 2768
Re: 64 bit Poasm window example
« Reply #9 on: September 22, 2016, 05:10:52 AM »
I simplified the code to move only the two uninitialized variables to the stack :

Code: [Select]
.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--

  • Administrator
  • Member
  • ******
  • Posts: 10572
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: 64 bit Poasm window example
« Reply #10 on: September 22, 2016, 11:16:19 AM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

TWell

  • Member
  • ****
  • Posts: 743
Re: 64 bit Poasm window example
« Reply #11 on: September 22, 2016, 08:09:14 PM »
simple version for startup
Code: [Select]
WinMainCRTStartup 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