Lab 1 - Using D-Bug12
This lab will focus on using a simple debugging tool called the D-Bug12 Monitor. D-Bug12 is a software program that is burned into the Flash memory of the HCS12 chip and by default runs when the chip is first powered on. Using a serial communication program such as Hyperterminal, you can interact with D-Bug12 to use it for basic debugging. For instance, you can view the contents of registers and memory locations, you can generate simple assembly programs, and you can single-step through a program. During this lab, we will also start getting a feel for the registers and memory model of the HCS12, and will begin to use a bit of the Dragon12 hardware.
1-Prelab: Lab background
Note: for this lab and all future labs, the prelab should be turned in before you begin working on the main lab section. For each week's lab, you will need to turn in that week's prelab in order to check out a Dragon12 board. Prelabs will not be accepted during or after your checkout slot.
For this week's pre-lab, show how you would convert the following bit patterns in to hex and vice versa. For instance, the 8-bit pattern "00111011" corresponds to hex "3B". In Motorola (now Freescale) notation, we write binary with a leading percent "%" sign, and hex with a leading dollar "$" sign. So, for the above example, we would write %00111011 = $3B. In 16 bit, we would write %0011010011110110 = $34F6. Note that each memory location in the HCS12 has a 16 bit memory address, such as $2FE7 which holds an 8 bit value, such as $39. So, we will often use both 8 bit and 16 bit values during the course.
Bit/hex patterns to convert:
1. %10100101 = ?
2. %11110011 = ?
3. $79 = ?
4. $AB = ?
5. $F734 = ?
6. %1011111011101111 = ?
Your pre-lab should only be one page long, and may be handwritten or computer generated. Make sure to include your name, date, class number, etc.
2-Tutorials
3 - Program
Using DBug12, write a small assembly program that begins at address $2200 that will add the two numbers: -24 decimal (you convert to hex, 2's complement form) and +24 decimal (hex 2's complement). Place the results in accumulator A. Show the TA the completed D-Bug12 program and demonstrate that it runs without error and gives the correct results using the "go" command. Also, record the contents of each register (PC, SP, X,Y and D) before and after running the program, and be prepared to explain the register contents to the TA. Reset the board and run the program using the trace 't' command. Record the values of each register (PC, SP, X, Y and D) after running each 't' command, and be prepared to explain the results of each step to the TA.
4-What to Hand In
At the next lab, hand in a brief report that lists the above DBug12 program you did in Part 3 of the lab. For each line of assembly, explain what the instruction does and list the contents of each register (PC, SP, X, Y and D) after each assembly instruction has completed (i.e, list the register contents after each 't' command). The report may be computer generated or neatly handwritten. Include your name, date, class number and ID. Only a single page report is needed, so don't bother with a cover sheet or anything.