我有一个8x16的位矩阵作为UINT8矩阵[16]。
我想转置矩阵并将其存储为UINT16矩阵2 [8]。
这是我的代码的时间关键部分,所以我需要尽快做到这一点。有没有一种聪明的方法可以在MIPS处理器上实现这一目标?
答案 0 :(得分:0)
也许是这样的:
lbu $10, matrix
lbu $11, matrix+1
lbu $12, matrix+2
lbu $13, matrix+3
lbu $14, matrix+4
lbu $15, matrix+5
lbu $16, matrix+6
lbu $17, matrix+7
lbu $18, matrix+8
lbu $19, matrix+9
lbu $20, matrix+10
lbu $21, matrix+11
lbu $22, matrix+12
lbu $23, matrix+13
lbu $24, matrix+14
lbu $25, matrix+15
addiu $2, $0, 8
addiu $9, $0, 256
loop:
addiu $2, $2, -1
srl $9, $9, 1
addu $27, $0, $0
and $26, $10, $9
srlv $26, $26, $2
or $27, $27, $26
and $26, $11, $9
srlv $26, $26, $2
sll $27, $27, 1
or $27, $27, $26
and $26, $12, $9
srlv $26, $26, $2
sll $27, $27, 1
or $27, $27, $26
and $26, $13, $9
srlv $26, $26, $2
sll $27, $27, 1
or $27, $27, $26
and $26, $14, $9
srlv $26, $26, $2
sll $27, $27, 1
or $27, $27, $26
and $26, $15, $9
srlv $26, $26, $2
sll $27, $27, 1
or $27, $27, $26
and $26, $16, $9
srlv $26, $26, $2
sll $27, $27, 1
or $27, $27, $26
and $26, $17, $9
srlv $26, $26, $2
sll $27, $27, 1
or $27, $27, $26
and $26, $18, $9
srlv $26, $26, $2
sll $27, $27, 1
or $27, $27, $26
and $26, $19, $9
srlv $26, $26, $2
sll $27, $27, 1
or $27, $27, $26
and $26, $20, $9
srlv $26, $26, $2
sll $27, $27, 1
or $27, $27, $26
and $26, $21, $9
srlv $26, $26, $2
sll $27, $27, 1
or $27, $27, $26
and $26, $22, $9
srlv $26, $26, $2
sll $27, $27, 1
or $27, $27, $26
and $26, $23, $9
srlv $26, $26, $2
sll $27, $27, 1
or $27, $27, $26
and $26, $24, $9
srlv $26, $26, $2
sll $27, $27, 1
or $27, $27, $26
and $26, $25, $9
srlv $26, $26, $2
sll $27, $27, 1
or $27, $27, $26
sll $3, $2, 1
sh $27, transposed($3)
bgez $2, loop
nop
.data 0x2000
matrix:
.byte 0x80
.byte 0x80
.byte 0x40
.byte 0x40
.byte 0x20
.byte 0x20
.byte 0x10
.byte 0x10
.byte 0x08
.byte 0x08
.byte 0x04
.byte 0x04
.byte 0x02
.byte 0x02
.byte 0x01
.byte 0x01
.data 0x3000
transposed:
.half 0
.half 0
.half 0
.half 0
.half 0
.half 0
.half 0
.half 0
它读取输入矩阵,然后执行循环8次(每个转置矩阵行一次)。
答案 1 :(得分:0)
我认为MIPS指令集中没有任何特殊指令可以帮助解决这个问题,所以你也可以在C中编写代码。如果你有权访问处理器,你可以创建一个用户定义的指令。 RTL ....