When creating a new embedded application, it can sometimes be useful during the early stages of development to be able to output debug status messages to indicate what is happening as your application executes.
Traditionally, this might be done by piping the messages over, say, a serial cable connected to a terminal program running on your PC. LPCXpresso also offers an alternative to this, called semihosting. Semihosting provides a mechanism for code running on the target board to use the facilities of the PC running the IDE. The most common example of this is for the strings passed to a printf being displayed in the IDE's console view.
The term "semihosting" was originally termed by ARM in the early 1990s, and basically indicates that part of the functionality is carried out by the host (the PC with the debug tools running on it), and partly by the target (your board). The original intention was to provide i/o in a target environment where no real peripheral-based i/o was available at all.
The way it is actually implemented by the tools depends upon which target CPU you are running on. With Cortex-M based MCUs, the bottom level of the C library contains a special BKPT instruction. The execution of this is trapped by the debug tools which determine what operation is being requested - in the case of a printf, for example, this will effectively be a "write character to stdout". The debug tools will then read the character from the memory of the target board - and display it in the console window within the IDE.
Semihosting also provides support for a number of other I/O operations. For example it provides the ability for scanf to read its input from the IDE console. It also allows file operations, such that fopen can open a file on your PC's hard drive, and fscanf can then be used to read from that file.
On ARM7/9 based targets the same principles of working are used, but implemented using the SWI / SVC instruction rather than the BKPT.
It is fair to say that the semihosting mechanism does not provide a high performance i/o system. Each time a semihosting operation takes place, the processor is basically stopped whilst the data transfer takes place. The time this takes depends somewhat on the target CPU, the debug probe/link (thus Red Probe+ provides a much enhanced semihosting speed over LPC-Link), the PC hardware and the PC operating system. But it takes a definite period of time, which may make your code appear to run more slowly.
When you have linked with the semihosting library, your application will no longer work standalone - it will only work when connected to the debugger.
Semihosting operations cause the CPU to drop into "debug state", which means that for the duration of the data transfer between the target and the host PC no code (including interrupts) will get executed on the target. Thus if you application uses interrupts, then it is normally advisable to avoid the use of semihosting whilst interrupts are active. If you still need to use printf, then you can retarget the bottom level of the C library to use an alternative communication channel, such as a UART.
The semihosting mechanism used within LPCXpresso based on the specification contained in the following document available from ARM's website...
=> ARM Developer Suite (ADS) v1.2 Debug Target Guide, Chapter 5. Semihosting
For more information...