Syntax: LDM <options>{cond} <base> {!}, <register_list>{^}
Operation: Multiple transfer of data from the registers to memory
Flags: (T)
The <register_list> is the series of register names, separated by commas, the contents of which we want to load from memory. The order of the registers in the list is of no significance, and any number of registers can be loaded. The assembler will allow a range of registers to be specified by using a '-' character.
The base field must be given as a simple register. The contents of this are taken to be the start address in memory from which the registers are to be loaded.
The options field is a two-character code which defines how the instruction should be executed.
As the ARM executes the instruction, it will load consecutive memory words into each of the registers named in register_list. A copy of the address in the base register is used and modified by the ARM as each register is stored. The actual contents of the base are not changed, unless we request this using the ! write back option.
When {^} is present,the user mode registers are stored instead (this is unpredictable in user and system modes).
Taken at its simplest level, LDM can be used to restore the contents of a register group previously stored with an STM instruction, containing the same memory address and register_list. However, a major use of STM and LDM is in the creation and access of stacks.
Example:
LDM R13!,{R0-R6} Pull R0 to R6 off the stack pointed to by R13
LDM R9,{R7-R13}^ Update user mode R7 to R13 from some area pointed to by R9
If <base> is not word aligned,the values read will not be rotated automatically as the bottom 2 bits of <base> are ignored. The result of register <base> being in <register_list> is unpredictable.
Be warned that on ARM architecture 5 and later, if as a result of an LDM operation bit 0 of R15 is set the processor will switch into Thumb mode too.
|
|
|