Advertisement
kernel_memory_dump

min i max odjednom

Mar 30th, 2014
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #   # min = niz[0]
  3.     # max = niz[0]
  4.     # for(i =1; i<n; i++){
  5.           #  if ( niz[i] > min)
  6.         # min = niz[i]
  7.     # if ( niz [i] > max) {
  8.     #   max = niz[i]
  9.  
  10.  
  11.  
  12. .section .data
  13. niz: .long 10,4,2,-1, 4, 24,3,-20,10,1000,1
  14. min: .long 0  # ovde staviti min niza
  15. max: .long 0
  16. n: .long 11
  17.  
  18. .section .text
  19. .globl main
  20.  
  21. main:
  22.     movl $1, %esi  # indeks niza:      niz[ esi]
  23.     # min = niz[0]
  24.     # for(i =1; i<n; i++)
  25.           #  if ( niz[i] > min)
  26.         # min = niz[i]
  27.    
  28.     # min = niz[0]
  29.     movl  niz, %eax
  30.     movl %eax, min  # min = niz[0]
  31.     movl %eax, max   # max = niz [ 0]
  32. for_petlja:
  33.     cmpl  %esi, n       # i < n
  34.     je  kraj
  35.     movl niz(, %esi , 4) , %eax  #  niz[ esi ] - > eax
  36.     incl %esi      # i ++    esi++
  37.     cmpl min, %eax #  eax -min
  38.     jnl  drugi_if
  39.     # u suprotnom, nije se desio jump  
  40.     # imamo nesto manje od  MIN
  41.     movl  %eax, min    # min  = niz[ esi]
  42. drugi_if:
  43.     cmpl max, %eax #  eax -max 
  44.     jng for_petlja
  45.     movl %eax, max
  46.     jmp for_petlja
  47.  
  48. kraj:
  49.     movl $1, %eax
  50.     movl $0, %ebx
  51.     int $0x80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement