ARM Instruction Reference
ARM DUI 0068B
Copyright © 2000, 2001 ARM Limited. All rights reserved.
4-11
Saving from r15
In general, avoid saving from r15 if possible.
If you do save from r15, the value saved is the address of the current instruction, plus
an implementation-defined constant. The constant is always the same for a particular
processor.
If your assembled code might be used on different processors, you can find out what the
constant is at runtime using code like the following:
SUB R1, PC, #4 ; R1 = address of following STR instruction
STR PC, [R0] ; Store address of STR instr offset,
LDR R0, [R0] ; then reload it
SUB R0, R0, R1 ; Calculate the offset as the difference
If your code is to be assembled for a particular processor, the value of the constant is
available in
armasm
as
{PCSTOREOFFSET}
.
Architectures
These instructions are available in all versions of the ARM architecture.
In T variants of ARM architecture v5 and above, a load to r15 causes a change to
executing Thumb instructions if bit[0] of the value loaded is set.
Examples
LDR r8,[r10] ; loads r8 from the address in r10.
LDRNE r2,[r5,#960]! ; (conditionally) loads r2 from a word
; 960 bytes above the address in r5, and
; increments r5 by 960.
STR r2,[r9,#consta-struc] ; consta-struc is an expression evaluating
; to a constant in the range 0-4095.
STRB r0,[r3,-r8,ASR #2] ; stores the least significant byte from
; r0 to a byte at an address equal to
; contents(r3) minus contents(r8)/4.
; r3 and r8 are not altered.
STR r5,[r7],#-8 ; stores a word from r5 to the address
; in r7, and then decrements r7 by 8.
LDR r0,localdata ; loads a word located at label localdata
Содержание Developer Suite
Страница 10: ...Preface x Copyright 2000 2001 ARM Limited All rights reserved ARM DUI 0068B ...
Страница 110: ...Assembler Reference 3 32 Copyright 2000 2001 ARM Limited All rights reserved ARM DUI 0068B ...
Страница 185: ...ARM Instruction Reference ARM DUI 0068B Copyright 2000 2001 ARM Limited All rights reserved 4 75 Example MSR CPSR_f r5 ...
Страница 238: ...Thumb Instruction Reference 5 44 Copyright 2000 2001 ARM Limited All rights reserved ARM DUI 0068B ...
Страница 282: ...Vector Floating point Programming 6 44 Copyright 2000 2001 ARM Limited All rights reserved ARM DUI 0068B ...
Страница 360: ...Index Index 6 Copyright 2000 2001 ARM Limited All rights reserved ARM DUI 0068B ...