MIPS - 有没有办法将协处理器 1 中的标志值传输到协处理器 0 的整数寄存器?

MIPS - is there a way to transfer the value of the flag in coprocessor 1 to integer registers of coprocessor 0?

我正在为一个学校项目制作一个编译器,我使用 MIPS 汇编作为我的目标代码。但这并不重要。我知道涉及浮点数的操作是在协处理器 1 中完成的,并且 c.eq.dc.le.d 等比较指令的结果位于可以通过 bc1t 和 [=13 进行测试的标志中=].有没有一种方法 MIPS 可以在不使用 bc1tbc1f 的分支指令的情况下将标志的值传输到协处理器 0 的寄存器(例如 $a0)。如果这不可能,我如何在 SPIM 中创建匿名标签? SPIM 似乎不支持此功能。 (如有错误请指正)

您可以使用 MOVF(或 MOVT)根据单个 FP 条件代码将值放入 GPR:

MOVF rd, rs, cc

To test an FP condition code then conditionally move a GPR

If the floating point condition code specified by CC is zero, then the contents of GPR rs are placed into GPR rd.

或者,如果您想要一次获得所有条件代码,您可以使用 CFC1:

CFC1 rt, fs

Copy the 32-bit word from FP (coprocessor 1) control register fs into GPR rt.

if fs = 0 then
    temp <- FIR
elseif fs = 25 then
    temp <- 0^24 || FCSR31..25 || FCSR23
elseif fs = 26 then
    temp <- 0^14 || FCSR17..12 || 0^5 || FCSR6..2 || 0^2
elseif fs = 28 then
    temp <- 0^20 || FCSR11.7 || 0^4 || FCSR24 || FCSR1..0
elseif fs = 31 then
    temp <- FCSR
else
    temp <- UNPREDICTABLE
endif
GPR[rt] <- temp

您想要的位是 23 和 25..31,因此 $f25$f31 应该适合用作 fs