User guide

By default, the stack pointer sp is initialized to 0x08000000 for ARMulator. If you are using a development board,
you must set $top_of_memory. For example, for most (unexpanded) ARM Integrator boards, set
$top_of_memory to 0x40000.
6.4.2 Sample code
The C code fragment in Example 6-1 shows the use of semihosting SWIs to output text. See the main.c source
code for the definitions of demo_malloc(), demo_printf(), demo_float_print(), and demo_sprintf().
The code selected by the #ifdef EMBEDDED is used in Loading the ROM image at address 0 and other examples.
Example 6-1 extract from main.c
int main(void)
{
printf("C Library Example\n");
#ifdef EMBEDDED
/* ensure no C library functions that uses semihosting SWIs are linked */
#pragma import(__use_no_semihosting_swi)
#endif
demo_printf();
demo_sprintf();
demo_float_print();
demo_malloc();
return 0;
}
Writing Code for ROM
Copyright ?1999 2001 ARM Limited 6-7