Not the best solution but the code below is working :
include \masm32\include\masm32rt.inc
include invoke.inc
.data
string db 'Sum = %u',13,10,0
.data?
.code
start:
_invoke CalcSum,1,3,5,7,9
invoke crt_printf,ADDR string,eax
_invoke CalcSum,2,4,6
invoke crt_printf,ADDR string,eax
invoke ExitProcess,0
CalcSum PROC
LOCAL argcnt:DWORD
mov ecx,DWORD PTR [ebp+8] ; get the number of parameters
; obtained by the _invoke macro
mov argcnt,ecx
xor eax,eax
lea edx,[ebp+12] ; get the address of the first
; argument
@@:
add eax,DWORD PTR [edx]
add edx,4
dec ecx
jnz @b
mov ecx,argcnt
inc ecx
shl ecx,2
leave
mov edx,DWORD PTR [esp] ; get the return address
add esp,ecx ; balance the stack
mov DWORD PTR [esp],edx
retn
CalcSum ENDP
END start