为什么我们不能将寄存器与立即数(Assembly-MIPS)进行比较(bne-beq)? [英] Why we cant compare (bne-beq) a register with an immediate (Assembly-MIPS)?

查看:481
本文介绍了为什么我们不能将寄存器与立即数(Assembly-MIPS)进行比较(bne-beq)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,在add上,我们有addi用于添加寄存器和立即数,为什么在这种情况下,我们不能有bnei或beqi ...

For example on add we have addi for adding a register and an immediate,why on this case we cant have bnei or beqi...

我应该回答这个问题,但是我不确定...有什么帮助吗?

Im supposed to answer on that,but im not sure...any help?

推荐答案

原因是指令编码:

ADDIBNE/BEQ均为 I型指令.但是,尽管ADDI指令中的立即数字段用于存储加法的立即数操作数,但在BEQ/BNE情况下,它用于存储分支偏移量.

Both ADDI and BNE/BEQ are I-Type instructions. But whereas the immediate field in the ADDI instruction is used for storing the immediate operand for the addition, it's used for storing the branch offset in the case of BEQ/BNE.

也许有MIPS汇编器允许您在条件分支指令中使用立即操作数,但是它们会将那些 pseudo-instructions 扩展为多个实际指令.

There may be MIPS assemblers which allow you to use immediate operands in conditional branch instructions, but they will expand those pseudo-instructions into multiple actual instructions.

这篇关于为什么我们不能将寄存器与立即数(Assembly-MIPS)进行比较(bne-beq)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆