Advertisement
_takumi

7funcs.s

Nov 26th, 2022
1,442
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     .file   "7.c"
  2.     .text
  3.     .globl  f
  4.     .type   f, @function
  5. f:
  6. .LFB5:
  7.     .cfi_startproc
  8.     pushq   %rbp
  9.     .cfi_def_cfa_offset 16
  10.     .cfi_offset 6, -16
  11.     movq    %rsp, %rbp
  12.     .cfi_def_cfa_register 6
  13.     movsd   %xmm0, -8(%rbp)     #a
  14.     movsd   %xmm1, -16(%rbp)    #b
  15.     movsd   %xmm2, -24(%rbp)    #x
  16.     movsd   -16(%rbp), %xmm0
  17.     mulsd   -24(%rbp), %xmm0
  18.     mulsd   -24(%rbp), %xmm0
  19.     mulsd   -24(%rbp), %xmm0
  20.     mulsd   -24(%rbp), %xmm0
  21.     addsd   -8(%rbp), %xmm0
  22.     popq    %rbp
  23.     .cfi_def_cfa 7, 8
  24.     ret
  25.     .cfi_endproc
  26. .LFE5:
  27.     .size   f, .-f
  28.     .globl  S
  29.     .type   S, @function
  30. S:
  31. .LFB6:
  32.     .cfi_startproc
  33.     pushq   %rbp
  34.     .cfi_def_cfa_offset 16
  35.     .cfi_offset 6, -16
  36.     movq    %rsp, %rbp
  37.     .cfi_def_cfa_register 6
  38.     subq    $64, %rsp
  39.     movsd   %xmm0, -40(%rbp)    #a
  40.     movsd   %xmm1, -48(%rbp)    #b
  41.     movl    %edi, -52(%rbp)     #A
  42.     movl    %esi, -56(%rbp)     #B
  43.     movl    $100000000, -20(%rbp)   # n
  44.     movl    -56(%rbp), %eax    
  45.     subl    -52(%rbp), %eax     #(B - A)
  46.     cvtsi2ss    %eax, %xmm0
  47.     cvtsi2ss    -20(%rbp), %xmm1
  48.     divss   %xmm1, %xmm0        #(B - A) / n
  49.     cvtss2sd    %xmm0, %xmm0
  50.     movsd   %xmm0, -8(%rbp)     #save h
  51.     pxor    %xmm0, %xmm0
  52.     movsd   %xmm0, -16(%rbp)    #sum
  53.     movl    $0, -24(%rbp)       #int i = 0
  54.     jmp .L4
  55. .L5:
  56.     cvtsi2sd    -52(%rbp), %xmm1 #A
  57.     cvtsi2sd    -24(%rbp), %xmm0 # h
  58.     mulsd   -8(%rbp), %xmm0     # i * h
  59.     addsd   %xmm1, %xmm0        #A + i * h
  60.     movsd   -48(%rbp), %xmm1    #A + i *h to f
  61.     movq    -40(%rbp), %rax     #a to f
  62.     movapd  %xmm0, %xmm2
  63.     movq    %rax, -64(%rbp)     #b to f
  64.     movsd   -64(%rbp), %xmm0
  65.     call    f
  66.     movapd  %xmm0, %xmm1
  67.     movsd   -16(%rbp), %xmm0
  68.     addsd   %xmm1, %xmm0
  69.     movsd   %xmm0, -16(%rbp)
  70.     addl    $1, -24(%rbp)
  71. .L4:
  72.     movl    -24(%rbp), %eax
  73.     cmpl    -20(%rbp), %eax
  74.     jl  .L5
  75.     movsd   -8(%rbp), %xmm0
  76.     mulsd   -16(%rbp), %xmm0    #return h * sum
  77.     leave
  78.     .cfi_def_cfa 7, 8
  79.     ret
  80.     .cfi_endproc
  81. .LFE6:
  82.     .size   S, .-S
  83.     .section    .rodata
  84.     .align 8
  85. .LC1:
  86.     .string "Incrorrect input, check README.md"
  87. .LC2:
  88.     .string "r"
  89. .LC3:
  90.     .string "w"
  91. .LC4:
  92.     .string "incorrect file"
  93. .LC5:
  94.     .string "%lf"
  95. .LC6:
  96.     .string "%d"
  97. .LC7:
  98.     .string "integral = %lf\n"
  99.     .text
  100.     .ident  "GCC: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0"
  101.     .section    .note.GNU-stack,"",@progbits
  102.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement