1
|
To create a new project, choose Project>Create New Project. The Create New Project dialog box appears, which lets you base your new project on a project template.
|
2
|
3
|
For this tutorial, select the project template Empty project, which simply creates an empty project that uses default project settings.
|
4
|
In the standard Save As dialog box that appears, specify where you want to place your project file, that is, in your newly created projects directory. Type project1 in the File name box, and click Save to create the new project.
|
5
|
Before you add any files to your project, you should save the workspace. Choose File>Save Workspace and specify where you want to place your workspace file. In this tutorial, you should place it in your newly created projects directory. Type tutorials in the File name box, and click Save to create the new workspace.
|
|
The Tutor.c application is a simple program using only standard features of the C language. It initializes an array with the ten first Fibonacci numbers and prints the result to stdout.
|
|
1
|
In the Workspace window, select the destination to which you want to add a source file; a group or, as in this case, directly to the project.
|
2
|
Choose Project>Add Files to open a standard browse dialog box. Locate the files Tutor.c and Utilities.c, select them in the file selection list, and click Open to add them to the project1 project.
|
1
|
Select the project folder icon project1 - Debug in the Workspace window and choose Project>Options. In this tutorial you should use the default settings.
|
2
|
3
|
Verify that the default settings are used. In addition to the default settings, click the List tab, and select the options Output list file and Assembler mnemonics. Click OK to set the options you have specified.
|
1
|
To compile the file Utilities.c, select it in the Workspace window.
|
2
|
Choose Project>Compile.
|
3
|
Compile the file Tutor.c in the same manner.
|
|
The List directory is the destination directory for the list files. The list files have the extension lst.
|
|
The Obj directory is the destination directory for the object files from the compiler and the assembler. These files have the extension rxx and are used as input to the XLINK linker. For the ILINK linker, the corresponding filename extension is o.
|
|
The Exe directory is the destination directory for the executable file. It has the extension dxx (for XLINK) and out (for ILINK), and is used as input to the IAR C-SPY® Debugger. Note that this directory is empty until you have linked the object files.
|
1
|
Open the list file Utilities.lst by double-clicking it in the Workspace window. Examine the list file, which contains the following information:
|
|
The header shows the product version, information about when the file was created, and the command line version of the compiler options that were used
|
|
The body of the list file shows the assembler code and binary code generated for each statement. It also shows how the variables are assigned to segments
|
|
The end of the list file shows the amount of stack, code, and data memory required, and contains information about error and warning messages that might have been generated.
|
2
|
Choose Tools>Options to open the IDE Options dialog box and click the Editor tab. Select the option Scan for changed files. This option turns on the automatic update of any file open in an editor window, such as a list file.
|
3
|
Select the file Utilities.c in the Workspace window, right-click and choose Options from the context menu to open the C/C++ Compiler options dialog box. Select the Override inherited settings option. Click the Optimizations tab and choose High level of optimization. Click OK.
|
4
|
Compile the file Utilities.c. Now you will notice two things. First, note the automatic updating of the open list file due to the selected option Scan for changed files. Second, look at the end of the list file and notice the effect on the code size due to the increased optimization.
|
5
|
For this tutorial, the optimization level None should be used, so before linking the application, restore the default optimization level. Open the C/C++ Compiler options dialog box by right-clicking on the selected file in the Workspace window. Deselect the Override inherited settings option and click OK. Recompile the file Utilities.c.
|
1
|
Select the project folder icon project1 - Debug in the Workspace window and choose Project>Options, or righ-click and choose Options from the context menu. Then select Linker in the Category list to display the linker option pages.
|
2
|
Click OK to save the linker options.
|
3
|
Choose Project>Make. The progress will as usual be displayed in the Build messages window. The result of the linking is the code file project1.dxx with debug information located in the Debug\Exe directory and a map file project1.map located in the Debug\List directory.
|
|
XLINK can generate a map file which optionally contains a segment map, symbol listing, module summary, etc
|
|
ILINK can generate a map file, which typically contains a placement summary. ILINK can also generate a log file, which logs decisions made by the linker regarding initializations, module sections, section select, etc.
|