This tutorial assumes that you are familiar with basic use of IAR Embedded Workbench; see the tutorial Getting Started using IAR Embedded Workbench.Contains utility routines required by Fibonacci.c for the Fibonacci calculations.
1 In the IDE, if Information Center is not open, choose Help>Information Center.
2 Click the Product explorer symbol.
3 Under the Language support heading, click Open tutorial workspace. Choose a destination for your project in the browse dialog box that appears. We recommend that you create a specific directory (with a subdirectory) where you store all your tutorial files, if you have not done that already. In this tutorial we call the directory MyTutorials and the subdirectory LanguageSupport.After you have chosen a destination directory, the LanguageSupport workspace is opened in the IDE.
4 In the Workspace window, select the MixingCandAssemblerModules project, right-click and choose Set as Active.In this example procedure, you will set up the compiler to create an assembler output file from the file Utilities.c.
1 In the Workspace window, select the file Utilities.c, right-click, and choose Options from the context menu.
2
4
5 Compile the file Utilities.c.
6 You can now find the file Utilities.s (or Utilities.sxx, depending on your product) in the Output folder. Open the file to examine the calling convention and to see how the C code is represented in assembler language.For more information about the calling convention used in the compiler, see the C/C++ Development Guide (or C/C++ Compiler User Guide, depending on your product).
1 In the Workspace window, update the MixingCandAssemblerModules project by adding the file Utilities.s (or Utilities.sxx, depending on your product) that you just created. In the Output folder, select the file, right-click and choose Open Containing Folder from the context menu. In the browse window that appears, select the file and drag it to the Workspace window, or more specifically, to the project where you want to add the file.
2 To exclude the file Utilities.c from the build (which is no longer needed), select the file in the Workspace window, right-click and choose Options from the context menu. In the Options dialog box, select Exclude from build.
3 In the Workspace window, select MixingCandAssemblerModules - Debug, right-click, and choose Options from the context menu. Use the default settings in the General Options, C/C++ Compiler, and Linker categories. Select the Assembler category, click the List tab, and make sure the option Output list file (or Generate list file, depending on your product) is selected.
4 In the Workspace window, select MixingCandAssemblerModules - Debug, right-click, and choose Rebuild All from the context menu. The project is built with the assembler file instead of with the corresponding C file.
5 To open the list file, double-click the file Utilities.lst available in the Output folder in the Workspace window.
1 Start C-SPY to execute the MixingCandAssemblerModules application.
2 In Fibonacci.c, position your cursor in the fib = GetFib(callCount); statement and choose Debug>Run to Cursor (alternatively, click the button ).Hover with the mouse pointer over CallCount to see its value.
3 Choose C/C++ Development Guide (or C/C++ Compiler User Guide, depending on your product) from the Help menu.In the PDF’s Bookmarks pane, navigate to Part 1, Assembler language interface, Calling convention, and click on Function entrance. Under the heading Register parameters, notice which registers that are used for parameters.
4 In the Disassembly window, notice the use of registers in the instructions leading up to the subroutine call.
5 Click the Step Into button (). Notice how the editor window now displays the assembler source code.
6 In the Registers window, notice how the used register(s) have been updated accordingly.