Assembly language > Assembly discussions
64 bit Poasm dialog box
Vortex:
Attached is a 64-bit Poasm dialog box example.
--- Code: ---; Source code assembled with Pelles Macro Assembler, Version 8.00.1
.model flat,fastcall
include ColorDlg.inc
.data
Resource db 'MYDIALOG',0
msg db 'Dialog box example',0
title1 db 'About',0
.data?
hBrush qword ?
.code
start PROC PARMAREA=5*QWORD
LOCAL hModule:QWORD
invoke GetModuleHandle,NULL
mov hModule,rax
invoke DialogBoxParam,hModule,ADDR Resource,NULL,ADDR DlgProc,NULL
invoke ExitProcess,rax
start ENDP
DlgProc PROC hWnd:QWORD,uMsg:QWORD,wParam:QWORD,lParam:QWORD PARMAREA=12*QWORD
LOCAL _hWnd:QWORD
mov _hWnd,rcx
.IF edx==WM_CTLCOLORDLG
invoke CreateSolidBrush,Blue
mov [rip+hBrush],rax
ret
.ELSEIF edx==WM_CLOSE
invoke SendMessage,rcx,WM_COMMAND,IDM_EXIT,0
.ELSEIF edx==WM_COMMAND
mov rax,r8
.IF r9==0
.IF ax==IDM_ABOUT
invoke MessageBox,NULL,ADDR msg,ADDR title1,MB_OK
.ELSEIF ax==IDM_EXIT
invoke DeleteObject,[rip+hBrush]
invoke EndDialog,_hWnd,NULL
.ENDIF
.ELSE
mov rdx,r8
shr edx,16
.IF dx==BN_CLICKED
.IF ax==IDC_ABOUT
invoke SendMessage,_hWnd,WM_COMMAND,IDM_ABOUT,0
.ELSEIF ax==IDC_EXIT
invoke SendMessage,_hWnd,WM_COMMAND,IDM_EXIT,0
.ENDIF
.ENDIF
.ENDIF
.ELSE
mov rax,FALSE
ret
.ENDIF
mov rax,TRUE
ret
DlgProc ENDP
END start
--- End code ---
Mikl___:
--- Code: ---invoke MessageBox,NULL,ADDR msg,ADDR title1,MB_OK
--- End code ---
in debugger
--- Code: ---mov r9,0
mov r8,offset title1
mov rdx,offset msg
mov rcx,0
call MessageBoxA
--- End code ---
although must be
--- Code: ---xor r9,r9
mov r8d,offset title1
mov edx,offset msg
xor ecx,ecx
call MessageBoxA
--- End code ---
there is inperfect solution in invoke macro
and why
--- Quote ---LOCAL _hWnd:QWORD
mov _hWnd,rcx
--- End quote ---
although must be
--- Quote ---mov hWnd,rcx
--- End quote ---
Vortex:
Hi Mikl,
Replacing :
--- Code: ---LOCAL _hWnd:QWORD
mov _hWnd,rcx
--- End code ---
with
--- Code: ---mov hWnd,rcx
--- End code ---
will not work in Poasm. Disassembling the object module, you get this listing :
--- Code: ---DlgProc PROC
sub rsp, 104 ; 0053 _ 48: 83. EC, 68
; Filling space: 3H
; Filler type: mov with same source and destination
; db 48H, 89H, 0C9H
ALIGN 2
cmp edx, 310 ; 005A _ 81. FA, 00000136
jnz ?_001 ; 0060 _ 75, 1D
mov rcx, 16711680 ; 0062 _ 48: C7. C1, 00FF0000
call CreateSolidBrush ; 0069 _ E8, 00000000(rel)
mov qword ptr [hBrush], rax ; 006E _ 48: 89. 05, 00000000(rel)
add rsp, 104 ; 0075 _ 48: 83. C4, 68
ret ; 0079 _ C3
--- End code ---
The stack organization of Poasm looks a bit problematic, this is why I prefer to create an additional local variable to preserve hWnd
xor r9,r9 is fine.
You can type mov rdx,offset msg instead of mov edx,offset msg This won't hurt the assembled code. Same for xor rcx,rcx replacing xor ex,ecx
Mikl___:
--- Quote ---Replacing :
--- Code: ---LOCAL _hWnd:QWORD
mov _hWnd,rcx
--- End code ---
with
--- Code: ---mov hWnd,rcx
--- End code ---
will not work in Poasm.
--- End quote ---
I checked it out before you ask a question -- but this is wrong -- and in MASM is working correctly
Vortex:
Hi Mikl,
It works correctly both in Masm and HJWasm. It's probably a Poasm specific bug. The only way is to create local variables to preserve the parameters of a procedure.
Navigation
[0] Message Index
[#] Next page
Go to full version