This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

why does LDR takes two cycle to be executed

Hello everyone,

I am currently working on a cortex-M0 microprocessor(LPC1114). I have looked through all the possible instruction descriptions but I did not find anyone of them explaining why some instructions takes two cycle to execute.

For example, ANDS, MOVS takes only one cycle to execute. but why do we need two cycles to execute LDR? and STR? 

Parents
  • Hello ,

    But what about LDR on CM4 (and I think it's same on CM3) : why does it take 2 cycles - by the CM4 tech manual, and the hardware cycle counter as I checked - even for this type of LDR example :

    LDR r0, [r1, r2] ? 

    Please correct me, but doesn't it need extra cycle to calculate r1 + r2? Looking at the older ARM7TDMI spec, LDR is a 3 cycle, one spent to calculate the destination address. And I tried reasoning how the extra cycle could be hidden, but I cannot really find 100% explanation (one thing I thought, CM3, CM4 are Harvard, perhaps memory write and instruction fetch can happen at same time..but , there is still cycle needed to update the register with memory contents before next instruction?)

    For case of STR taking only one cycle on CM4, the manual says :
    "STR Rx,[Ry,#imm] is always one cycle. This is because the address generation is performed in the initial cycle, and the data store is performed at the same time as the next instruction  is executing."

    So the espec is "cheating" somewhat, as there is last cycle but it's happening as the next one is executing at least.

    There is nothing more detailed in CM4 manual about how LDR is implemented however.

    Clarification would be very much appreciated - about how / why LDR only is takes 2 cycles  here (Ignoring case when its to to /from PC, which takes longer).

Reply
  • Hello ,

    But what about LDR on CM4 (and I think it's same on CM3) : why does it take 2 cycles - by the CM4 tech manual, and the hardware cycle counter as I checked - even for this type of LDR example :

    LDR r0, [r1, r2] ? 

    Please correct me, but doesn't it need extra cycle to calculate r1 + r2? Looking at the older ARM7TDMI spec, LDR is a 3 cycle, one spent to calculate the destination address. And I tried reasoning how the extra cycle could be hidden, but I cannot really find 100% explanation (one thing I thought, CM3, CM4 are Harvard, perhaps memory write and instruction fetch can happen at same time..but , there is still cycle needed to update the register with memory contents before next instruction?)

    For case of STR taking only one cycle on CM4, the manual says :
    "STR Rx,[Ry,#imm] is always one cycle. This is because the address generation is performed in the initial cycle, and the data store is performed at the same time as the next instruction  is executing."

    So the espec is "cheating" somewhat, as there is last cycle but it's happening as the next one is executing at least.

    There is nothing more detailed in CM4 manual about how LDR is implemented however.

    Clarification would be very much appreciated - about how / why LDR only is takes 2 cycles  here (Ignoring case when its to to /from PC, which takes longer).

Children