Arm Community
Site
Search
User
Site
Search
User
Arm Developer
Documentation
Learning Paths
On-Demand Videos
Groups
Arm Ambassadors
Education Hub
Open Source Software and Platforms
Research Collaboration and Enablement
Forums
AI forum
Architectures and Processors forum
Arm Development Platforms forum
Arm Development Studio forum
Automotive forum
Compilers and Libraries forum
Embedded and Microcontrollers forum
Internet of Things (IoT) forum
Keil forum
Laptops and Desktops forum
Mobile, Graphics, and Gaming forum
Morello forum
Operating Systems forum
Servers and Cloud Computing forum
SoC Design and Simulation forum
SystemReady Forum
Blogs
AI blog
Announcements
Architectures and Processors blog
Automotive blog
Embedded and Microcontrollers blog
Internet of Things (IoT) blog
Laptops and Desktops blog
Mobile, Graphics, and Gaming blog
Operating Systems blog
Servers and Cloud Computing blog
SoC Design and Simulation blog
Tools, Software and IDEs blog
Support
Arm Support Services
Documentation
Downloads
Training
Arm Approved program
Arm Design Reviews
Community Help
More
Cancel
Support forums
Embedded and Microcontrollers forum
LDR Instruction
Jump...
Cancel
State
Not Answered
Replies
2 replies
Subscribers
140 subscribers
Views
6379 views
Users
0 members are here
Architecture
Instruction Set
Thumb
Thumb2
Options
Share
More actions
Cancel
Related
How was your experience today?
LDR Instruction
subin t
over 11 years ago
Note: This was originally posted on 5th November 2008 at
http://forums.arm.com
Hi all,
I am new to the thumb-2 instruction set. In one of my sample code
I noticed a instruction
LDR r0, =0x12345678;
This instruction actually load the r0 with value (0x12345678).
But I didn't find such an instruction anywhere in the thumb-2 instruction set.
I am wondering anyone is aware of such instruction and from where i can find
more details about the thumb-2 instruction set.
0
Jacob Bramley
over 11 years ago
Note: This was originally posted on 5th November 2008 at
http://forums.arm.com
That is a pseudo-instruction, and actually expands to multiple real instructions. If assemble the code then view the disassembly of the result, you'll see something like this:
0x1000: LDR r0, [pc,#8]
...
0x1008: .DCD 0x12345678
This is called a "PC relative load". The ".DCD" directive simply allows you to insert arbitrary data into the instruction stream. Of course, you'd never execute that data, so your code will have to branch around it.
Using assembler, you can also specify exactly where the literal pools should be using another assembler directive. There are various reasons why you might want to do that.
So, to answer your question, the instruction you show isn't part of the Thumb-2 (or ARM) instruction set, but is expanded into real instructions by the assembler. You'll need to look at the documentation for the specific assembler in order to find out more, but the format you're using works in every assembler I've used.
Cancel
Vote up
0
Vote down
MISSING RESOURCE: login_to_reply
Accept answer
Cancel
0
Peter Harris
over 11 years ago
Note: This was originally posted on 5th November 2008 at
http://forums.arm.com
It is also worth noting that "LDR rd, =X" may not assemble to an "LDR" at all.
If X is a small enough literal value to fit into the MOV instruction encoding you might see a single MOV instruction.
Cancel
Vote up
0
Vote down
MISSING RESOURCE: login_to_reply
Accept answer
Cancel