Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         .section        .rodata
  2. A:      .double 0.0, 0.0, 0.0, 0.0
  3. B:      .double 1e-8
  4. format: .string "%d\n"
  5.  
  6.         .text
  7.         .global tree_find
  8.  
  9. tree_find:
  10.         push    %ebp
  11.         movl    %esp, %ebp
  12.         push    %ebx
  13.         push    %esi
  14.         push    %edi
  15.  
  16.         movupd  A, %xmm0
  17.         movupd  A, %xmm1
  18.         movupd  A, %xmm2
  19.         movl    8(%ebp), %ebx ;null
  20.         movsd   12(%ebp), %xmm0
  21.         mov     20(%ebp), %edi
  22.  
  23.  
  24. loop:
  25.         movsd   (%ebx), %xmm2
  26.         comisd  %xmm2, %xmm0
  27.         jg      great
  28.         jmp     less
  29.  
  30. great:
  31.         movsd   %xmm0, %xmm1
  32.         subsd   (%ebx), %xmm1
  33.         comisd  B, %xmm1
  34.         jle     end
  35.         movl    12(%ebx), %ebx
  36.         cmpl    $0, %ebx
  37.         jz      bad_end
  38.         jmp     loop
  39.  
  40. less:
  41.         movsd   %xmm0, %xmm1
  42.         movsd   (%ebx), %xmm2
  43.         subsd   %xmm1, %xmm2
  44.         comisd  B, %xmm2
  45.         jle     end
  46.         movl    8(%ebx), %ebx
  47.         cmpl    $0, %ebx
  48.         jz      bad_end
  49.         jmp     loop
  50.  
  51. end:
  52.         cmpl    $0, %edi
  53.         jz      up
  54.         movl    16(%ebx), %esi
  55.         movl    %esi, (%edi)
  56. up:
  57.         popl    %edi
  58.         popl    %esi
  59.         popl    %ebx
  60.         movl    %ebp, %esp
  61.         popl    %ebp
  62.         movl    $1, %eax
  63.         ret
  64.  
  65. bad_end:
  66.         popl    %edi
  67.         popl    %esi
  68.         popl    %ebx
  69.         movl    %ebp, %esp
  70.         popl    %ebp
  71.         movl    $0, %eax
  72.         ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement