I used to post code that I had finished in this thread. Sadly most of the stuff I have done this semester is theoretical.
I'll just post this bit of x86 from a previous assignment. Had to write a function to calculate the bessel function of the first order iirc.
Code
bessel: frame z
uses ecx, ebx
mov ebx, [z]
mov ecx, 1
fst Q[x_val]; stores x for later use
.begin
push ebx
call exp;ToS = x^n
fst Q[t_i]; t_i = x^n
fld1
fld1
fadd ; ToS = 2, x^n
push ebx
call exp ; ToS = 2^n, x^n
push ebx
call fact ; eax = n!
mov [tmp_sto], eax
fild Q[tmp_sto]; ToS = n!, 2^n, x^n
fmul ; ToS = n! * 2^n, x^n
fdiv ; ToS = t0 case (x^n / (n! * 2^n))
fst Q[result]
fstp Q[t_i]; ToS = empty, result = t_i = t0
.loop
finit
fld Q[x_val]
fld Q[x_val]
fmul ; ToS = x^2
mov eax, 4
mov [tmp_sto], eax
fild Q[tmp_sto]; ToS = 4, x^2
mov [tmp_sto], ecx
fild Q[tmp_sto]; ToS = i, 4, x^2
fmul ; ToS = 4*i, x^2
mov [tmp_sto], ebx
fild Q[tmp_sto]; ToS = n, 4*i, x^2
mov [tmp_sto], ecx
fild Q[tmp_sto]; ToS = i, n, 4*i, x^2
fadd ; ToS = (n+i), 4*i, x^2
fmul ; ToS = (4*i)*(n+i), x^2
fdiv ; ToS = x^2 / (4*i*(n+i))
fld Q[t_i] ; ToS = t_(i-1), x^2 / (4*i*(n+i)))
fmul ; ToS = t_i
fchs ; ToS = -(t_i)
fst Q[t_i]
fld Q[result]
fadd ; ToS = current result
fstp Q[result]; ToS = empty
inc ecx
.check
fld Q[t_i]
fabs ; ToS = ABS(t_i)
fld Q[brk_pt]
fcomi st0, st1
jb .loop
.done
fld Q[result]
ret
endf
I
assembly. Even when I get really weird fucking errors.
This post was edited by Eep on Nov 18 2013 10:08pm