I have a program where I have to pass arguments to my functions through registers, stack, and public variables, and it seems that I lose data between them, because even after the first function I get 0.0 in "save" variable I think that I messed up something about adressing variables, because I am very new to MASM32 syntax, and it has some weird limitations. Though maybe I'm just trying to print it wrong
Main file
extern funcNum1:proto
extern funcNum2:proto
extern funcNum3:proto
public giveVal1, giveVal2
.data?
save dd ?
giveVal1 dd ?
giveVal2 dd ?
.data
array dq 12.0, 0.87, 9.7, 8.64
.code
start:
call main
inkey
exit
main proc
cls
print "List number 27, variant 6",10
lea ecx, array
lea edx, array+24
lea eax, save
call funcNum1
push eax
lea ecx, array+16
push ecx
call funcNum2
pop eax ; save
printf("Result is %f\n", save)
mov esi, dword ptr array
mov dword ptr giveVal2, esi
mov esi, dword ptr array+8
mov dword ptr giveVal1, esi
call funcNum3
fld giveVal1
fld qword ptr [edi]
fxch
fdiv
fstp save
printf("Result is %f\n", save)
ret
main endp
end start
File with functions
extrn giveVal1:DWORD, giveVal2:DWORD
public funcNum1, funcNum2, funcNum3
.data?
valuef dq ?
reg1 dq ?
reg2 dq ?
.data
value1 dq 53
value2 dq -2
value3 dq 4
.code ; code section
funcNum1 proc
fld qword ptr [ecx]
fld qword ptr [edx]
fdiv
fsin
fstp qword ptr [eax]
ret
funcNum1 endp
funcNum2 proc
pop edx
pop eax ; array[2]
pop ecx ; save
fild value1
fld qword ptr [ecx]
fsub
fstp valuef
finit
fild value2
fld qword ptr [eax]
fmul
fld valuef
fadd
fstp qword ptr [ecx]
finit
push ecx
push edx
ret
funcNum2 endp
funcNum3 proc
fld qword ptr [giveVal1]
fild qword ptr [value3]
fdiv
fld qword ptr [giveVal2]
fsub
fstp giveVal1
ret
funcNum3 endp
end