Non-Confidential | ![]() | ARM DUI0472J | ||
| ||||
Home > Compiler-specific Features > __semihost intrinsic |
This intrinsic inserts an SVC
or BKPT
instruction into the instruction stream generated by the compiler. It enables you to make semihosting calls from C or C++ that are independent of the target architecture.
int __semihost(int
val
, const void
*ptr
)
Where:
Is the request code for the semihosting request.
See Developing Software for ARM Processors for more information.
Is a pointer to an argument/result block.
See Developing Software for ARM Processors for more information.
See Developing Software for ARM Processors for more information on the results of semihosting calls.
Use this intrinsic from C or C++ to generate the appropriate semihosting call for your target and instruction set:
0x123456
In ARM state for all architectures.
0xAB
In Thumb state, excluding M-profile architectures. This behavior is not guaranteed on all debug targets from ARM or from third parties.
0xAB
For M-profile architectures (Thumb only).
ARM processors prior to ARMv7 use SVC
instructions to make
semihosting calls. However, if you are compiling for a Cortex M-profile processor,
semihosting is implemented using the BKPT
instruction.
char buffer[100]; ... void foo(void) { __semihost(0x01, (const void *)buf); // equivalent in thumb state to // int __svc(0xAB) my_svc(int, int *); // result = my_svc(0x1, &buffer); }
Compiling this code with the option --thumb
generates:
||foo|| PROC ... LDR r1,|L1.12| MOVS r0,#1 SVC #0xab ... |L1.12| ... buffer % 400