Lab 1 version 2
ECE 4436
Spring 2009
Purpose: To learn to use Code Warrior’s simulator to build and test a previously developed
program project.
1. Before starting this lab, read the document at the link, “Laboratory Procedures,” found on
the course web site in the Laboratory Support area.
2. Read the document at the link, “Using CodeWarrior with Relocatable Assembly Language
Programs,” and follow its instructions for opening an existing project. Use it as a guide for
the steps below.
3. Prepare for the lab portion of this course by creating a \4436\Labs\ directory in your home
directory in your UH account, or in the My Documents directory on your home computer.
4. Download Lab1.zip from the Lab Assignments area of the course web site and unzip it into
your Labs directory, creating the Lab1 subdirectory containing the project you will use.
5. Launch Metrowerks CodeWarrior and choose Open… on the File menu. Browse to locate
the lab1.mcp project file in the Lab1 directory and open it.
6. Do each of the following tasks:
a. Open the main source file, main.asm, and edit it so that the variable first has a
different value.
b. Set the target connection to Full Chip Simulation and build the project, assembling
main.asm. You should get an error produced by the assembler.
c. Click on the error message and the line with the error(s) will be marked. Edit the line
to correct the obvious error, and build the project again. You should get no errors this
time. Hint: Fixing one error sometimes automatically fixes another.
d. Open the Debug window to begin testing the program in the Simulator.
e. Single-step the program, watching the values in the array table change with each
pass through the loop. Also notice how the register values change when the
instruction being executed requires it.
f. We would like to have an assembly listing file, main.lst, created by the assembler. To
set this up, choose Edit/P&E Multilink CyclonePro Settings… Then select
Target/Assembler for HC12, and click on the Options button. Now select the two
checkboxes for “Generate a listing file” and “Do not printed included files in listing
file.” Now click OK, then OK. Now when there is an error-free assembly, a listing
file main.lst is created in the bin subdirectory of the project directory.
g. Click the Make button to do an assembly and create the listing file. Choose Add
Files… on the Project menu, navigate to bin, select main.lst, and click on Open. This
will place a pointer to the main.lst file in the list of files on the Files tab, making it
more easily opened in the future. Double-click main.lst to open it. The “Obj. code”
column shows the assembled code, and the “Loc” column shows the corresponding
memory location/address.
h. On the Help menu, choose CodeWarrior Help. On the Contents tab, select
HC(S)12(X)/HC(S)12(X) Debugger. Scan this section to learn more about the
Debugger.
i. Save the finished project.