64bit PROC syntax - How to build parameter 5,6, 7... on a PROC? ml64

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
ml64 assembles this proc without error message and creates EXE file:
testproc PROC FRAME : ExceptionHandler2 thisvar:QWORD<br/>
LOCAL testvar2:DWORD<br/>
push rbp<br/>
.PUSHREG rbp<br/>
mov rbp, rsp<br/>
.SETFRAME RBP, 0<br/>
sub rsp, 16
; 4byte needed for testvar2, but ensure 16byte boundary<br/>
.ALLOCSTACK 16<br/>
.ENDPROLOG
mov rcx, 0AABBCC11223344h<br/>
mov rbx, thisvar ; ml64 builds:
mov rbx, QWORD PTR [rbp+16]<br/>
add testvar2, ecx ; ml64 builds:
add DWORD PTR [rbp-4], ecx
add rsp, 16
pop rbp<br/>
ret
; ml64 does not write RET opcode here...<br/>
testproc ENDP
<br/>
main proc
sub rsp, 28h<br/>
and rsp, 0FFFFFFFFFFFFFF0Fh ; 16byte aligned<br/>
mov rcx, 1<br/>
mov rdx, 2<br/>
mov r8, 3<br/>
mov r9, 4<br/>
push 5<br/>
call testproc
...
main endp

http://msdn.microsoft.com/en-us/library/01d2az3t.aspx http://msdn.microsoft.com/en-us/library/01d2az3t.aspx PROC syntax allows PARAMETERS obviously also for ml64 (cause FRAME keyword is written there, which is not valid in 32bit
app)
The Calling Convention is rcx, rdx, r8, r9. On calling such a PROC, a stack frame of 20h
has to be ensured outside the PROC.
Normally the keyword LOCAL should give an error, cause obivously its not fully implemented.

<br/>
<br/>

View the full article
 
Back
Top