29.12.2014 Views

RealView Compilation Tools Compiler Reference Guide - ARM ...

RealView Compilation Tools Compiler Reference Guide - ARM ...

RealView Compilation Tools Compiler Reference Guide - ARM ...

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>Compiler</strong>-specific Features<br />

Usage<br />

Use this intrinsic from C or C++ to generate the appropriate semihosting call for your<br />

target and instruction set:<br />

SVC 0x123456<br />

SVC 0xAB<br />

BKPT 0xAB<br />

In <strong>ARM</strong> state for all architectures.<br />

In Thumb state, excluding <strong>ARM</strong>v7-M. This behavior is not<br />

guaranteed on all debug targets from <strong>ARM</strong> or from third parties.<br />

For <strong>ARM</strong>v7-M, Thumb-2 only.<br />

Restrictions<br />

<strong>ARM</strong> processors prior to <strong>ARM</strong>v7 use SVC instructions to make semihosting calls.<br />

However, if you are compiling for the Cortex-M3 processor, semihosting is<br />

implemented using the BKPT instruction.<br />

Example<br />

char buffer[100];<br />

...<br />

void foo(void)<br />

{<br />

__semihost(0x01, (const void *)buf); // equivalent in thumb state to<br />

// int __svc(0xAB) my_svc(int, int *);<br />

// result = my_svc(0x1, &buffer);<br />

}<br />

Compiling this code with the option --thumb generates:<br />

||foo|| PROC<br />

...<br />

LDR<br />

MOVS<br />

SVC<br />

...<br />

r1,|L1.12|<br />

r0,#1<br />

#0xab<br />

|L1.12|<br />

...<br />

buffer<br />

% 400<br />

See also<br />

• --cpu=list on page 2-15<br />

• --thumb on page 2-86<br />

• __svc on page 4-16<br />

4-86 Copyright © 2007, 2010 <strong>ARM</strong> Limited. All rights reserved. <strong>ARM</strong> DUI 0348A<br />

Non-Confidential

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

Saved successfully!

Ooh no, something went wrong!