Final version for 2001
More Assembly Language Programming
Prelab
For the prelab, write the program discussed below.
The HC12 has several ports (A, B, AD, T, S, P and DLC) which can be used for various functions. For example, Port S is used for serial communications - you talk to the PC terminal through Port S. Port T is used for accessing the HC12 timer. We will discuss this more in class over the next few weeks. If a port is not used for its specific function, it can be used for general-purpose I/O - e.g., if you are not using timer functions, you can use Port T in a manner similar to the way you use Ports A and B. Port AD can only be used for input; all the other ports can be used for either input or output, by writing to the Data Direction Register for that port. In this week's lab you will need to use more I/O pins than are available on Ports A and B alone. (Note that you should not use bits 0 and 1 of Port AD, or bits 0 and 1 of Port S, since these are dedicated to other functions on your evaluation board.)
In this lab you are to write a program which will use the DIP switches to enter two numbers into the HC12, and use the LEDs to display the results of some operations using these numbers.
Connect eight bits of one of the HC12's Ports to the eight DIP switches on your breadboard. Connect eight bits of another of the Ports to the eight LEDs on your breadboard. Connect one pin of a third Port to one of the debounced switches on your breadboard. Write an assembly language program to do the following:
Bits 2,1,0 | Function |
0 0 0 | First number entered |
0 0 1 | Second number entered |
0 1 0 | Bitwise AND of the two numbers |
0 1 1 | Bitwise OR of the two numbers |
1 0 0 | Sum of the two numbers |
1 0 1 | N, Z, V and C bits from adding the two numbers |
1 1 0 | First number minus second number |
1 1 1 | N, Z, V and C bits from subtracting the two numbers |
Note that the HC12 should continue to monitor these bits, so you can look at any or all of the results.