如何MIPS的逻辑或指令的工作? [英] How does the MIPS Logical OR Instruction work?

查看:353
本文介绍了如何MIPS的逻辑或指令的工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设 $ Z0 是始终包含数为零的寄存器。

Assuming that $z0 is a register which always contains the number zero.

然后MIPS指令或$ T0,$ T1,$ T2 提出<$ C的按位 $ C> $ T1 和 $ T2 入册 $ T0

Then the MIPS instruction OR $t0, $t1, $t2 puts the bitwise OR of $t1 and $t2 into the register $t0.

假设寄存器 $ T2 包含数字5。什么是寄存器 $ T0 指令的执行或$ T0,之后$ Z0,$ T1

Suppose that the register $t2 contains the number "5". What is in the register $t0 after the execution of the instruction or $t0, $z0, $t1

这是在一个模拟试卷一个问题,但我很困惑,如何把它工作了。我真的需要帮助,请。我将如何去解决呢?我无法搞清楚T1的价值我知道如何按位或工作

This was a question in a mock exam paper but I'm confused as to how to work it out. I really need help please. How would I go about solving it? I'm having trouble figuring out the value of t1 I know how bitwise OR works

推荐答案

如果你想知道为什么寄存器0($ Z0)也经常在OR指令使用的:

If you want to know WHY register 0 ($z0) is often used in OR instructions:

OR $xx, $z0, $yy

有寄存器YY的内容复制到注册ZZ的效果。

has the effect that the content of register yy is copied to register zz.

在此使用MOVE指令不在MIPS处理器存在完成的其他处理器。组装机将取代

On other processors this is done using the "MOVE" instruction which does not exist on MIPS processors. Assemblers will replace a

MOVE $xx, $xx

通过这些指令(这并没有真正在MIPS处理器存在):

(which does not really exist on MIPS processors) by one of these instructions:

OR $xx, $z0, $yy
ADD $xx, $z0, $yy
ADDU $xx, $z0, $yy
ADDI $xx, $yy, #0
SUB $xx, $yy, $z0
...

所有这些指令简单地注册YY的值复制到注册XX。

All these instructions simply copy the value of register yy to register xx.

- 编辑 -

您想知道一个OR指令一般是如何工作的:

You want to know how an OR instruction works in general:

这是OR指令是一个位指令。这意味着:用相同数目的位(例如,两个32位值),是采取与数字处理逐位(而不是完整号码)的两个数字

An OR instruction is a bitwise instruction. This means: Two numbers with the same number of bits (e.g. two 32-bit-numbers) are taken and the digits are processed bit-by-bit (and not the complete number).

OR指令给出0的结果,如果这两个输入位为0和1,如果至少有一个输入位是1

The OR instruction gives a result of 0 if both "input" bits are 0 and 1 if at least one input bit is 1.

例如:

OR t3, t1, t2

t1 = 0x1234
t2 = 0x6789

t1 = 0001001000110100 (binary)
t2 = 0110011110001001 (binary)
---------------------
t3 = 0111011110111101 (binary)

t3 = 0x77BD

这篇关于如何MIPS的逻辑或指令的工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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