Advertisement
Lautaroleguizamon

B31

Sep 16th, 2023 (edited)
465
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.     li x9 10
  5. PushMax:
  6.     la x5 vector
  7.     addi x6 x0 10
  8.     slli x6 x6 2
  9.     add x6 x5 x6 #x6 tope
  10.     addi a0 x5 0
  11.     addi a1 x5 4
  12. loop:
  13.     beq a1 x6 PrintVector
  14.     beq x0 x0 MaxDir
  15. MaxDir:
  16.     lw x7 0(a0)
  17.     lw x8 0(a1)
  18.     bgt x7 x8 Swap
  19.     addi a0 a0 4
  20.     addi a1 a1 4
  21.     beq x0 x0 loop
  22. Swap:
  23.     lw a2 0(a0)
  24.     lw a3 0(a1)
  25.     sw a2 0(a1)
  26.     sw a3 0(a0)
  27.     addi a0 a0 4
  28.     addi a1 a1 4
  29.     beq x0 x0 loop
  30. PrintVector:
  31.     lw a0 0(x5)
  32.     li a7 1
  33.     ecall
  34.     li a0 44
  35.     li a7 11
  36.     ecall
  37.     addi x5 x5 4
  38.     blt x5 x6 PrintVector
  39.     li a0 10
  40.     ecall
  41.     addi x9 x9 -1
  42.     bgt x9 x0 PushMax
  43.     nop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement