Advertisement
Guest User

Untitled

a guest
Mar 11th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .data
  2. printf_format:
  3.     .string "%lf\n"
  4.  
  5.     .text
  6.     .global myexpm2
  7.  
  8. // *r - 20
  9. // x - 16, 12
  10. myexpm2:
  11.     // стандартный пролог
  12.     pushl   %ebp // 4
  13.     pushl   %ebx // 0
  14.     movl    %esp, %ebp
  15.  
  16.     movl    16(%ebp), %eax
  17.     pushl   %eax
  18.     movl    12(%ebp), %eax
  19.     pushl   %eax
  20.  
  21.     movsd   (%esp), %xmm6
  22.     mulsd   %xmm6, %xmm6  
  23.     movl    $0, %ebx
  24.     cvtsi2sd    %ebx, %xmm0
  25.     subsd   %xmm6, %xmm0 // -x^2 = %xmm0
  26.  
  27.  
  28.     movl    $1, %ebx
  29.     cvtsi2sd    %ebx, %xmm5 //  слагаемое
  30.     cvtsi2sd    %ebx, %xmm3 //  ans в %xmm3
  31.     cvtsi2sd    %ebx, %xmm4
  32.  
  33. cycle:
  34.     movsd   %xmm4, %xmm3 // curr в %xmm4
  35.    
  36.     cvtsi2sd    %ebx, %xmm2
  37.  
  38.     mulsd   %xmm0, %xmm5
  39.     divsd   %xmm2, %xmm5
  40.  
  41.     addsd   %xmm5, %xmm4
  42.  
  43.     addl    $1, %ebx
  44.    
  45.     comisd  %xmm4, %xmm3
  46.     jnz cycle
  47.    
  48.     // возвращаем значение
  49.     movl    20(%ebp), %eax
  50.     movsd   %xmm4, (%eax)
  51.    
  52. ep: // стандартный эпилог
  53.     movl    %ebp, %esp
  54.     popl    %ebx
  55.     popl    %ebp
  56.     ret
  57.  
  58.     //sub   $8, %esp
  59.     //movsd %xmm5, (%esp)
  60.     //pushl $printf_format
  61.     //call  printf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement