Lab 2 - Using Code Warrior
 
In this lab, we are going to create our first program using Code Warrior, and then load and run it on the Dragon12 board. This is an important lab as all subsequent labs will follow steps similar to that shown here. So, take the time to make sure you are comfortable with the general procedure outlined in this lab. Remember, the TAs are there to help, so feel free to call on them when you have a question.
 
 
1-Prelab: Lab background
 
For the pre-lab, write a brief description or outline of the general steps necessary to create an executable program using the assembly language. You may want to have a look at the tutorial on assembling a program. Please do not cut/past/copy from that web page - put it in your own words.
 
 
2-Tutorials
 
(a) Read and do the tutorial "Creating a New Project Using Stationery". In that demo, you will create a project called "demo2_hcs12", and then create a simple program that will light some LEDs on the Dragon12.
 
*** NB: Whenever you create a Code Warrior program or project, make sure to save it in your project directory on the network drive. One suggestion is to creater a "master" folder called "ee3176" in your network drive, and then save each individual project or lab within this folder. For instance, after following the above steps, you would have a folder called "demo2_hcs12" in your "ee3176" folder on your network drive. After completing the lab below, you would have an additional folder called "lab2" in your "ee3176" folder. Good housekeepeing of your computer files is a basic skill you need to know.
 
(b) Read and do the DBug12 Program Demo tutorial. This tutorial tells you how to load a program into the Dragon12 using DBug12. You should be able to get the program to run correctly and light the LEDs on the Dragon12 board. You will be using DBug12 a lot in this course, so take your time to understand what you are doing. Feel free to bug the TA if you have any questions.
 
3 - Program
 
   1. Following the steps outlined in the hcs12 stationery tutorial noted above, create a new project called "lab2" from the ee3176 stationery.
   2. In the "Linker for HCS12" target panel settings, choose "Absolute, single file assembly project" and name it "lab2.abs". We have set up the project so that your executable s1 record that we load into the Dragon12 will be called "lab2.abs.s1".
   3. In the Project Files windows, open (double click) the file "labx_hcs12.asm" and then Save As "lab2.asm".
   4. Open the assembly file "lab2.asm" that you just created, and copy in the source code from "demo2_hcs12.asm" (you can just cut/paste the code from the web page). Change the header comments, etc. to reflect your name, the name of the program, date, etc.
   5. Modify your program so that it adds three numbers, and stores the result in "res1" and writes the result to port B. The first two numbers, "num1" and "num2" are as in the original program ($18 and $2A), and the third number is "num3 = D" (hex). So we are doing "num1 + num2 + num3 = res1" and writing the result "res1" to Port B to light up the LEDs there. Hint: you should only have to add two lines to the program: one directive line and one source code line..
   6. Assemble the program, load it into the Dragon12 using the DBug12 "load" command, and then run the program using "g 1000" under DBug12. Once the program assembles and runs OK, do your check out with the TA.


 
4-What to Hand In
 
At the next lab, hand in the commented code from your program from Step 3 above. All programs must have "header" comments (the main comments that lead a program) that include your: (1) name; (2) date; (3) class (eg, UTEP EE3176);(4) the name of the program (eg, "lab2.asm"); and (5) what the program does. In addition, there should be comments throughout your program that describe what the main sections of code do. The rule of thumb is that you should be able to look at your code one year from now and figure out what it is doing by reading the comments and code.
 
*** Your code comments are important and will form a significant proportion of your lab grade, so take your time to do them carefully. As a general rule, you should be able to look at your code comments at a distant time, say a year from now, and understand what the program is doing.
EE3376 Lab 2