I have to evaluate this expression (k – y) / (b^z – (k + k^a))
This is my attempt to solve the problem
finit
mov ecx, 15
mov eax, 1
; Calcul b^z
fld b
fld z ;st(0)=z,st(1)=b,st(2)=k/y
fyl2x; st(0)=b*log*z
fld1
fscale; st(0)=2^[b*logz];st(1)=b*log*z
fld1
fld st(1)
fyl2x ; st(0)=[b*logz],st(1)=2^[b^logz],st(2)=b*logz
fsubr st(0),st(2);st(0)=blogz-[b^logz]
f2xm1
fld1
fadd
fstp qword ptr [putere]
finit
loop_k:
mov [k], eax
; Conversie k la float
fild dword ptr [k]
fstp qword ptr [k_float]
; Calcul (k - y)
fld qword ptr [k_float] ; Load k
fld qword ptr [y] ; Load y
fsub ; k - y
fstp qword ptr [numarator]
; Calcul k^a
fld k_float
fld a ;st(0)=z,st(1)=b,st(2)=k/y
fyl2x; st(0)=b*log*z
fld1
fscale; st(0)=2^[b*logz];st(1)=b*log*z
fld1
fld st(1)
fyl2x ; st(0)=[b*logz],st(1)=2^[b^logz],st(2)=b*logz
fsubr st(0),st(2);st(0)=blogz-[b^logz]
f2xm1
fld1
fadd
; Calcul k + k^a
fld qword ptr [k_float] ; Load k
fadd ; k + k^a
fstp qword ptr [sumk]
; Calcul b^z - (k + k^a)
fld qword ptr [putere]
fld qword ptr [sumk]
fsub ; b^z - (k + k^a)
; Calcul (k - y) / (b^z - (k + k^a))
fld qword ptr [numarator]
fdivr ; (k - y) / (b^z - (k + k^a))
fld qword ptr [sum]
fadd
fstp qword ptr [sum]
; Incrementare k și buclă
inc eax
loop loop_k
; Afișarea rezultatului
push dword ptr [sum+4]
push dword ptr [sum]
push offset result_msg
call printf
add esp, 12
I am not sure that the scaling is correct since I do not know where I can check. If you have a site that does that it would be very helpful.
But the main problem is that whatever values i put, the resultat that is printed is -1.#IND00.
When I do a single loop it prints a value, but not the correct value