Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;coded by Roger Rotge
  2.  
  3. ;July 22, 2011
  4.  
  5. ;this is an assembly language version of the bubble sort routine
  6.  
  7.  
  8.  
  9. section         .text
  10.  
  11.                 global _sort
  12.  
  13.  
  14.  
  15. _sort:
  16.  
  17.         push    ebp
  18.  
  19.         mov     ebp, esp
  20.  
  21.         sub     esp, 16
  22.  
  23.         mov     dword [ebp-2], 0
  24.  
  25.         jmp     L2
  26.  
  27.  
  28.  
  29. L6:
  30.  
  31.         mov     dword [ebp-8],0
  32.  
  33.         jmp L3
  34.  
  35.  
  36.  
  37. L5:
  38.  
  39.         mov     eax, [ebp-8]
  40.  
  41.         sal     eax, 2
  42.  
  43.         add     eax, [ebp+8]
  44.  
  45.         mov     edx,  [eax]
  46.  
  47.         mov     eax,  [ebp-8]
  48.  
  49.         inc     eax
  50.  
  51.     sal     eax, 2
  52.  
  53.     add     eax,  [ebp+8]
  54.  
  55.     mov     eax,  [eax]
  56.  
  57.     cmp     edx, eax
  58.  
  59.     jle     L4
  60.  
  61.     mov     eax,  [ebp-8]
  62.  
  63.     sal     eax, 2
  64.  
  65.     add     eax,  [ebp+8]
  66.  
  67.     mov     eax,  [eax]
  68.  
  69.     mov      [ebp-12], eax
  70.  
  71.     mov     eax,  [ebp-8]
  72.  
  73.     sal     eax, 2
  74.  
  75.     add     eax,  [ebp+8]
  76.  
  77.     mov     edx,  [ebp-8]
  78.  
  79.     inc     edx
  80.  
  81.     sal     edx, 2
  82.  
  83.     add     edx,  [ebp+8]
  84.  
  85.     mov     edx,  [edx]
  86.  
  87.     mov      [eax], edx
  88.  
  89.     mov     eax,  [ebp-8]
  90.  
  91.     inc     eax
  92.  
  93.     sal     eax, 2
  94.  
  95.     add     eax,  [ebp+8]
  96.  
  97.     mov     edx,  [ebp-12]
  98.  
  99.     mov      [eax], edx
  100.  
  101. L4:
  102.     inc     dword [ebp-8]
  103.  
  104. L3:
  105.  
  106.     mov     eax,  [ebp+12]
  107.  
  108.     dec     eax
  109.  
  110.     sub     eax,  [ebp-4]
  111.  
  112.     cmp     eax,  [ebp-8]
  113.  
  114.     jg      L5
  115.  
  116.     inc     dword [ebp-4]
  117.  
  118. L2:
  119.  
  120.     mov     eax,  [ebp+12]
  121.  
  122.     dec     eax
  123.  
  124.     cmp     eax,  [ebp-4]
  125.  
  126.     jg      L6
  127.  
  128.     leave
  129.  
  130.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement