What will be accomplished by the assembler after its first p
What will be accomplished by the assembler after its first pass over the following code? Clearly state the instruction field format and each needed instruction opcode bit string that you use in your answer.
Loop: LOAD.D F2, R1, #0
ADD.D F2, F2, F0
STORE.D F2, R1, #0
ADDI R1, R1, #–8
BNE R1, #0, Loop
Solution
The explanations for each of the instructions is given in square bracket in bold.
Loop: LOAD.D F2, R1, #0 [loads the double precision floating point value from memory address indicated by R1 into register F2]
ADD.D F2, F2, F0 [Add the registers F2 and F0 and store the result in F2]
STORE.D F2, R1, #0 [store the value from register F2 into the address indicated by R1]
ADDI R1, R1, #–8 [Decrement the contents of R1 by 8]
BNE R1, #0, Loop [As long as R1 is not zero , loop back to the label Loop:]
===========
The effect of these instructions is that starting from memory address indicated by R1 upto memory address 0, each of the double precision values are added with the value stored in register F0 and stored back in its location. R1 starts from some memory address and each time is decremented by 8 to go to next memory location. This is repeated till R1 becomes 0. For each time of the loop, the value in memory indicated by R1 is fetched, added with F0 and stored by in the same address. So, all values starting from memory address 0 to the starting value of R1 are incremented by the same amount as indicated by F0 in a loop.
