I have just downloaded Pelle's latest version and have a very simple example that builds but does not run. The help file is very thin on the ground about building an EXE file with POASM and the only reference I can find to a 64 bit POASM question is the recommendation to use JWASM.
Has anyone succeeded in making a 64 bit EXE with POASM ?
This is the simple test piece.
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
includelib \pasm64\lib64\kernel32.lib
includelib \pasm64\lib64\user32.lib
MessageBoxA PROTO :QWORD,:QWORD,:QWORD,:QWORD
ExitProcess PROTO :QWORD
.data
align 16
tmsg db "MessageBox Text Message",0
align 16
titl db "Title",0
.code
align 16
start:
xor rax, rax
invoke MessageBoxA,rax,ADDR tmsg,ADDR titl,rax
mov rax, rax
rol rax, 64
invoke ExitProcess,0
end start
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
I have built it with this batch file.
@echo off
\pasm64\bin\poasm.exe /AAMD64 /V2 /Fllst.txt test.asm
\pasm64\bin\polink.exe /subsystem:WINDOWS /verbose test.obj
pause
Result is a 1.5k file but it does not run.
I have tried both the 64 bit libraries that come with Pelle's C and the VC2010 64 bit libraries but neither is better than the other.
Looks like you still have to allocate spill space (like ML64), it doesn't happen automatically.
start:
sub rsp, 28h
xor rax, rax
invoke MessageBoxA,rax,ADDR tmsg,ADDR titl,rax
On entry the stack is unaligned (xxx8) and we need a minimum of 4 qwords for parameters (spill).
Other API functions with more than 4 need more stack space, so you would adjust 28h as needed.
That did it, works fine. Gratsie !
In PellesC forum was this example too:
MessageBoxA PROTO :QWORD,:QWORD,:QWORD,:QWORD
MessageBox EQU <MessageBoxA>
ExitProcess PROTO :QWORD
.data
szMsg db 'Hello!',0
szApp db 'MsgBox',0
.code
WinMainCRTStartup proc PARMAREA=4*QWORD
invoke MessageBox,0,ADDR szMsg,ADDR szApp,0
invoke ExitProcess,0
WinMainCRTStartup endp
end
and this:.model flat,fastcall
INCLUDELIB kernel32.lib
INCLUDELIB user32.lib
WM_DESTROY equ 2
WM_CLOSE equ 10h
WM_INITDIALOG equ 110h
GetModuleHandleW PROTO :QWORD
ExitProcess PROTO :QWORD
DialogBoxIndirectParamW PROTO :QWORD,:QWORD,:QWORD,:QWORD,:QWORD
EndDialog PROTO :QWORD,:QWORD
PostQuitMessage PROTO :QWORD
MessageBoxW PROTO :QWORD,:QWORD,:QWORD,:QWORD
;----------------------
DlgProc PROTO :QWORD,:QWORD,:QWORD,:QWORD
WMInitdialog PROTO :QWORD
WMDestroy PROTO
WMClose PROTO :QWORD
.drectve segment
db '/subsystem:windows '
.drectve ends
.data
;align 4
DlgBox dw 1 ; dlgVer
dw 0FFFF ; signature
dd 0 ; helpID
dd 0 ; exStyle
dd 10CA0800h ; style
dw 0 ; cDlgItems
dw 0 ; x
dw 0 ; y
dw 200 ; cx
dw 100 ; cy
dw 0 ; empty menu
dw 0 ; empty windowClass
dw "Test",0 ; title POAsm
;dw 'T','e','s','t',0 ; title
sMsg dw "OK to close",0
;sMsg dw 'O','K',' ','t','o',' ','c','l','o','s','e',0
.code
; parameters RCX, RDX, R8 and R9
start PROC PARMAREA=5*QWORD
INVOKE GetModuleHandleW,0
mov rcx,rax
INVOKE DialogBoxIndirectParamW,rcx,ADDR DlgBox,0,ADDR DlgProc,0
INVOKE ExitProcess, rax
start ENDP
DlgProc PROC hWnd:QWORD,uMsg:QWORD,wParam:QWORD,lParam:QWORD PARMAREA=4*QWORD
;mov hWnd, rcx ; ?
mov QWORD PTR [rsp+30h],rcx
;mov uMsg, rdx
mov DWORD PTR [rsp+38h],edx
;mov wParam, r8
mov QWORD PTR [rsp+40h],r8
;mov lParam, r9
mov QWORD PTR [rsp+48h],r9
mov rax,uMsg
.if uMsg==WM_INITDIALOG
INVOKE WMInitdialog, hWnd
.elseif uMsg==WM_CLOSE
INVOKE WMClose, hWnd
.elseif uMsg==WM_DESTROY
INVOKE WMDestroy
.else
@@: xor rax,rax
.endif
ret
DlgProc ENDP
WMInitdialog PROC hWnd:QWORD PARMAREA=4*QWORD
;mov hWnd,rcx
;mov qword ptr [rsp+30h],rcx
mov rax,1
ret
WMInitdialog ENDP
WMDestroy PROC
INVOKE PostQuitMessage,0
mov rax,1
ret
WMDestroy ENDP
WMClose PROC hWnd:QWORD PARMAREA=4*QWORD
;mov hWnd,rcx
mov QWORD PTR [rsp+30h],rcx
INVOKE MessageBoxW,hWnd,ADDR sMsg, 0, 21h
.if rax == 1
;mov rcx,hWnd
mov rcx,QWORD PTR [rsp+30h]
INVOKE EndDialog,hWnd,0
.endif
ret
WMClose ENDP
END start