SHARE
TWEET

Untitled

a guest Oct 27th, 2019 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     .global my_sin
  2.     .intel_syntax noprefix
  3.     .text
  4.  
  5. my_sin:
  6.     push ebp
  7.     mov ebp, esp
  8.     sub esp, 8
  9.  
  10.     push ebx
  11.     push ecx
  12.  
  13.     movsd xmm0, [ebp+8] # x
  14.     movsd xmm1, xmm0 # n = x
  15.    
  16.     mov ebx, 0
  17.  
  18.     cvtsi2sd xmm2, ebx # sum = 0.0
  19.     cvtsi2sd xmm3, ebx # prev_sum = 0.0
  20.     mov ecx, 1 # i
  21.  
  22.     mov ebx, -1
  23.     cvtsi2sd xmm4, ebx #-1
  24.  
  25. Loop:
  26.     movsd xmm3, xmm2 # prev_sum = sum
  27.     addsd xmm2, xmm1 # sum += n
  28.  
  29.     mulsd xmm1, xmm4 # n *= -1.0
  30.     mulsd xmm1, xmm0 # n *= x
  31.     mulsd xmm1, xmm0 # n *= x
  32.  
  33.     mov eax, 1
  34.     mov ebx, 2
  35.     mul ebx # eax *= 2
  36.     mul ecx # eax *= i
  37.     cvtsi2sd xmm5, eax
  38.     divsd xmm1, xmm5 # n /= 2*i
  39.     add eax, 1 # eax += 1
  40.     cvtsi2sd xmm5, eax
  41.     divsd xmm1, xmm5  # n /= (2*i + 1)
  42.  
  43.     add ecx, 1 # ++i
  44.     comisd xmm2, xmm3 # cmp prev_sum and sum
  45.     jne Loop
  46.  
  47.     movsd [ebp-8], xmm2
  48.     fld qword ptr [ebp-8]
  49.  
  50.     pop ecx
  51.     pop ebx
  52.     leave
  53.  
  54.     ret
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top