Advertisement
Guest User

Untitled

a guest
Apr 15th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <mips/regdef.h>
  2.  
  3. #ifndef SIZE_LONG_LONG
  4. #define SIZE_LONG_LONG 8
  5. #endif
  6.  
  7.     .text
  8.     .abicalls
  9.     .align 2
  10.     .globl trasponer
  11.     .ent trasponer
  12. trasponer:
  13.     subu  sp, sp , 48
  14.     sw    ra, 40(sp)
  15.     sw   $fp, 36(sp)
  16.     move $fp,sp
  17.     sw    gp, 32(sp)
  18.  
  19.     sw    a0, 48(sp)      # Cantidad de filas
  20.     sw    a1, 52(sp)      # Cantidad de columnas
  21.     sw    a2, 56(sp)
  22.     sw    a3, 60(sp)
  23.  
  24.     add  t0, zero, zero   # t0 es el valor de "i" fila
  25.     add  t1, zero, zero   # t1 es el valor de "j" columna
  26.     addi v0, zero, 0
  27. FOR_FILAS:
  28.     blt   t0, a0, FOR_COLUMNAS
  29.  
  30. FINISH:
  31.     lw    gp, 32(sp)
  32.     lw   $fp, 36(sp)
  33.     lw    ra, 40(sp)
  34.     addiu sp, sp, 48
  35.     jr    ra
  36.  
  37.  
  38. FOR_COLUMNAS:
  39.     blt   t1, a1, TRASPOSE
  40.     add   t1, zero, zero
  41.     addi  t0, zero, 1
  42.     b    FOR_FILAS
  43.  
  44.  
  45. TRASPOSE:
  46.     mul   t2, t1, a0
  47.     addu  t2, t2, t0
  48.     addi  t3, zero, SIZE_LONG_LONG
  49.     mul   t2, t3, t2                  # t2 es la posicion de entrada
  50.  
  51.     mul   t4, t0, a1
  52.     addu  t4, t4, t1
  53.     addi  t3, zero, SIZE_LONG_LONG
  54.     mul   t4, t3, t4                  # t4 es la posicion de salida
  55.  
  56.     addu  t5, t2, a2
  57.     ld    t6, t5
  58.    
  59.     addu  t7, t4, a3
  60.     sd    t6, t7
  61.    
  62.     addi  t1, t1, 1
  63.     b FOR_COLUMNAS
  64.  
  65.     .end trasponer
  66.     # .size trasponer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement