RealView Compilation Tools Developer Guide - ARM Information ...
RealView Compilation Tools Developer Guide - ARM Information ...
RealView Compilation Tools Developer Guide - ARM Information ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
处 理 处 理 器 异 常<br />
上 下 文 切 换<br />
第 6-35 页 的 示 例 6-19 实 现 了 在 用 户 模 式 下 的 环 境 切 换 。 其 代 码 是 基 于 指 向 它 要<br />
运 行 的 过 程 的 过 程 控 制 块 (PCBs) 指 针 列 表 。<br />
图 6-5 展 示 了 示 例 所 期 望 的 PCB 布 局 。<br />
图 6-5 PCB 布 局<br />
指 向 下 一 个 要 运 行 的 过 程 的 PCB 指 针 是 由 r12 完 成 的 , 且 该 项 列 表 末 尾 有 一 零<br />
指 针 。r13 寄 存 器 是 指 向 PCB 的 指 针 , 并 在 一 小 段 时 间 间 隔 被 保 存 , 因 而 , 进 入<br />
时 它 指 向 现 行 运 行 过 程 的 PCB。<br />
示 例 6-19<br />
STMIA r13, {r0 - r14}^ ; Dump user registers above r13.<br />
MRS r0, SPSR ; Pick up the user status<br />
STMDB r13, {r0, lr} ; and dump with return address below.<br />
LDR r13, [r12], #4 ; Load next process info pointer.<br />
CMP r13, #0 ; If it is zero, it is invalid<br />
LDMNEDB r13, {r0, lr}<br />
; Pick up status and return address.<br />
MSRNE SPSR_cxsf, r0 ; Restore the status.<br />
LDMNEIA r13, {r0 - r14}^ ; Get the rest of the registers<br />
NOP<br />
SUBNES pc, lr, #4<br />
; and return and restore CPSR.<br />
; Insert "no next process code" here.<br />
<strong>ARM</strong> DUI 0203BSC © 2002、 2003 <strong>ARM</strong> Limited 版 权 所 有 。 保 留 所 有 权 利 。 6-35