fork download
  1. .intel_syntax noprefix
  2. .globl main
  3. main:
  4. sub esp, 16 # allocate space for i, sum and fmt
  5. mov dword ptr [esp+4], -1 # i
  6. fild dword ptr [limit] # limit
  7. fldz # sum
  8. 1:
  9. inc dword ptr [esp+4] # i += 1
  10. fild dword ptr [esp+4] # i
  11. fmul qword ptr [factor] # i * factor
  12. fsin
  13. faddp # add to sum
  14. fcomi st, st(1) # check if below limit
  15. jb 1b
  16. fstp qword ptr [esp+8] # store on stack for printf
  17. fstp st(0) # remove limit from fpu stack
  18. mov dword ptr [esp], offset fmt
  19. call printf
  20. add esp, 16 # clean up stack
  21. xor eax, eax # return value
  22. ret
  23.  
  24. .data
  25. factor: .double .08726646259971647884 # 5 * PI / 180
  26. limit: .int 3
  27. fmt: .string "i=%d sum=%g\n"
  28.  
Success #stdin #stdout 0.02s 1568KB
stdin
Standard input is empty
stdout
i=8 sum=3.00063