I'm assuming this is a homework assignment that requires you to use x87 FPU instructions. Alternatively you could be using SSE/SSE2 SIMD instructions to perform the addition.
C calling (cdecl) convention on Win32 requires single and double precision floats to be returned in ST(0) (register on top of the FPU stack). Since faddp adds two numbers and places the result in ST(0) means that we don't need any temporary variables to store the result. These lines can then be removed:
.data
res dq 0
and
fstp res ; pop sum from the stack and store it in res
When creating a procedure you should specify the size of the arguments being passed so that MASM knows exactly what size the operands are for operations. To ensure you are using double precision values mark the double arguments as REAL8 (8 byte REALS). You should also mark the PROC as using C calling convention with PROC C
so the stack and the arguments are properly set up and addressed. The procedure declaration should look like:
procSuma proc C num1:REAL8,num2:REAL8
The resulting code could look like:
.model flat, c
.code
procSuma proc C num1:REAL8,num2:REAL8
fld num1 ; load num1 and push it onto the fpu stack
fld num2 ; load num2 and push it onto the fpu stack
faddp ; pop two numbers, add them, push sum on the stack.
; result in st(0) (top of FPU stack)
; We return double values in st(0) so nothing to do
; since faddp put our result in st(0)
ret
procSuma endp
end
You could reduce the addition to a couple instructions by using FADD instead of FADDP:
fld num1 ; load num1 and push it onto the fpu stack
fadd num2 ; Add ST(0)(num1) to num2 and store result in ST(0).
; We return double values in st(0) so nothing to do
; since fadd put our result in st(0)