Arm Community
Site
Search
User
Site
Search
User
Groups
Arm Research
DesignStart
Education Hub
Graphics and Gaming
High Performance Computing
Innovation
Multimedia
Open Source Software and Platforms
Physical
Processors
Security
System
Software Tools
TrustZone for Armv8-M
中文社区
Blog
Artificial Intelligence
Automotive
Healthcare
HPC
Infrastructure
Innovation
Internet of Things
Machine Learning
Mobile
Smart Homes
Wearables
Forums
All developer forums
IP Product forums
Tool & Software forums
Pelion IoT Platform
Activity
Support
Open a support case
Documentation
Downloads
Training
Arm Approved program
Arm Design Reviews
More
Cancel
Developer Community
IP Products
System
Jump...
Cancel
System
Embedded forum
LDR Instruction
Blogs
Forums
Videos & Files
Help
Jump...
Cancel
New
State
Not Answered
Replies
2 replies
Subscribers
141 subscribers
Views
2500 views
Users
0 members are here
Architecture
Instruction Set
Thumb
Thumb2
Related
LDR Instruction
Offline
subin t
over 6 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
Offline
Jacob Bramley
over 6 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
Up
0
Down
Reply
Accept answer
Cancel
0
Offline
Peter Harris
over 6 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
Up
0
Down
Reply
Accept answer
Cancel
More questions in this forum
By title
By date
By reply count
By view count
By most asked
By votes
By quality
Descending
Ascending
All recent questions
Unread questions
Questions you've participated in
Questions you've asked
Unanswered questions
Answered questions
Questions with suggested answers
Questions with no replies
Suggested Answer
optimize scaling that involves float division in M0
0
Cortex-M0
Floating-Point Execution
4030
views
2
replies
Latest
26 days ago
by
Broeker
Not Answered
PADDR
0
APB
vhdl
AMBA 3 APB Interface
1343
views
1
reply
Latest
29 days ago
by
Colin Campbell
Not Answered
ABP wrapper/ resizer 32-128 bit FPGA SoC
0
APB
vhdl
128-bit
SoC FPGA
1128
views
0
replies
Started
1 month ago
by
Rann
Not Answered
Semihosting 3.0
0
1822
views
2
replies
Latest
1 month ago
by
koendv
Answered
ARM CCN (Cache Coherent Network) question
0
CoreLink CCN-512 Cache Coherent Network
3550
views
2
replies
Latest
1 month ago
by
MarekBykowski
<
>
View all questions in Embedded forum