Advertisement
DMG

Sortiranje niza 64-bit (BS)

DMG
Nov 16th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Program za sortiranje niza u dvostrukoj preciznosti
  2. # dmarjanovic
  3.  
  4. # Duzina je 7*2 (zbog dvostruke preciznosti)
  5. LENGTH = 14
  6. .section .data
  7.     array: .quad 132736784648734631, 24, 31, 132736784648734632, 43, 512, 342343254543646643, 625
  8.    
  9. .section .text
  10. .globl main
  11.  
  12. main:
  13.     movl $array, %eax
  14.     movl $LENGTH, %esi
  15.     subl $4, %esi
  16.    
  17.     movl $0, %ebp
  18.    
  19. for_1:
  20.     cmpl $0, %esi
  21.     je end
  22.    
  23.     addl $2, %esi
  24.    
  25.     for_2:
  26.         cmpl %ebp, %esi
  27.         je go_to_for_1
  28.        
  29.         # Uporedjuje array(ebp) i array(ebp+1)
  30.         # Prvo uporedjujemo vise bite
  31.        
  32.         movl 4(%eax,%ebp,4), %ecx
  33.         cmpl %ecx, 12(%eax,%ebp,4)
  34.         jl swap
  35.         jg go_to_for_2
  36.        
  37.         movl (%eax,%ebp,4), %ecx
  38.         cmpl %ecx, 8(%eax,%ebp,4)
  39.         jl swap
  40.        
  41.         go_to_for_2:
  42.             addl $2, %ebp
  43.             jmp for_2
  44.            
  45.         swap:
  46.             movl (%eax,%ebp,4), %ecx
  47.             movl 8(%eax,%ebp,4), %edx
  48.             movl %ecx, 8(%eax,%ebp,4)
  49.             movl %edx, (%eax,%ebp,4)
  50.            
  51.             movl 4(%eax,%ebp,4), %ecx
  52.             movl 12(%eax,%ebp,4), %edx
  53.             movl %ecx, 12(%eax,%ebp,4)
  54.             movl %edx, 4(%eax,%ebp,4)
  55.            
  56.             jmp go_to_for_2
  57.    
  58.     go_to_for_1:
  59.         subl $4, %esi
  60.         movl $0, %ebp
  61.         jmp for_1
  62.  
  63. end:
  64.     movl $1, %eax
  65.     int $0x80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement