将 32 位 int 拆分为 2 个带符号的 16 位短裤
Split 32-bit int into 2 signed 16-bit shorts
有什么简单的方法可以将 32 位寄存器的值拆分为 2 个带符号的 16 位短裤吗?
我考虑过这个:
#t0 holds the 32bit value containing the 2 signed shorts
sra $v0, $t0, 16 #extract the 1st signed short and put it in v0
li $t1, 0xffff #create a mask
and $v1, $t0, $t1 #extract the 2nd signed short and put it in v1
但是那会破坏第二个值的符号对吗?有没有一种简单的方法不涉及屏蔽另一个寄存器中的 2 个值的符号并将其移动到 v1 之后?
要对低位进行符号扩展,您需要向左移动然后向右移动
sll $v1, $t0, 16
sra $v1, $v1, 16
有什么简单的方法可以将 32 位寄存器的值拆分为 2 个带符号的 16 位短裤吗?
我考虑过这个:
#t0 holds the 32bit value containing the 2 signed shorts
sra $v0, $t0, 16 #extract the 1st signed short and put it in v0
li $t1, 0xffff #create a mask
and $v1, $t0, $t1 #extract the 2nd signed short and put it in v1
但是那会破坏第二个值的符号对吗?有没有一种简单的方法不涉及屏蔽另一个寄存器中的 2 个值的符号并将其移动到 v1 之后?
要对低位进行符号扩展,您需要向左移动然后向右移动
sll $v1, $t0, 16
sra $v1, $v1, 16