Guest User

Untitled

a guest
Jan 21st, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. .text
  2. .global mystrcmp
  3. mystrcmp:
  4. pushl %ebp
  5. movl %esp, %ebp
  6.  
  7. pushl %ebx
  8. pushl %esi
  9. pushl %edi
  10.  
  11. movl 8(%ebp), %ecx
  12. movl 12(%ebp), %edx
  13. movl $0, %esi
  14. for:
  15. movl (%edx,%esi,1), %eax //str1[i]
  16. movl (%ecx,%esi,1), %ebx //str2[i]
  17. cmpl %ebx, %eax
  18. jne compare // compare
  19. incl %esi
  20. cmpl $0, %eax
  21. jg for
  22. compare:
  23. cmpl %ebx, %eax
  24. jl less
  25. je equal
  26. jg greater
  27. less:
  28. movl $-1, %eax
  29. jmp end
  30. equal:
  31. movl $0, %eax
  32. jmp end
  33. greater:
  34. movl $1, %eax
  35. jmp end
  36. end:
  37. popl %edi
  38. popl %esi
  39. popl %ebx
  40.  
  41. popl %ebp
  42. ret
Add Comment
Please, Sign In to add comment