Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define t0 $8 // Zacatek pole
- #define t1 $9 // hodnota
- #define t2 $10 // nasledujici hodnota
- #define t3 $11 // pomocna promenna
- #define s0 $16
- #define s1 $17
- #define s2 $18
- #define s3 $19
- #define s4 $20
- .globl pole
- .data
- .align 2
- pole:
- .word 5
- .word 3
- .word 4
- .word 1
- .word 2
- .text
- .globl start
- .ent start
- start:
- // Inicializace prvniho cyklu
- la s0, pole
- addi s1, $0, 0 // dolni mez i
- addi s2, $0, 5 // horni mez i
- // Inicializace druheho cyklu
- addi s3, $0, 0 // dolni mez j
- addi s4, $0, 4 // horni mez j
- outercycle:
- beq s1, s2, alldone // i==5
- add t0, $0, s0 // zpet na zacatek pole
- addi s3, $0, 0 // vynulovat j
- addi s1, s1, 0x1 // i++
- j innercycle
- nop
- innercycle:
- beq s3, s4, outercycle
- nop
- lw t1, 0x0(t0) // nactu promenne
- lw t2, 0x4(t0)
- bgt t1, t2 , swap
- nop
- swapdone:
- addi t0, t0, 0x4 // posun v poli
- addi s3, s3, 0x1 // j++
- j innercycle // dalsi kolo cyklu
- nop
- swap:
- add t3, $0, t1 // docasne ulozim t1
- sw t2, 0x0(t0) // a prehodim hodnoty
- sw t3, 0x4(t0)
- j swapdone
- nop
- alldone:
- nop
- .end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement