Load Register Indirect with Predecrement?

Discussion in 'Homework Help' started by de1337ed, Dec 6, 2011.

  1. de1337ed

    Thread Starter New Member

    Mar 6, 2011
    Hey Guys,
    We are learning assembly in class, and there is this one instruction, Load Register Indirect with Predecrement (LDRP Rd, Rs), specific to our assembly language that is taught. I was wondering if anyone knows what is the point of this instruction? Can someone site a specific situation where we would use it in? All the situations that I think of can simply be done with LDR, and without the use of LDRP.

    If you are wondering what LDRP does, it basically takes the value stored in a register (usually an address), decrements it, and puts it to another register.
    LDR is similar, except with no decrement.
    Thank you.
  2. RiJoRI

    Well-Known Member

    Aug 15, 2007
    Are you sure your description of Load Register Indirect Pre-dec is correct? I ask because Load Indirect generally uses either a register (or memory location) to point to the data to be loaded into a second register. If this is the case, consider a stack where the stack pointer points at the next available memory location. Otherwise, it might be considered a fancy way to decrement a register. LDRP R0,R0 would decrement R0 and store the result in R0.

  3. de1337ed

    Thread Starter New Member

    Mar 6, 2011
    Oops, sorry, messed up the definition. lol.

    It takes an address from a register, decrements the address, then goes into memory and fetches the data at this address, and then loads it into the other register. So ya, what use is this when we already have LDR?
  4. Papabravo


    Feb 24, 2006
  5. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    I'm pretty sure when you turn optimization to max in C, it'd get used.. somehow, in a clever way you'd have never thought of.

    As compilers mature, I'm amazed at some of the clever tricks in the libraries.