Assembling Assembly Source-code Files

Let's assemble the main.asm file.

  1. Select File > Assemble from the menu bar.
  2. The Select File to Assemble dialog box appears. Browse to the Sources folder in the project directory and select the main.asm file.

    The following image shows main.asm file.

    Figure 1. Select File to Assemble Dialog Box
    Select File to Assemble Dialog Box
  3. Click Open.

The main.asm file starts assembling.

The following image shows the result of assembling of main.asm file.

Figure 2. Results of Assembling main.asm File
Results of Assembling main.asm File

The project window provides information about the assembly process or generates error messages if the assembly was unsuccessful. In this case, the A2309 File not found error message is generated. As the following image displays, if you right-click on the text containing the error message, a context menu appears.

Note: If you get any other types of errors, make sure the main.asm file is modified as shown in Listing: main.asm File.
Figure 3. Context Menu
Context Menu

Select Help on "file not found" and help for the A2309 error message appears, as the following image displays.

Figure 4. A2309: File not found
A2309: File not found

You know that the file exists because it is included in the Sources folder that you imported into the project directory. The help message for the A2309 error states that the Assembler is looking for this "missing" include file first in the current directory and then in the directory specified by the GENPATH environment variable. This suggests that the GENPATH environment variable should specify the location of the derivative.inc include file.

Note: If you read the main.asm file, you could have anticipated this on account of this statement on line 20: INCLUDE 'derivative.inc'.

To fix this error:

  1. Select File > Configuration.
  2. The Configuration dialog box appears (refer to the figure listed below). Click the Environment tab and then select General Path.
  3. Press the " ..." button and navigate in the Browse for Folder dialog box for the folder that contains the derivative.inc file - the Sources folder in the project directory.
    Figure 5. Browsing for Sources Folder
    Browsing for Sources Folder
  4. Click OK to close the Browse for Folder dialog box.
  5. The Configuration dialog box is active again (refer to the figure listed below). Click the Add button.

    The path to the derivative.inc file " D:\Projects\Model T\Sources" appears in the area below the Add button.

    Figure 6. Adding GENPATH
    Adding GENPATH
  6. Click OK.

    An asterisk appears in the title bar of the Assembler window, so save the change to the configuration.

  7. Click the Save button in the toolbar or select File > Save Configuration.

    The asterisk disappears.

The new path is updated in the derivative.inc file.

Tip: You can clear the messages in the Assembler window at any time by selecting View > Log > Clear Log.

Now that you have supplied the path to the derivative.inc file, assemble the main.asm file again.

Select File > Assemble and again navigate to the main.asm file and click Open. However, the A2309 error message reappears but this time for a different include file - mc9s08ac128.inc.

Note: In this case, the derivative.inc file has this statement: INCLUDE 'mc9s08ac128.inc'. Therefore, a prior reading of the assembly-code and include files suggests these include files might require GENPATH configurations. If possible, set any needed GENPATH in advance of assembling the source-code files.
Figure 7. Assemble Attempt #2
Assemble Attempt #2

Fix this by repeating the GENPATH routine for the other include file. The mc9s08ac128.inc file is located at this path:

<CWInstallDir>\MCU\lib\hc08c\device\asm_include

CWInstallDir is the directory in which the CodeWarrior software is installed.

The asm_include folder is the typical place for missing include files.

After the GENPATH is set up for the second include file and saved as before, you can try to assemble the main.asm file for the third time.

The Macro Assembler indicates successful assembling and indicated that the Code Size was 39 bytes. The message *** 0 error(s), indicates that the main.asm file assembled without errors. Do not forget to save the configuration one additional time.

The Assembler also generated a main.dbg file (for use with the Simulator/Debugger), a main.o object file (for further processing with the Linker), and a main.lst output listing file in the project directory. The binary object-code file has the same name as the input module, but with the *.o extension - main.o. The debug file has the same name as the input module, but with the *.dbg extension - main.dbg and the assembly output listing file has the *.lst extension. The following image displays the project directory after the successful assembly of the project.

Figure 8. Project Directory After Successful Assembly
Project Directory After Successful Assembly

The ERR.TXT file is present in the project directory because of the earlier failed attempts at assembling. The ERR.TXT file is empty after a successful assembly. You can delete this file. The following listing shows the project.ini file.

Listing: project.ini file after GENPATH environment variable is created
[AHC08_Assembler]
StatusbarEnabled=1

ToolbarEnabled=1

WindowPos=0,1,-32000,-32000,-1,-1,290,513,903,833

EditorType=4

Options=-F2 -L=%(TEXTPATH)\%n.lst -Li

CurrentCommandLine=""D:\Projects\Model T\Sources\main.asm""

RecentCommandLine0=""D:\Projects\Model T\Sources\main.asm""

RecentCommandLine1=D:\Workspace\test\Sources\main.asm

[Environment Variables]

GENPATH=C:\Freescale\CW MCU 
v10.3\MCU\lib\hc08c\device\asm_include;D:\Projects\Model T\Sources

OBJPATH=

TEXTPATH=

ABSPATH=

LIBPATH=

The haphazard running of this project was intentionally designed to fail to illustrate what occurs if the path of any include file is not properly configured. Be aware that include files may be included by either *.asm or *.inc files. In addition, remember that the lib folder in the CodeWarrior installation contains several derivative-specific include and prm files available for inclusion into your projects.