04.01.2015 Views

RealView Compilation Tools - ARM Information Center

RealView Compilation Tools - ARM Information Center

RealView Compilation Tools - ARM Information Center

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Compiler-specific Features<br />

Example<br />

void foo(void)<br />

{<br />

int was_masked = __disable_irq();<br />

/* ... */<br />

if (!was_masked)<br />

__enable_irq();<br />

}<br />

Restrictions<br />

The difference in function prototypes between the generic <strong>ARM</strong>v7 architecture and the<br />

<strong>ARM</strong>v7 A, R, and M-profiles exists because the way that the previous IRQ state is<br />

returned differs between the M-profile and the A and R-profiles. This means that when<br />

you compile with --cpu=7, the compiler is unable to generate an instruction sequence<br />

that works on all <strong>ARM</strong>v7 processors, so you must use the void __disable_irq(void);<br />

function prototype with --cpu=7.<br />

The following example illustrates the difference between compiling for <strong>ARM</strong>v7-M and<br />

<strong>ARM</strong>v7-R:<br />

/* test.c */<br />

void DisableIrq(void)<br />

{<br />

__disable_irq();<br />

}<br />

int DisableIrq2(void)<br />

{<br />

return __disable_irq();<br />

}<br />

armcc -c --cpu=Cortex-M3 --thumb -o m3.o test.c<br />

DisableIrq<br />

0x00000000: b672 r. CPSID i<br />

0x00000002: 4770 pG BX lr<br />

DisableIrq2<br />

0x00000004: f3ef8010 .... MRS r0,PRIMASK<br />

0x00000008: f0000001 .... AND r0,r0,#1<br />

0x0000000c: b672 r. CPSID i<br />

0x0000000e: 4770 pG BX lr<br />

armcc -c --cpu=Cortex-R4 --thumb -o r4.o test.c<br />

DisableIrq<br />

0x00000000: b672 r. CPSID i<br />

0x00000002: 4770 pG BX lr<br />

DisableIrq2<br />

<strong>ARM</strong> DUI 0348C Copyright © 2007-2010 <strong>ARM</strong>. All rights reserved. 4-81<br />

ID101213<br />

Non-Confidential,

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

Saved successfully!

Ooh no, something went wrong!