2011-07-31 16 views
0

我必須編寫一個使用IAS指令集的程序,該指令集將循環兩個數組並將其中的每個元素添加到另一個數組中,並將結果存儲在第三個數組中。例如,我必須取A(1)+ B(1)並將其存儲在C(1)中,然後取A(2)+ B(2)並存儲在C(2)中,依此類推直到我得到A(20)+ B(20)存儲在C(20)中。但我不知道如何創建IAS計數器控制的循環......反正...這裏是我做了什麼..但它不工作:)如何使用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] 

感謝您的幫助: )

回答

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 
相關問題