ARM.SoC.Architecture

17 an example of packed struct memory allocation run

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ized, the program starts with a call to main (). Program termination. Most programs terminate by calling _exit (); even a program which runs forever should terminate if an error is detected. The total size of the code generated for this minimal library is 736 bytes, and it is implemented in a way that allows the linker to omit any unreferenced sections to reduce the library image to around half a kilobyte in many cases. This is a great deal smaller than the full ANSI C library. 186 Architectural Support for High-Level Languages 6.11 Examples and exercises Write, compile and run a 'Hello World' program written in C. The following program has the required function: /* Hello World in C */ #include <stdio.h> int main() { Example 6.1 printf( "Hello World\n" ); return ( 0 ); } The principal things to note from this example are: The '#include' directive which allows this program to use all the standard input and output functions available in C. The declaration of the 'main' procedure. Every C program must have exactly one of these as the program is run by calling it. The 'printf (. .}' statement calls a function provided in stdio which sends output to the standard output device. By default this is the display terminal. As with the assembly programming exercises, the major challenge is to establish the flow through the tools from editing the text to compiling, linking and running the program. Once this program is working, generating more complex programs is fairly straightforward (at least until the complexity reaches the point where the design of the program becomes a challenge in itself). Using the ARM software development tools, the above program should be saved as 'HelloW.c'. Then a new project should be created using the Project Manager and this file added (as the only file in the project). A click on the 'Build' button will cause the program to be compiled and linked, then the 'Go' button will run it on the ARMulator, hopefully giving the expected output in the t...
View Full Document

Ask a homework question - tutors are online