Lab 2: Basic Arithmetic Programming - Fall 2008 | ECE 3120, Lab Reports of Microcomputers

Material Type: Lab; Professor: He; Class: Microcomputer Systems; Subject: ECE Elect & Computer Engr; University: Tennessee Tech University; Term: Spring 2008;

Typology: Lab Reports

Pre 2010

Uploaded on 07/30/2009

koofers-user-jr6
koofers-user-jr6 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECE-3120
Spring 2008
LAB 2 – Basic Arithmetic Programming
2/18/2008 Page 1 of 3 Lab 2
The purpose of this lab is to introduce you to basic programming with the 68HCS12
using assembler directives and arithmetic instructions. You will NEED to study the
directives and arithmetic operation instructions in Huang chapter 2 before attempting this
program.
PRE-LAB:
Prepare the pseudocode and the first draft of the program and calculate the expected
results (Sum, Average, Difference) by hand. This must be completed before coming to
the lab and shown to the lab instructor at the start of the lab session.
Approved: Lab TA _____________________ Date ____________
PROGRAMMING ASSIGNMENT:
Write a fully-commented program for the HC12 board, including appropriate directives
and labels for memory operands and constants, called Arith.asm. The program should do
the following:
The program should start execution at address $1000.
Use directives to create an array of five unsigned decimal byte values: 61, 200,
47, 188, and 26 stored in contiguous memory at locations $1500-$1504.
Calculate the unsigned Sum of the five numbers and store this word at memory
location $1510.
Calculate the unsigned Average of the 5 numbers and store this byte in memory
after the sum.
Subtract the Average from the Sum and store the unsigned Difference (word) in
memory after the Average.
Procedure: First, use D-Bug12 to fill memory locations $1000 through $1600 with zeros.
Then assemble, download, and single-step through the program to debug it. Verify that
each value change, in registers and memory, is correct and that the final values of
Average, Sum, and Difference are correct. Then reset the processor, download the
program again, run it at full speed until it stops, and verify that the final values are still
correct. 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 may edit
out mistakes and repetitions before submission.
pf3

Partial preview of the text

Download Lab 2: Basic Arithmetic Programming - Fall 2008 | ECE 3120 and more Lab Reports Microcomputers in PDF only on Docsity!

Spring 2008

LAB 2 – Basic Arithmetic Programming

The purpose of this lab is to introduce you to basic programming with the 68HCS using assembler directives and arithmetic instructions. You will NEED to study the directives and arithmetic operation instructions in Huang chapter 2 before attempting this program.

P R E - L A B :

Prepare the pseudocode and the first draft of the program and calculate the expected results (Sum, Average, Difference) by hand. This must be completed before coming to the lab and shown to the lab instructor at the start of the lab session.

_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, including appropriate directives and labels for memory operands and constants, called Arith.asm. The program should do the following:

  • The program should start execution at address $1000.
  • Use directives to create an array of five unsigned decimal byte values: 61, 200, 47, 188, and 26 stored in contiguous memory at locations $1500-$1504.
  • Calculate the unsigned Sum of the five numbers and store this word at memory location $1510.
  • Calculate the unsigned Average of the 5 numbers and store this byte in memory after the sum.
  • Subtract the Average from the Sum and store the unsigned Difference (word) in memory after the Average.

Procedure : First, use D-Bug12 to fill memory locations $1000 through $1600 with zeros. Then assemble, download, and single-step through the program to debug it. Verify that each value change, in registers and memory, is correct and that the final values of Average, Sum, and Difference are correct. Then reset the processor, download the program again, run it at full speed until it stops, and verify that the final values are still correct. 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 may edit out mistakes and repetitions before submission.

Spring 2008

LAB 2 – Basic Arithmetic Programming

_Approved: Lab TA _____________________ Date _____________

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

Generally, follow the format for source code as described in the ECE3120 Assembly Language Practice document. Specifically for our class:

  • Include a title comment block at the top of the file like: ;----------------------------------------- ; Lab 2 ; Basic Arithmetic Programming ; Your name and date ; Describe program function and purpose, ; using multiple lines if necessary. ;-----------------------------------------
  • Then include pseudocode in another comment block before beginning the code and data. It must clearly describe the program algorithm, step by step, using higher-level syntax such as math, C code, and English.
  • Next, include the necessary directives for addresses and data, initialized with data values when needed. The allowed directives are: ORG, DC.B, DC.W, DS.B, DS.W, EQU, END.
  • Finally, include the sequence of instructions.
  • Include other comments throughout the code to explain your program details.
  • Use labels or expressions with labels (not just "magic numbers" or numerical addresses) in your code when referring to constants and memory locations.
  • Directives and instructions may be either upper or lower case, but be consistent.
  • Start labels in column 1. Terminate labels with a colon.
  • Start all comments with a semicolon.
  • All instructions and directives start in column 9 or later.
  • Carefully align the four fields of each instruction and directive line.
  • Lines must NOT wrap around to the next line on printed documents (source or listing).
  • All code and data must fit in our board's RAM space and code execution must end with SWI.