23.10.2014 Views

RealView - ARM Information Center

RealView - ARM Information Center

RealView - ARM Information Center

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ARM</strong> 指 令 参 考<br />

从 r15 中 保 存<br />

一 般 情 况 下 , 尽 可 能 避 免 从 r15 中 保 存 。<br />

如 果 确 实 保 存 了 r15 中 的 值 , 则 所 保 存 的 是 当 前 指 令 的 地 址 , 另 加 上 一 个 由 实 现<br />

定 义 的 常 数 。 对 于 特 定 的 处 理 器 , 该 常 数 总 是 相 同 的 。<br />

如 果 汇 编 代 码 可 以 用 在 不 同 的 处 理 器 上 , 可 以 用 类 似 以 下 的 代 码 来 查 看 该 常 数<br />

在 运 行 时 的 值 :<br />

SUB R1, PC, #4 ; R1 = address of following STR instruction<br />

STR PC, [R0] ; Store address of STR instruction + offset,<br />

LDR R0, [R0] ; then reload it<br />

SUB R0, R0, R1 ; Calculate the offset as the difference<br />

如 果 汇 编 代 码 要 用 于 某 个 特 定 处 理 器 上 , 在 armasm 中 可 以 用 {PCSTOREOFFSET} 获 得<br />

该 常 数 的 值 。<br />

体 系 结 构<br />

这 些 指 令 在 所 有 版 本 的 <strong>ARM</strong> 体 系 结 构 中 有 效 。<br />

在 v5 及 更 高 版 本 体 系 结 构 的 T 变 体 中 , 如 果 设 置 了 装 载 值 的 [0] 位 , 那 么 装 载<br />

到 r15 会 导 致 处 理 器 改 为 执 行 Thumb 指 令 。<br />

示 例<br />

LDR r8,[r10] ; loads r8 from the address in r10.<br />

LDRNE r2,[r5,#960]! ; (conditionally) loads r2 from a word<br />

; increments r5 by 960.<br />

STR r2,[r9,#consta-struc] ; consta-struc is an expression evaluating<br />

; to a constant in the range 0-4095.<br />

STRB<br />

r0,[r3,-r8,ASR #2] ; stores the least significant byte from<br />

; r0 to a byte at an address equal to<br />

; contents(r3) minus contents(r8)/4.<br />

; r3 and r8 are not altered.<br />

STR r5,[r7],#-8 ; stores a word from r5 to the address<br />

; in r7, and then decrements r7 by 8.<br />

LDR r0,localdata ; loads a word located at label localdata<br />

<strong>ARM</strong> DUI 0204BSC © 2002、 2003 <strong>ARM</strong> Limited 版 权 所 有 。 保 留 所 有 权 利 。 4-13

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!