Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: Beginner questions

2005-08-26 by Peter

The differences between MOV and LDR are:

MOV is for moving data between registers, or moving a constant 
encoded into the instruction into a register.

LDR is a memory-access instruction that loads a value from memory 
into a register.

The second operand of a MOV may be shifted or rotated by a number of 
bits encoded into the instruction, or specified by the bottom byte of 
another register. The shift is carried out by dedicated hardware 
inline with the Op2 input into the ALU, so it has zero time overhead, 
unless of course the shift amount is specified in another register - 
in the ARM7 there are just two register read ports, so the processor 
stalls for one cycle while the shift amount is read from the register.

The shift/rotate hardware is used when extracting a constant encoded 
into a dataprocessing instruction (ADD, SUB, CMP, MOV etc). The 
encoding is "8 bits, optionally rotated right by an even number of 
bits" - so 8 bits anywhere in the 32-bit word isn't strictly accurate.

In the ARM assembler, a useful syntactical nicety is:
     MOV Rd,=0xfeedbeef
The assembler will turn this into a MOV or MVN if at all possible, 
otherwise it will create a literal pool entry and a pc-relative LDR 
instruction.

The only mildly reasonable argument for using three instructions to 
construct a constant rather than a pc-relative load from a literal 
pool, is that in a cached system it may turn out that the pc-relative 
load forces a cache-line eviction and reload... but that's not a very 
convincing argument to me.

Peter.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.