Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. int j;
  2. long swapped = 0;
  3. long sizeSORT = ptr2[0]-2;
  4. long temp = 0;
  5. long temp2 = 0;
  6. long indexSORT = 0;
  7. long int *base = &ptr[1];
  8.  
  9. __asm__ ("do2:\n\t"
  10. "movl $0, %0\n\t"
  11.  
  12. "for2:\n\t"
  13. " cmpl %6, %8\n\t" //Compares indexSORT and sizeSORT
  14. " je endFor2\n\t" //try jle later to see if it works
  15. " if2:\n\t"
  16. " movl (%4, %8, 4), %1\n\t"
  17. " movl 4(%4, %8, 4), %3\n\t"
  18. " cmpl %1, %3\n\t"
  19. " jge endIf2\n\t"
  20. " movl %1, 4(%4, %8, 4)\n\t"
  21. " movl %3, (%4, %8, 4)\n\t"
  22.  
  23. " movl $1, %0\n\t" //Sets swapped to True, thus breaks the do while-loop
  24. " endIf2:\n\t"
  25. " incl %2\n\t"
  26. " jmp for2\n\t"
  27.  
  28. "endFor2:\n\t"
  29. " if3:\n\t"
  30. " cmpl $0, %5\n\t"
  31. " je endFor3\n\t"
  32. " endIf3:\n\t"
  33. "movl $0, %0\n\t"
  34. "movl %6, %2\n\t" //Can I do this?, Load sizeSORT into indexSORT
  35. "for3:\n\t"
  36. " cmpl $0, %8\n\t"
  37. " je endFor3\n\t"
  38.  
  39. " if4:\n\t"
  40. " movl -4(%4, %8, 4), %1\n\t"
  41. " movl (%4, %8, 4), %3\n\t"
  42. " cmpl %1, %3\n\t"
  43. " jge endIf4\n\t"
  44. " movl %1, (%4, %8, 4)\n\t"
  45. " movl %3, -4(%4, %8, 4)\n\t"
  46.  
  47. " endIf4:\n\t"
  48. " decl %2\n\t"
  49. " jmp for3\n\t"
  50. "endFor3:\n\t"
  51.  
  52. // 0 1 2 3 4
  53. : "=r" (swapped), "=r" (temp), "=r" (indexSORT), "=r" (temp2), "+r" (base)
  54. // 5 6 7 8 9
  55. : "r" (swapped), "r" (sizeSORT), "r" (temp), "r" (indexSORT), "r" (base));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement