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
2-Tutorials
*** 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.
3 - Program
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.