Advertisement
_takumi

main.asm

Nov 27th, 2022
966
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     .intel_syntax noprefix
  2.     .section    .rodata
  3.     .align 8
  4. .LC2:
  5.     .string "Incorrect input, check README.md"
  6. .LC3:
  7.     .string "r"
  8. .LC4:
  9.     .string "w"
  10. .LC5:
  11.     .string "Incorrect file"
  12. .LC6:
  13.     .string "%lf"
  14. .LC8:
  15.     .string "|x| must be less than 1"
  16. .LC10:
  17.     .string "Answer = %lf\n"
  18.     .text
  19.     .globl  main
  20.     .type   main, @function
  21. main:
  22.     push    rbp
  23.     mov rbp, rsp
  24.     sub rsp, 64
  25.     mov eax, edi # argc
  26.     mov rbx, rsi # argv
  27.     cmp rax, 3
  28.     je  .L6
  29.     lea rdi, .LC2[rip] # "Incorrect input, check README.md"
  30.     call    puts@PLT  
  31.     mov eax, 0
  32.     jmp .L13
  33. .L6:
  34.     mov rax, rbx
  35.     add rax, 8
  36.     mov rax, QWORD PTR [rax]
  37.     lea rsi, .LC3[rip] # "r"
  38.     mov rdi, rax       # argv[1]
  39.     call    fopen@PLT
  40.     mov r12, rax
  41.     mov rax, rbx
  42.     add rax, 16
  43.     mov rax, QWORD PTR [rax]
  44.     lea rsi, .LC4[rip] # "w"
  45.     mov rdi, rax       # argv[2]
  46.     call    fopen@PLT
  47.     mov r13, rax
  48.     cmp r12, 0
  49.     je  .L8
  50.     cmp r13, 0
  51.     jne .L9
  52. .L8:
  53.     lea rdi, .LC5[rip] # "Incorrect file\n"
  54.     call    puts@PLT
  55.     mov eax, 0
  56.     jmp .L13
  57. .L9:
  58.     lea rdx, -48[rbp]   # &x
  59.     mov rax, r12
  60.     lea rsi, .LC6[rip]  # "%lf"
  61.     mov rdi, rax        # input
  62.     mov eax, 0
  63.     call    __isoc99_fscanf@PLT
  64.     lea rdx, -40[rbp]   # &m
  65.     mov rax, r12
  66.     lea rsi, .LC6[rip]  # "%lf"
  67.     mov rdi, rax        # input
  68.     mov eax, 0
  69.     call    __isoc99_fscanf@PLT
  70.     movsd   xmm0, QWORD PTR -48[rbp]
  71.     movsd   xmm1, QWORD PTR .LC0[rip]
  72.     comisd  xmm0, xmm1
  73.     ja  .L10
  74.     movsd   xmm1, QWORD PTR -48[rbp]
  75.     movsd   xmm0, QWORD PTR .LC7[rip]
  76.     comisd  xmm0, xmm1
  77.     jbe .L15
  78. .L10:
  79.     lea rdi, .LC8[rip] # "|x| must be less than 1"
  80.     call    puts@PLT
  81.     mov eax, 0
  82.     jmp .L13
  83. .L15:
  84.     movsd   xmm0, QWORD PTR -40[rbp]
  85.     mov rax, QWORD PTR -48[rbp]
  86.     movsd   xmm1, QWORD PTR .LC9[rip]
  87.     movapd  xmm2, xmm1  # 50
  88.     movapd  xmm1, xmm0  # m
  89.     movq    xmm0, rax   # x
  90.     call    f
  91.     movq    rax, xmm0
  92.     mov r14, rax
  93.     mov rdx, r14
  94.     mov rax, r13
  95.     movq    xmm0, rdx       # res
  96.     lea rsi, .LC10[rip] # "Answer = %lf\n"
  97.     mov rdi, rax        # out
  98.     mov eax, 1
  99.     call    fprintf@PLT
  100.     mov rax, r12
  101.     mov rdi, rax  # input
  102.     call    fclose@PLT
  103.     mov rax, r13
  104.     mov rdi, rax  # out
  105.     call    fclose@PLT
  106.     mov eax, 0
  107. .L13:
  108.     leave
  109.     ret
  110.     .size   main, .-main
  111.     .section    .rodata
  112.     .align 8
  113. .LC0:
  114.     .long   0
  115.     .long   1072693248
  116.     .align 8
  117. .LC7:
  118.     .long   0
  119.     .long   -1074790400
  120.     .align 8
  121. .LC9:
  122.     .long   0
  123.     .long   1078525952
  124.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement