Yahoo Groups archive

Lpc2000

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

Message

Re: [lpc2000] Strange GCC compiler assembler output

2006-05-03 by Ralph Hempel

Jan Thogersen wrote:

> How come it takes 3 instruction to load the correct address into r2. 
> First it moves #0xE0000000 to r2, then adds #0x00004000 and finally adds 
> #0x00000018 to end up with #0xE0004018 which is the address of T0MR0. 
> But why don't it just move #0xE0004018 into the r2 in the first instruction?

It's because of the way ARM instructions are encoded. Each instruction
is exactly 32 bits long, so there's no way to load a 32 bit constant.

<http://www.heyrick.co.uk/assembler/qfinder.html>

The ARM move instruction actually works out to something like:

Move 8 bit value into Rn shifted by up to 31 bits.

<http://www.heyrick.co.uk/assembler/mov.html#mov>

Here's a quick reference card in PDF format:

<http://www.arm.com/pdfs/QRC0001H_rvct_v2.1_arm.pdf>

Hope this helps.

Ralph

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.