Keil Logo

The semihosting interface

11.2 The semihosting interface

The ARM and Thumb SVC instructions contain a field that encodes the SVC number used by the application code.


If you are compiling for the ARMv6-M or ARMv7-M, the Thumb BKPT instruction is used instead of the Thumb SVC instruction. Both BKPT and SVC take an 8-bit immediate value. In all other respects, semihosting is the same for all supported ARM processors.
The system SVC handler can decode the SVC number. Semihosting operations are requested using a single SVC number, leaving the other numbers available for use by the application or operating system. The SVC number used for semihosting depends on the target architecture or processor:
SVC 0x123456
In ARM state for all architectures.
In ARM state and Thumb state, excluding ARMv6-M and ARMv7-M. This behavior is not guaranteed on all debug targets from ARM or from third parties.
For ARMv6-M and ARMv7-M, Thumb state only.
The SVC number indicates to the debug agent that the SVC instruction is a semihosting request. To distinguish between operations, the operation type is passed in R0. All other parameters are passed in a block that is pointed to by R1.
The result is returned in R0, either as an explicit return value or as a pointer to a data block. Even if no result is returned, assume that R0 is corrupted.
The available semihosting operation numbers passed in R0 are allocated as follows:
Used by ARM.
Reserved for future use by ARM.
Reserved for user applications. These are not used by ARM.
If you are writing your own SVC operations, however, you are advised to use a different SVC number rather than using the semihosted SVC number and these operation type numbers.
Undefined and currently unused. It is recommended that you do not use these.
In the following sections, the number in parentheses after the operation name is the value placed into R0, for example SYS_OPEN (0x01).
If you are calling SVCs from assembly language code ARM recommends that you define the semihosting operation names, to their respective operation numbers, with the EQU directive. For example:
SYS_OPEN    EQU 0x01
Non-ConfidentialPDF file icon PDF versionARM DUI0375H
Copyright © 2007, 2008, 2011, 2012, 2014-2016 ARM. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.