A few problems there.
FMUL
expects floating point arguments, but you passlong
.FICOM
only sets FPU flags, you have to move them to CPU or useFCOMI
.JG
is checking wrong flags, you need to check the carry flag.- Your code unbalances the floating point stack.
Bonus: Since 5*PI/180 is constant, you can precalculate that.
You could use some code like this (adjust for your compiler's syntax, this is for gnu assembler):
.intel_syntax noprefix
.globl main
main:
sub esp, 16 # allocate space for i, sum and fmt
mov dword ptr [esp+4], -1 # i
fild dword ptr [limit] # limit
fldz # sum
1:
inc dword ptr [esp+4] # i += 1
fild dword ptr [esp+4] # i
fmul qword ptr [factor] # i * factor
fsin
faddp # add to sum
fcomi st, st(1) # check if below limit
jb 1b
fstp qword ptr [esp+8] # store on stack for printf
fstp st(0) # remove limit from fpu stack
mov dword ptr [esp], offset fmt
call printf
add esp, 16 # clean up stack
xor eax, eax # return value
ret
.data
factor: .double .08726646259971647884 # 5 * PI / 180
limit: .int 3
fmt: .string "i=%d sum=%g\n"