Saturday, 7 September 2013

Add numbers in a for loop together using rhe IAS instruction set

Add numbers in a for loop together using rhe IAS instruction set

I am supposed to write a program using the IAS instruction set that sums
10 times the value of the counter i. Here is the part of the code that I
should translate to IAS Instruction set:
int sum=0;
for (int i=0; i<10; i++)
sum+=i;
I started like this:
00000001 LOAD M(i)
00000101 ADD M(sum)
but the problem that I faced is how to increment the counter, knowing that
the IAS machine has only one addressing mode which is direct.
The second problem is whether I should repeat the process of loading and
adding 10 times in order to finish the loop or there is a more advanced
way to do it?
Thank you

No comments:

Post a Comment