-1
$\begingroup$

Im'm studying Instruction Set Architecture using the book "Logic and Computer Design Fundamentals". Studying types of architectures I came up with an example of memory-memory type which is:

ADD T1, A, B     ' M[T1] <-M[A] + M[B]

ADD T2, C, D     ' M[T2] <- M[C] + M[D]

MUL X, T1, T2    ' M[X] <- M[T1] * M[T2]

Then a it is said and I quote:

For the previous example, three instructions are required, but if an extra word must appear in the instruction for each memory address, then up to four memory reads are required to fetch each instruction. Including the fetching of operands and storing of results, the program to perform the arithmetic operation would require 21 accesses to memory.

I don't understand how they come up with 21 accesses to memory...

i know that we have at least 9 accesses (one for each operand and each result). If we have an extra word (to specify the address of each operand) then we will have 7 more

9+7=16... How do they come up with the extra 5 accesses? Can someone clarify this to me? Thanks!

$\endgroup$
  • 3
    $\begingroup$ If each operand encoded in each instruction takes a word that takes a memory access, then each instruction might use four words (thus four memory accesses just for the instruction). Each instruction also reads two sources and writes one destination, so that is three data accesses for each instruction. There are three instructions. (4+3)*3 = 21. $\endgroup$ – Paul A. Clayton Apr 4 '17 at 2:30
  • $\begingroup$ @PaulA.Clayton Make an answer? $\endgroup$ – Yuval Filmus Apr 4 '17 at 9:43
1
$\begingroup$

The proposed architecture apparently does not use CPU registers. That means all data must be stored in main memory. Instructions will then need to know where in main memory their arguments are.

So, ADD T1, A, B needs the instruction (one word), the 2 addresses of A and B (2 words), and the two values of A and B (2 words). It will then calculate the result, retrieve the address of T1 (1 word), and store the result at that address (1 word). In total, that's 6 reads (one instruction, 3 addresses, 2 values) and 1 write (the final value).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.