本文介绍了翻译mips伪指令"rol"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试翻译mips伪指令rol(向左旋转).我需要翻译它才能提交作业,这很不幸,因为伪指令对我来说效果很好.

I'm trying to translate the mips pseudo instruction rol (rotate left). I need to translate it before I can submit an assignment, which is unfortunate because the pseudo instruction worked quite well for me.

说明是

      rol   $s4,$s4, 1  #goes to the left most bit (which as it says, gets the left most bit)

我的翻译方式是

       lui $s4, 0x8001
       ori $t0, $s4, 0x0004
       srl $s4, $t0, 31
       sll $s5, $t0, 1
       or $s5, $s5, $s3

但是它完全弄乱了我的代码,有人可以帮我正确翻译它吗?还是告诉我我做错了什么?

but it completely messes up my code, can someone please help me translate it correctly? Or tell me what I'm doing wrong?

先谢谢您,

推荐答案

以下是UT-达拉斯关于ShiftRotate MIPS指令/伪指令的演讲: https://www.utdallas.edu/~dodge/EE2310/lec14.pdf

Here is a UT-Dallas lecture on Shift and Rotate MIPS instructions/pseudoinstructions: https://www.utdallas.edu/~dodge/EE2310/lec14.pdf

Slide Nine向后拉rol/ror伪指令上的窗帘.

Slide Nine pulls back the curtain on the rol/ror pseudoinstruction.

在幕后有一对移位(srlsll),它们将相关位移动到其最终所需的位置,并用0,然后是or填充不相关的位位置.将它们与按需要旋转的钻头重新组合.

Behind the scenes there are a pair of shifts (srl and sll) which move relevant bits into their final desired locations and fills non-relevant bit positions with 0's, and then an or to recombine them with bits rotated as desired.

在您的情况下,您想将所有位向左旋转一个位置.要创建此行为,我们可以使用三个MIPS指令:

In your case you want to rotate all bits one position to the left. To create this behavior we can use three MIPS instructions:

 srl $t1, $s4, 1 #shift original word 1 bit to the right
 sll $t2, $s4, 31 #shift original word 31 bits to the left
 or $s2, $t1, $t2 #Combine two fragments of words and place result in source register

让我知道这是否不清楚,或者我误解了您的目的.

Let me know if this is unclear or I misunderstood your purpose.

这篇关于翻译mips伪指令"rol"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 05:53