ECE-3120 Lab 3: Program Loops in HC12 Assembly - Prof. Xubin He, Lab Reports of Microcomputers

Lab 3 for ece-3120 spring 2008 course, focusing on programming loops, branching, and arithmetic instructions using the hc12 microcontroller. Students are required to write a fully-commented program, calculate sums and counts of positive, negative, and zero numbers in an array, and debug the program using d-bug12. The document also includes instructions on how to prepare for the lab, assemble, and turn in the assignment.

Typology: Lab Reports

Pre 2010

Uploaded on 07/30/2009

koofers-user-4d9
koofers-user-4d9 🇺🇸

8 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECE-3120
Spring 2008
LAB 3 –PROGRAM LOOPS
The purpose of this lab is to introduce you to basic programming on the 68HCS12 using
program loops, branching, and arithmetic instructions. You will NEED to study about
the arithmetic and branching instructions in Huang chapter 2 before attempting this
program.
PRE-LAB:
Prepare pseudocode and the first draft of the program and calculate the expected results
by hand. This must be completed before coming to the lab and shown to the lab instructor
at the start of the lab session. Note: The Pre-Lab must be typed into a proper *.ASM
source file, following our standard Program Format requirements.
Approved: Lab TA _____________________ Date ____________
PROGRAMMING ASSIGNMENT:
Write a fully-commented program for the HC12 board, following our standard Program
Format requirements (http://iweb.tntech.edu/rhaggard/3120s08/Program_Format.htm),
including appropriate directives and labels for memory operands and constants, called
Loop.asm. It must use a single program loop for most of the work. The program should
do the following:
Be able to process any array containing 1 to 255 signed data bytes as follows.
Each byte can thus have a value between -128 and +127. This means that the
program should be able to handle any size array in this range, with any set of
values, by changing ONLY the directives that create the array values and
array size, without modifying any instructions.
Calculate the sum of all the positive numbers in the array.
Calculate the sum of all the negative numbers in the array.
Count the number of zeros in the array.
Calculate the total sum of all numbers in the array.
The code must start execution at $1000.
The program directives should initialize the following signed decimal data byte array
in the data space (starting at $1200):
100, 127, -127, 22, 0, -8, -1, 0, 1, 120, 77, -45, 0, -99, in this order.
2/19/08 Page 1 of 3 Lab 3
pf3

Partial preview of the text

Download ECE-3120 Lab 3: Program Loops in HC12 Assembly - Prof. Xubin He and more Lab Reports Microcomputers in PDF only on Docsity!

Spring 2008

L A B 3 – P R O G R A M L O O P S

The purpose of this lab is to introduce you to basic programming on the 68HCS12 using program loops, branching, and arithmetic instructions. You will NEED to study about the arithmetic and branching instructions in Huang chapter 2 before attempting this program.

P R E - L A B :

Prepare pseudocode and the first draft of the program and calculate the expected results by hand. This must be completed before coming to the lab and shown to the lab instructor at the start of the lab session. Note: The Pre-Lab must be typed into a proper *.ASM source file, following our standard Program Format requirements.

_Approved: Lab TA _____________________ Date _____________

P R O G R A M M I N G A S S I G N M E N T :

Write a fully-commented program for the HC12 board, following our standard Program Format requirements (http://iweb.tntech.edu/rhaggard/3120s08/Program_Format.htm), including appropriate directives and labels for memory operands and constants, called Loop.asm. It must use a single program loop for most of the work. The program should do the following:

  • Be able to process any array containing 1 to 255 signed data bytes as follows. Each byte can thus have a value between -128 and +127. This means that the program should be able to handle any size array in this range, with any set of values, by changing ONLY the directives that create the array values and array size, without modifying any instructions.
  • Calculate the sum of all the positive numbers in the array.
  • Calculate the sum of all the negative numbers in the array.
  • Count the number of zeros in the array.
  • Calculate the total sum of all numbers in the array.
  • The code must start execution at $1000.

The program directives should initialize the following signed decimal data byte array in the data space (starting at $1200): 100, 127, -127, 22, 0, -8, -1, 0, 1, 120, 77, -45, 0, -99, in this order.

Spring 2008

L A B 3 – P R O G R A M L O O P S

The program should store in memory:

  • The sum of positive numbers in memory location $1300:$
  • The sum of negative numbers in memory location $1302:$
  • The number of zeros in memory location $
  • The total sum in memory location $1306:$

Procedure : First, use D-Bug12 to fill memory locations $1000 through $14FF with zeros. Then assemble, download, and debug/execute the program as follows. a. Single-step through the program until it completes the first loop iteration and is ready to branch back to the start of the loop. Verify that each change is correct. b. Then set a breakpoint to stop execution at the end of each loop and run through the rest of the program to the end, pausing at each breakpoint to display the important results. Verify that each result is correct at the end of each loop and that all four final results are correct at the end of the program. Use the listing file to determine the breakpoint address. Remember that the instruction at the breakpoint address is NOT executed when the break occurs; it is only executed when you resume execution after the break. c. Then reset the processor (which removes the breakpoint), download the program again, run it at full speed until it stops, and verify that the four final values are still correct. d. When finished debugging and executing, copy the entire terminal window output and paste it into a Notepad or Word document for inclusion in the report. You should edit out mistakes and unnecessary repetitions before submission.

_Approved: Lab TA _____________________ Date _____________