In this brave new world of mixed hybrid calling conventions, here is another one to add to the collection.
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
; Pass procedure arguments in an array
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
include \masm32\include64\masm64rt.inc
.code
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
entry_point proc
LOCAL arr[16] :QWORD ; create a QWORD array on the stack
lea rcx, arr ; load its address into RCX
mov QWORD PTR [rcx], 1
mov QWORD PTR [rcx+8], 2
mov QWORD PTR [rcx+16], 3
mov QWORD PTR [rcx+24], 4
mov QWORD PTR [rcx+32], 5
mov QWORD PTR [rcx+40], 6
mov QWORD PTR [rcx+48], 7
mov QWORD PTR [rcx+56], 8
call arrtest ; call the arrtest proc with address in RCX
waitkey
invoke ExitProcess,0
ret
entry_point endp
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
arrtest proc parr:QWORD
LOCAL .r15 :QWORD
mov [rbp+16], rcx ; copy RCX into parr address
mov .r15, r15 ; preserve r15
mov r15, parr
conout str$(QWORD PTR [r15]),lf
conout str$(QWORD PTR [r15+8]),lf
conout str$(QWORD PTR [r15+16]),lf
conout str$(QWORD PTR [r15+24]),lf
conout str$(QWORD PTR [r15+32]),lf
conout str$(QWORD PTR [r15+40]),lf
conout str$(QWORD PTR [r15+48]),lf
conout str$(QWORD PTR [r15+56]),lf
mov r15, .r15 ; restore r15
ret
arrtest endp
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
end
Hmmm... where is the difference to passing a pointer to a STRUCT?
Or
;assume stack is para aligned
push 8
push 7
push 6
push 5
push 4
push 3
push 2
push 1
mov rcx,rsp
sub rsp,32 ;maybe not needed?
call arrtest
add rsp,32+8*8 ;or reuse
16 array slots but only 8 filled?
JJ,
> Hmmm... where is the difference to passing a pointer to a STRUCT?
Less typing. :P Each has its place but with a long list of identical items, an array is simpler.
:biggrin:
> 16 array slots but only 8 filled?
Alway allows room for more. :P
If you push the args you must correct the stack, either in the tail end of the called proc or after the procedure call. Writing to a RSP relative address does not have the problem and it allows for all integer data types from BYTE to QWORD.