Advertisement
DMG

Sortiranje niza (BS)

DMG
Oct 30th, 2014
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Program za sortiranje niza
  2. # dmarjanovic
  3.  
  4. LENGTH = 15
  5. .section .data
  6.     array: .long 1, 7, 52, 14, 19, 3, 40, 32, 3, 111, 64, 70, 9, 7, 3
  7.  
  8. .section .text
  9. .globl main
  10.  
  11. main:
  12.     movl $LENGTH, %esi
  13.  
  14. for_1:
  15.     subl $2, %esi
  16.     cmpl $0, %esi
  17.     je end
  18.  
  19.     movl $0, %ebx
  20.     incl %esi
  21. for_2:
  22.     cmpl %esi, %ebx
  23.     je for_1
  24.  
  25.     movl array(,%ebx,4), %edx
  26.     incl %ebx
  27.  
  28.     cmpl array(,%ebx, 4), %edx
  29.     jle goto_for_2
  30.    
  31.     movl array(,%ebx, 4), %ecx
  32.     movl %edx, array(,%ebx, 4)
  33.     decl %ebx
  34.     movl %ecx, array(,%ebx, 4)
  35.     incl %ebx
  36.  
  37. goto_for_2:
  38.     jmp for_2
  39.  
  40.  
  41. end:
  42.     movl $1, %eax
  43.     int $0x80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement