Advertisement
PecaJ

domaci 1

Jan 20th, 2021
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. tmp = 0
  2. n = 1
  3. i = 2
  4. j = 3
  5. b = 4
  6. sr = 5
  7. veci = 6
  8. manji = 7
  9. adrA = 100
  10. adrB = 400
  11. ORG 8
  12. ;Zadatak 1.
  13.  
  14. MOV b, #adrB
  15.  
  16. ;Ucita duzinu niza
  17. IN n
  18. BGT 0, n, exit
  19. BEQ 0, n, exit
  20.  
  21. ;Ucita niz celih brojeva
  22. MOV i, #adrA ;Pokazuje indeks u nizu
  23. MOV j, n ;Prati broj prolaska kroz petlju
  24. MOV sr, 0
  25. l0: IN (i)
  26. ADD sr, sr, (i)
  27. ADD i, i, 1
  28. SUB j, j, 1
  29. BGT j, 0, l0
  30.  
  31. ;Aritmeticka sredina
  32. DIV sr, sr, n
  33.  
  34. ;Odredi br manjih i br vecih od arit. sredine
  35. MOV i, #adrA ;Pokazuje indeks u nizu
  36. MOV j, n ;Prati broj prolaska kroz petlju
  37. l1: BGT (i), sr, incVeci
  38. p0: BGT sr, (i), incManji
  39. p1: BEQ sr, (i), savePos
  40. p2: ADD i, i, 1
  41. SUB j, j, 1
  42. BGT j, 0, l1
  43.  
  44. SUB i, b, #adrB
  45. MOV b, #adrB
  46.  
  47. OUT manji
  48. OUT veci
  49. OUT (b), i
  50.  
  51. exit: stop
  52.  
  53.  
  54. incVeci:ADD veci, veci, 1 ;Povecava brojac vecih za jedan
  55. BEQ veci, veci, p0
  56.  
  57. incManji:ADD manji, manji, 1;Povecava brojac manjih za jedan
  58. BEQ manji, manji, p1
  59.  
  60. savePos:SUB tmp, i, #adrA ;Upisuje vrednost u niz b (kada je jednak srednjoj vr)
  61. MOV (b), tmp
  62. ADD b, b, 1
  63. BEQ b, b, p2
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement