Lab 6: Assembly Programming & Debugging with Motorola 68HC12 - Prof. Andrew Mason, Lab Reports of Electrical and Electronics Engineering

Lab 6 of ece 331 spring 2009 course, which focuses on assembly language programming and monitor-level debugging using the axiom manufacturing cml12s-dp256 development board for the motorola 68hc12 microcontroller. Students will learn the process of writing, assembling, downloading, and debugging assembly language programs. The lab covers the use of the mon12 monitor program and the cml12s-dp256 development board.

Typology: Lab Reports

Pre 2010

Uploaded on 07/28/2009

koofers-user-7iq-1
koofers-user-7iq-1 🇺🇸

5

(2)

8 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECE 331 Spring 2009
Lab 6: Assembly Language Programming and Monitor-level Debugging
Summary:
Demonstrate the process of writing, assembling, downloading, and monitor-level debugging
of assembly language programs using the Axiom Manufacturing CML12S-DP256
development board for the Motorola 68HC12 microcontroller.
Learning Objectives:
Review of assembly language syntax
Introduction to the MON12 monitor program
Introduction to the CML12S-DP256 development board
Resources and Supplies:
Text editor & 68HC12 assembler
MON12 monitor program
CML12S-DP256 development board
CML12S-DP256 MON12 manual
All documents are available on the class website
Important Reminders:
It is your responsibility to save the programs you create.
You will not need to bring your SRB to this or any remaining lab.
Pre-lab assignments must be completed before coming to the lab.
Background:
CML12S-DP256 development board
Axiom’s CML12S-DP256 is a development board for the Motorola MC6S12DP256
microcontroller which is a configuration of the 68HCS12 core with memory and I/O. The
CML12S-DP256 and associated software, particularly the MON12 embedded firmware
monitor program, provide a user interface to the microcontroller useful to debugging code
and testing microcontroller hardware functions. Assembled code in .S19 files can be loaded
to the controller through the MON12 program. Additional details can be found as needed in
the CML12S-DP256 MON12 manual.
The CML12S-DP256 provides a debug mode in which the debugger software (e.g.,
MON12) handles CPU initialization, interrupt vectors, and the stack. The memory map for
the CML12S-DP256 is shown on page 11 of the manual. The manual suggest using
external RAM starting at $4000 for storing user program code in the debug mode of
operation. It is suggested that program data be stored in internal RAM between $1000 and
$3DFF The MON12 debugger reserves the remaining part of internal RAM between $3E00
and $3FFD and starts the stack at $3F80.
Lab 6 p. 1
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Lab 6: Assembly Programming & Debugging with Motorola 68HC12 - Prof. Andrew Mason and more Lab Reports Electrical and Electronics Engineering in PDF only on Docsity!

Lab 6: Assembly Language Programming and Monitor-level Debugging

Summary: Demonstrate the process of writing, assembling, downloading, and monitor-level debugging of assembly language programs using the Axiom Manufacturing CML12S-DP development board for the Motorola 68HC12 microcontroller.

Learning Objectives:

  • Review of assembly language syntax
  • Introduction to the MON12 monitor program
  • Introduction to the CML12S-DP256 development board

Resources and Supplies:

  • Text editor & 68HC12 assembler
  • MON12 monitor program
  • CML12S-DP256 development board
  • CML12S-DP256 MON12 manual All documents are available on the class website

Important Reminders:

  • It is your responsibility to save the programs you create.
  • You will not need to bring your SRB to this or any remaining lab.
  • Pre-lab assignments must be completed before coming to the lab.

Background:

CML12S-DP256 development board Axiom’s CML12S-DP256 is a development board for the Motorola MC6S12DP microcontroller which is a configuration of the 68HCS12 core with memory and I/O. The CML12S-DP256 and associated software, particularly the MON12 embedded firmware monitor program, provide a user interface to the microcontroller useful to debugging code and testing microcontroller hardware functions. Assembled code in .S19 files can be loaded to the controller through the MON12 program. Additional details can be found as needed in the CML12S-DP256 MON12 manual.

The CML12S-DP256 provides a debug mode in which the debugger software (e.g., MON12) handles CPU initialization, interrupt vectors, and the stack. The memory map for the CML12S-DP256 is shown on page 11 of the manual. The manual suggest using external RAM starting at $4000 for storing user program code in the debug mode of operation. It is suggested that program data be stored in internal RAM between $1000 and $3DFF The MON12 debugger reserves the remaining part of internal RAM between $3E and $3FFD and starts the stack at $3F80.

Determinants

A 2 x 2 matrix m is typically represented like: (^) ⎥. ⎦

⎤ ⎢ ⎣

21 22

11 12 m m

m m m

The determinant of matrix m is computed by det ( m )= m 11 .m 22 -m 21 .m 12. The following assembly/machine language program will calculate the determinant of a 2 x 2 matrix m consisting of 8-bit 2’s complement entries. The program starts from memory location $4000, and the matrix is assumed to be stored in memory locations $1001, $1002, $1003, $1004. A MON12 debugger command, MM (modify memory), can be used to enter matrix data into data memory. Page 10 of the manual lists the MON12 commands.

ORG $ 4000 b6 10 02 LDAA $ 4003 f6 10 03 LDAB $ 4006 12 MUL 4007 7b 10 ff STAB $10FF 400a b6 10 01 LDAA $ 400d f6 10 04 LDAB $ 4010 12 MUL 4011 f0 10 ff SUBB $10FF 4014 7b 10 ff STAB $10FF END

Pre-lab Assignment:

  • Read this entire lab assignment so you know what to expect in the lab. Also read through the CML12S-DP256 MON12 manual to become familiar with where to find information in that document.
  • Complete the steps described in the Pre-lab sheet near the end of this document. Each student must complete his/her own pre-lab before coming to the lab and hand it in to the lab TA at the beginning of the lab.

Laboratory Assignment: This lab consists of two parts. A check-off sheet is included at the end of this lab document.

  • Print the check off sheet. Where indicated, you must record your results on the check-off sheet. After you successfully finish each part of the lab, show the TA your results and ask him to sign the check-off sheet.

Part 1: Entering, running, and debugging machine language programs. Preparation:

  1. From the PC on your lab bench, launch the AxIDE utility from the 68HC12 program folder under the ‘Start’ menu.
  2. Connect the CML12S-DP256 board to power and to your computer using the wiring bundle attached to your computer.
  3. Press the reset button on the CML12S-DP256 board. In your terminal window on the PC you should see a message to “PRESS KEY TO START MONITOR…”. Press the ENTER key and you should see:

would like to stop execution and observe results. Use the ‘Set/Display user breakpoints’ command ( BR ) to set a breakpoint at address $4017.

  1. Repeat step 6 to enter the new matrix (^) ⎥. ⎦

F

  1. Use the RM command to set the PC to $4000 so you can execute the entire program again.
  2. Use the ‘Begin/Continue execution of user code’ command ( G ) to run the program from the top without stopping until it reaches the breakpoint.
  3. When program execution breaks, use the MD command to display the final determinate value and record it on your check off sheet. Verify the result is correct by calculating the determinate and comparing it to your results. This will require some hex to decimal conversion and possibly 2’s complement conversion to find correct decimal magnitudes. Record the relevant values along with a comment on the correctness of your results. It is possible to get incorrect results even if the program is working as expected. A discussion point for the report asks you to consider this more thoroughly.
  4. Repeat steps 12-15 for the matrix (^) ⎥. ⎦
  1. Repeat steps 12-15 for the matrix (^) ⎥ ⎦

FF

  1. When you are satisfied that the determinate program is operating correctly, ask the TA to check a demonstration of your program. Ask the TA to check off Part 1 on your lab check-off sheet.

Part 2: Assembly Language Programs: Editing, assembling, and removal of syntax errors.

;program code for Lab 6, part 2 org $ ldab #count ldaa #num more adda #num staa result decb bne more swi count equ $ num1 equ $ result rmb $ end Preparation:

  1. Using the lab PC, create a folder to store all of your ECE331 assembly programs. It is suggested you save these in your network drive space or otherwise ensure it is

stored off of the lab PC’s hard drive. You are responsible for saving all of your programs, and they may get erased from the lab computers. Using any text editor, enter the program above and save it as a .asm file in the directory you just created. Follow the syntax rules for entering assembly code.

  1. Launch the AsmIDE utility from the 68HC12 program folder under the ‘Start’ menu.
  2. Within AsmIDE, select File Æ Open to open your .asm file.
  3. From the Build menu, select Assemble. The assembler will produce two output files in the program directory. The .lst file contains a program listing along with the assembled machine code. If the input code contains any errors, the .lst file will give the line number of the error and a brief description of the nature of the error. The .s19 file is a hexadecimal machine code file that can be downloaded into the board memory for execution. A complete .s19 file is only produced when the assembly proceeds to conclusion with no errors.
  4. Continue to remove any syntax errors that are indicated by the assembler until you obtain an error free assembly. Print your .lst file using the text editor and include this in your lab report.

Testing:

  1. Press the reset button. You should see a message to “PRESS KEY TO START MONITOR…” in your terminal window. Press the ENTER key and you should see: a. Axiom MON12 - HC12 Monitor / Debugger V256. b. Type "Help" for commands. c. >_
  2. Type ‘ load ’ at the prompt and press the ENTER key.
  3. Select the ‘ Upload ’ option. Then click on the ‘ Browse ’ button and select the .s19 file that was created from the assembly process. Once you have selected the file, click ‘OK’.
  4. Use the ‘Modify CPU Register Contents’ command ( RM ) to set the Program Counter to point at address $4000. To do this type RM press enter, and then enter the address.
  5. Type G , and press Enter to start the program execution. The program will run until it reaches the software interrupt instruction (SWI) near the end of your program.
  6. Looking at the program and/or the .lst file, determine what memory address the final result is stored. Record this address on your check off sheet.
  7. Record the result of the program in the check off sheet.
  8. When you are satisfied that the program is operating correctly, ask the TA to check a demonstration of your program. Ask the TA to check off Part 2 on your lab check-off sheet.

PRE-LAB 6

Due: At the beginning of lab.

Student Name: ___________________________ Lab. Section (time): __________

Make sure you read the lab document before you start the pre-lab, especially the Background section.

  1. Find the determinant of the following matrices.

a) (^) ⎥ ⎦

3 B

b) (^) ⎥ ⎦

F

c) (^) ⎥ ⎦

d) (^) ⎥ ⎦

FF

  1. For the assembly code listed in the Background under Determinates, where is the determinate stored at the end of program execution? Specify the memory address.
  2. For the program shown at the beginning of part 2: a. Briefly explain the functionality of the program

b. What is the expected output of the program

LAB 6 CHECK-OFF SHEET

Student Name: ___________________________ Lab. Section (time): __________

Complete this sheet as you complete the lab. Remember to have the TA check off each section of the assignment. This sheet must be included in your lab report.

Part 1: Entering, running, and debugging machine language programs

Step 5. The contents of memory in addresses $4000______ $4001______ $4002______ $4003______

$4004______

$4005______

$4006______

Step 10. Record the determinant det(m) = ______ Does the result agree with the expected? Yes or no and if no why?

Step 15. Record the determinant det(m) = ______ Does the result agree with the expected? Yes or no and if no why?

Step 16. Record the determinants det(m) = ______ Does the result agree with the expected? Yes or no and if no why?

Step 17. Record the determinants det(m) = ______ Does the result agree with the expected? Yes or no and if no why?

Part 1: TA sign off Part 1: Entering, running, and debugging machine language programs. Initial________