Yahoo Groups archive

Lpc2000

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

Message

Re: [lpc2000] Re: Beginner questions

2005-08-26 by Brian C. Lane

Peter wrote:

> 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.
> 

Ah! That makes sense. For some reason my reading of the opcodes hadn't 
made that distinction clear (or my recent use of the MSP430 corrupted my 
understanding).

> 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.

I suspected it might be a pipeline thing, since I still don't have a 
good handle on how all these bits fit together. I'm using a LPC2138 so 
it has a 3 level pipeline and Memory Accelerator.

Thanks,

Brian

-- 
-----------------------------------------------------
Brian C. Lane (W7BCL)                      Programmer
www.shinemicro.com   RF, DSP & Microcontroller Design

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.