0

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.

4

2 回答 2

3

常见的汇编指令可以从 OISC 指令的组合中合成。例如,取自维基百科页面,添加:

ADD a, b == subleq a, Z
            subleq Z, b
            subleq Z, Z

并且BEQ

BEQ b, c == subleq b, Z, L1
            subleq Z, Z, OUT
        L1: subleq Z, Z
            subleq Z, b, c
       OUT: ...

重要的见解是,一旦有了这些构建块,就可以构建更复杂的块。例如,使用ADDandBEQ你可以很容易地实现一个计数循环(这对斐波那契很有用......)

因此,您可以执行以下操作:

  1. 用普通的汇编语言实现斐波那契(最多几行)
  2. 看看哪些指令可以替代从 OISC 指令轻松合成的指令
  3. 使用 OISC 重写
于 2010-04-09T17:47:24.390 回答
1

你有两种方法来解决它:

  • 您的数据结构包含真实的(正范围)斐波那契数;如果是这样,你确实需要做一个计算和一个否定(你称之为绝对)步骤,即。每个整数最少 2 个。
  • 或者,您可以解决它的 0 补码:-1、-1、-2、-3、-5、-8... 这样,您只需简单地取反结果即可打印/提供等。这具有快速的 1 步计算,但是当您访问它时(即当您将其打印给用户时),它的翻译成本很低。
于 2017-10-14T01:22:55.043 回答