Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .global my_sin
- .intel_syntax noprefix
- .text
- my_sin:
- push ebp
- mov ebp, esp
- sub esp, 8
- push ebx
- push ecx
- movsd xmm0, [ebp+8] # x
- movsd xmm1, xmm0 # n = x
- mov ebx, 0
- cvtsi2sd xmm2, ebx # sum = 0.0
- cvtsi2sd xmm3, ebx # prev_sum = 0.0
- mov ecx, 1 # i
- mov ebx, -1
- cvtsi2sd xmm4, ebx #-1
- Loop:
- movsd xmm3, xmm2 # prev_sum = sum
- addsd xmm2, xmm1 # sum += n
- mulsd xmm1, xmm4 # n *= -1.0
- mulsd xmm1, xmm0 # n *= x
- mulsd xmm1, xmm0 # n *= x
- mov eax, 1
- mov ebx, 2
- mul ebx # eax *= 2
- mul ecx # eax *= i
- cvtsi2sd xmm5, eax
- divsd xmm1, xmm5 # n /= 2*i
- add eax, 1 # eax += 1
- cvtsi2sd xmm5, eax
- divsd xmm1, xmm5 # n /= (2*i + 1)
- add ecx, 1 # ++i
- comisd xmm2, xmm3 # cmp prev_sum and sum
- jne Loop
- movsd [ebp-8], xmm2
- fld qword ptr [ebp-8]
- pop ecx
- pop ebx
- leave
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement