Load Register Indirect with Predecrement?

Thread Starter

de1337ed

Joined Mar 6, 2011
23
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.
 

RiJoRI

Joined Aug 15, 2007
536
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.

--Rich
 

Thread Starter

de1337ed

Joined Mar 6, 2011
23
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?
 

thatoneguy

Joined Feb 19, 2009
6,359
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?
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.
 
Top