mips - 在不带 FPU 的 MIPS 中添加 64 位 IEEE 754 数字

标签 mips ieee-754

我应该描述如何在 MIPS 中实现两个 double 的加法而不使用浮点单元。我知道如何使用单精度 IEEE 754 来做到这一点,但不知何故无法弄清楚如何在两个寄存器中完成整个移位业务(当标准化等时)。

除了移位第一个寄存器,保存移位的位数,然后将相同的移位次数应用于第二个寄存器之外,还有其他方法吗?

最佳答案

如果您需要在 MIPS32 处理器上移动 64 位值,您可以执行以下操作:

# Left shift
# $t1:$t0 contains a 64-bit number
slt $t2,$t0,$0    # $t2 = ($t0 & 0x80000000) ? 1 : 0
sll $t0,$t0,1     # shift the low word left 1 bit
sll $t1,$t1,1     # shift the high word left 1 bit
or $t1,$t1,$t2    # add the carry from the low word to the high word

# Right shift
# $t1:$t0 contains a 64-bit number
sll $t2,$t1,31    # save the lsb of $t1 in the msb of $t2
srl $t1,$t1,1     # shift the high word right 1 bit
srl $t0,$t0,1     # shift the low word right 1 bit
or $t0,$t0,$t2    # add the carry from the high word to the low word

根据需要循环重复多次。

关于mips - 在不带 FPU 的 MIPS 中添加 64 位 IEEE 754 数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17008054/

相关文章:

linker - 没有足够的 GOT 空间用于本地 GOT 条目

c - IEEE-754 在 C 中 float

java - IBM-IEEE double 浮点字节转换

assembly - 了解汇编 MIPS .ALIGN 和内存寻址

c - 在 MIPS 中表达此语句

C IEEE-Floats inf 等于 inf

javascript - 双 64 位中最小值的位模式是什么

java - 如何根据 IEEE-754 格式将十六进制值转换为单精度 float 以及 double float

assembly - 汇编指令 `.global`的作用是什么

mips - QtSpim 在读取字符串后剪切 2 个初始字符