【问题标题】:How to add two array's of numbers together using the IAS instruction set?如何使用 IAS 指令集将两个数字数组相加?
【发布时间】:2011-07-31 13:13:36
【问题描述】:

我必须使用 IAS 指令集编写一个程序,该程序将遍历两个数组,并将一个数组的每个元素添加到另一个数组中,并将结果存储在第三个数组中。因此,例如,我必须将 A(1) + B(1) 存储在 C(1) 中,然后将 A(2) + B(2) 存储在 C(2) 中,依此类推,直到我到达A(20) + B(20) 存储在 C(20) 中。但我不知道如何在 IAS 中创建一个计数器控制循环......无论如何......这是我所做的......但它不起作用:)

00000001 LOAD M(A[1]) Transfer M(A[1]) to the accumulator
00000101 ADD M(B[1]) Add M(B[1]) to AC and store result in AC
00100001 STOR M(C[1]) Transfer contents of accumulator to memory location C[1]

感谢您的帮助:)

【问题讨论】:

    标签: arrays architecture von-neumann


    【解决方案1】:

    对于未来的任何人。这个问题实际上有很多解决方案,这是我使用的解决方案(可能需要一些详细说明):

    * Initialize a variable 'count' to 999
    Label: TOP
    00000001    LOAD M(A[count])            Transfer M(A[count]) to the accumulator
    00000101    ADD M(B[count])             Add M(B[count]) to AC and store result in AC
    00100001    STOR M(C[count])            Transfer contents of accumulator to memory location C[count]
    00001010    LOAD M(address of count)    Transfer the contents of M(address of count) to the AC
    00000110    SUB M(the number 1)         Subtract one from AC and store in AC
    00100001    STOR M(D)                   Transfer contents of AC to location M(D)
    00001111    JUMP+ M(X,0:19)             If number in accumulator is non-negative take next
                                            instruction from left half of M(X)
    LH: go to TOP
    RH: exit
    

    【讨论】:

      猜你喜欢
      • 2018-04-10
      • 2021-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-03
      • 1970-01-01
      • 2010-12-24
      • 1970-01-01
      相关资源
      最近更新 更多