Advertisement
Guest User

Untitled

a guest
Feb 5th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.        .text
  2.        .global         mystrcmp
  3.  
  4. mystrcmp:
  5.         pushl           %ebp
  6.         movl            %esp, %ebp
  7.  
  8.         pushl           %edi
  9.         pushl           %esi
  10.         pushl           %ebx
  11.         pushl           %ecx
  12.  
  13.         movl            8(%ebp), %edi
  14.         movl            12(%ebp), %esi
  15.         movzbl          (%edi), %ebx
  16.         movzbl          (%esi), %ecx
  17.  
  18.         cmpl            %ebx, %ecx
  19.         je              equal
  20.         jg              greater
  21.         jl              less
  22.  
  23. equal:
  24.         movl            $0, %eax
  25.         cmpl            %ebx, %eax
  26.         je              ending
  27.         incl            %edi
  28.         incl            %esi
  29.         movzbl          (%edi), %ebx
  30.         movzbl          (%esi), %ecx
  31.  
  32.         cmpl            %ebx, %ecx
  33.         je              equal
  34.         jg              greater
  35.         jl              less
  36.  
  37. greater:
  38.         movl            $1, %eax
  39.         jmp             ending
  40.  
  41. less:
  42.         movl            $-1, %eax
  43.         jmp             ending
  44.  
  45. ending:
  46.         popl            %ecx
  47.         popl            %ebx
  48.         popl            %esi
  49.         popl            %edi
  50.  
  51.         movl            %esp, %ebp
  52.         popl            %ebp
  53.         ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement