Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tmp = 0
- n = 1
- i = 2
- j = 3
- b = 4
- sr = 5
- veci = 6
- manji = 7
- adrA = 100
- adrB = 400
- ORG 8
- ;Zadatak 1.
- MOV b, #adrB
- ;Ucita duzinu niza
- IN n
- BGT 0, n, exit
- BEQ 0, n, exit
- ;Ucita niz celih brojeva
- MOV i, #adrA ;Pokazuje indeks u nizu
- MOV j, n ;Prati broj prolaska kroz petlju
- MOV sr, 0
- l0: IN (i)
- ADD sr, sr, (i)
- ADD i, i, 1
- SUB j, j, 1
- BGT j, 0, l0
- ;Aritmeticka sredina
- DIV sr, sr, n
- ;Odredi br manjih i br vecih od arit. sredine
- MOV i, #adrA ;Pokazuje indeks u nizu
- MOV j, n ;Prati broj prolaska kroz petlju
- l1: BGT (i), sr, incVeci
- p0: BGT sr, (i), incManji
- p1: BEQ sr, (i), savePos
- p2: ADD i, i, 1
- SUB j, j, 1
- BGT j, 0, l1
- SUB i, b, #adrB
- MOV b, #adrB
- OUT manji
- OUT veci
- OUT (b), i
- exit: stop
- incVeci:ADD veci, veci, 1 ;Povecava brojac vecih za jedan
- BEQ veci, veci, p0
- incManji:ADD manji, manji, 1;Povecava brojac manjih za jedan
- BEQ manji, manji, p1
- savePos:SUB tmp, i, #adrA ;Upisuje vrednost u niz b (kada je jednak srednjoj vr)
- MOV (b), tmp
- ADD b, b, 1
- BEQ b, b, p2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement