I have to write a program using the IAS instruction set that will loop through two arrays and add each element of the one to the other and store the result in a thrid array. So for example I have to take A(1) + B(1) and store it in C(1) and then take A(2) + B(2) and store in C(2) and so on until I get to A(20) + B(20) stored in C(20). But I don't know how to create a counter controlled loop in IAS... anyways... here is what I have done.. but it doesn't work :)
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]
thanks for any help :)
For anyone in the future. There are actually numerous solutions to this question, this is the one I went with (it may need some elaboration):
* 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