EE 308 - LAB 3
Final version for 2000
Assembly Language Programming
Introduction and Objectives
The purpose of this lab is to write a few assembly language
programs and test them on the simulator and on your EVBU.
Make sure you have the programs clearly thought out and written down before
you come to lab. You should put all your code starting at memory location
0x0800. You are encouraged to bring the programs in on disk.
As in last week's lab you will write some programs in assembly language
and run the programs on the HC12 simulator and the EVBU. To make sure your
programs work you will use D-Bug 12 op codes as your input data. There is
one problem when running programs on the simulator - D-Bug 12 code which
is present in the EVBU is not on the simulator. We can fix this problem by
loading D-Bug 12 into the simulator. The following tells you how to do that.
- Copy the file dbug12.h12 from the n:\ee308
- Start the ZAP simulator. Load the file
Write and run the following programs:
- Write a program which writes an 0xff to address 0x0002,
and then increments address 0x0000 indefinitely. (Note: this is a
Test your program both on the simulator and the EVBU. Trace through the
program on the simulator and observe what happens to the data at address 0x0000.
Check that the port PA lines are being toggled on your EVBU. (Use a logic
probe to verify that the Port PA lines are toggling.)
- Write a program to swap the last element of an array with the first element,
the next-to-last element with the second element, etc. The array should have
0x20 eight-bit numbers and should start at 0x0900. (This is
a problem from the homework due Feb. 9.)
Check that your program works both on the simulator and
the EVBU. Us the following data for your test:
- Write a program to determine the number of negative numbers in a table.
The starting address of the table is 0x8000 and the ending address is 0xbfff.
Each element in the table should be considered to be an eight-bit signed
number. Save the answer at address 0x0900. (This is a problem from the homework due feb. 9.)
Test your program on the simulator and the EVBU. What is the value of the
sum stores at 0x0900?
- Write a program that puts the largest one-byte signed number from memory
locations 0xFCE0 through 0xFCFF in accumulator A and
memory location 0x0900. (Note: The largest one-byte signed number
is 0x7f = 12710.) Test your program on the simulator and EVBU.
Loading Programs into EEPROM
You can load programs into the on-chip EEPROM. When loaded in
your program will remain on your HC12 even after turning off power.
Before loading your program into EEPROM, you must re-assemble it
after modifying your program to start your code at address
0x0D00. Also, modify your LKF link file to start the .text
section at address 0x0D00
The details of how to download your program into EEPROM are given in the
Universal Evaluation Board User's Manual in Appendix E, and are
summarized here, with a description of how to make this work with our
- Modify your program to put the code at address 0x0D00. Add this
instruction as the first instruction in your program:
Leave the data at address 0x0900. Modify your lkf link file to
put the .text section at address 0x0D00.
- Make sure you are talking to your EVBU with a Windows 3.11 Terminal. (The
Windows 95/98/NT Hyperterminal will not work for this).
- Move jumpers
W3 and W4 to their other position, then reset your board.
- On the Windows 3.11 Terminal menu bar, select Settings, Text
Transfer, Line at a Time, Wait for Prompt String, and type in a
``*'' as your prompt string (without the quotes).
- From the HC12 command
prompt, type L (for LoadEE). Go to the Transfers menu,
choose Send Text File, and send your S19 file which was assembled
to load the program into EEPROM.
- After the HC12 responds Programmed,
hit the STOP icon at the bottom of the Terminal window, then change your
Terminal Text Transfer settings back to Standar Flow Control.
- Move your W3 and W4 jumpers back to their original position, and
reset your EVBU.
- At the HC12 prompt, examine the contents of memory starting at location
0x0D00 and verify that your program has been loaded into EEPROM.
After the code is in the EEPROM, you can run it in one of two ways -
1) From D-Bug 12, set the program counter to 0x0D00 and `g` (or `g 0D00`); or 2) Move jumper W3 to its other position, and
reset or power-cycle the EVBU. (Note that if you
run your program using method 2, you cannot easily re-enter D-Bug 12 to check the results of your program. We will use method 2
in later labs where we won't need to re-enter D-Bug 12 after
running a program.)
- Load your last program (which finds the highest signed number)
into EEPROM. Run it by giving the G 0D00 command from D-Bug 12. Verify that the performance is the same as when you ran
it from RAM.
- Turn off power to your EVBU. Turn power back on, and rerun your
program by giving the g 0D00 command from D-Bug 12.
Verify that your program stayed in EEPROM.