机器语言中 OISC 中使用 SBN 的斐波那契数
我想在 OISC 架构中使用 SBN 生成斐波那契数列。我最初的做法是先用汇编语言实现,然后再转换为机器语言。第一步涉及将 0 和 1 存储在 2 个寄存器中,然后从 0 中减去 1,并在后续步骤中重复减去 1。每次它都会生成一个负数,并且由于它是负数,因此它会分支并获取绝对值查找指令。
我的做法正确吗?我对 OISC 的含义感到困惑。如果我错了,请纠正我,如果我执行减法然后求绝对值,则意味着我每次都使用 2 条指令。或者是在 OISC 处理器中这两条指令同时完成,这意味着我的方法是正确的。
I want to generate fibonacci series using SBN in an OISC architecture. My initial approach is to implement it in assembly language first and then convert it to machine language. The first steps involve storing 0 and 1 in 2 registers and then subtract 1 from 0 and repeatedly subtract 1 in the consequent steps. Everytime it will generate a negative number and since its negative, it branches off and fetches the absolute value finding instruction.
Is my approach correct? My confusion in the meaning of OISC. Correct me if i'm wrong, if i perform a subtraction and then an absolute value finding, it means that that i'm using 2 instructions everytime. or is it that in the OISC processor both these instructions are done at the sametime which would mean that my approach is correct.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通用汇编指令可以由 OISC 指令的组合合成。例如,取自维基百科页面,添加:
以及
BEQ
:重要的见解是,一旦拥有这些构建块,您就可以构建更复杂的块。例如,使用
ADD
和BEQ
您可以轻松实现计数循环(这对斐波那契很有用......)因此您可以执行以下操作:
Common assembly instructions can be synthesized from combinations of the OISC instruction. For example, taken from the Wikipedia page, addition:
And
BEQ
:The important insight is that once you have these building blocks, you can build more complex blocks. For instance, with
ADD
andBEQ
you can easily implement a counting loop (which would be useful for Fibonacci...)So you can do the following:
有两种方法可以解决这个问题:
You have 2 ways to about it: