05.02.2013 Views

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The System Level Programmers’ Model<br />

In both cases, the behavior in earlier architecture versions is a branch that remains in the same<br />

instruction set state. For more information, see:<br />

— Interworking on page AppxG-4, for <strong>ARM</strong>v6<br />

— Interworking on page AppxH-5, for <strong>ARM</strong>v5 <strong>and</strong> <strong>ARM</strong>v4.<br />

Pseudocode details of <strong>ARM</strong> core register operations<br />

The following pseudocode gives access to the general-purpose registers:<br />

// The names of the banked core registers.<br />

enumeration RName {RName_0usr, RName_1usr, RName_2usr, RName_3usr, RName_4usr, RName_5usr,<br />

RName_6usr, RName_7usr, RName_8usr, RName_8fiq, RName_9usr, RName_9fiq,<br />

RName_10usr, RName_10fiq, RName_11usr, RName_11fiq, RName_12usr, RName_12fiq,<br />

RName_SPusr, RName_SPfiq, RName_SPirq, RName_SPsvc,<br />

RName_SPabt, RName_SPund, RName_SPmon,<br />

RName_LRusr, RName_LRfiq, RName_LRirq, RName_LRsvc,<br />

RName_LRabt, RName_LRund, RName_LRmon,<br />

RName_PC};<br />

// The physical array of banked core registers.<br />

//<br />

// _R[RName_PC] is defined to be the address of the current instruction. The<br />

// offset of 4 or 8 bytes is applied to it by the register access functions.<br />

array bits(32) _R[RName];<br />

// RBankSelect()<br />

// =============<br />

RName RBankSelect(bits(5) mode, RName usr, RName fiq, RName irq,<br />

RName svc, RName abt, RName und, RName mon)<br />

if BadMode(mode) then<br />

UNPREDICTABLE;<br />

else<br />

case mode of<br />

when ‘10000’ result = usr; // User mode<br />

when ‘10001’ result = fiq; // FIQ mode<br />

when ‘10010’ result = irq; // IRQ mode<br />

when ‘10011’ result = svc; // Supervisor mode<br />

when ‘10110’ result = mon; // Monitor mode<br />

when ‘10111’ result = abt; // Abort mode<br />

when ‘11011’ result = und; // Undefined mode<br />

when ‘11111’ result = usr; // System mode uses User mode registers<br />

return result;<br />

// RfiqBankSelect()<br />

// ================<br />

RName RfiqBankSelect(bits(5) mode, RName usr, RName fiq)<br />

return RBankSelect(mode, usr, fiq, usr, usr, usr, usr, usr);<br />

B1-12 Copyright © 1996-1998, 2000, 2004-2008 <strong>ARM</strong> Limited. All rights reserved. <strong>ARM</strong> DDI 0406B

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

Saved successfully!

Ooh no, something went wrong!