Advertisement
Lautaroleguizamon

B29

Sep 16th, 2023
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .data
  2.     vector: .word 100,-20,40,-365,400,65536,1,0,3,-10
  3. .text
  4.     la x5 vector
  5.     addi x6 x6 10
  6.     slli x6 x6 2
  7.     add x6 x5 x6 #x6 tope
  8.     addi a0 x5 0
  9.     addi a1 x5 4
  10. loop:
  11.     beq a1 x6 PrintVector
  12.     beq x0 x0 MaxDir
  13. MaxDir:
  14.     lw x7 0(a0)
  15.     lw x8 0(a1)
  16.     bgt x7 x8 Swap
  17.     addi a0 a0 4
  18.     addi a1 a1 4
  19.     beq x0 x0 loop
  20. Swap:
  21.     lw a2 0(a0)
  22.     lw a3 0(a1)
  23.     sw a2 0(a1)
  24.     sw a3 0(a0)
  25.     addi a0 a0 4
  26.     addi a1 a1 4
  27.     beq x0 x0 loop
  28. PrintVector:
  29.     lw a0 0(x5)
  30.     li a7 1
  31.     ecall
  32.     li a0 44
  33.     li a7 11
  34.     ecall
  35.     addi x5 x5 4
  36.     blt x5 x6 PrintVector
  37.     nop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement