This preview shows page 1. Sign up to view the full content.
Unformatted text preview: 0306-250
Assembly Language Programming
Laboratory Exercise Three: Condition Codes and Branching
This exercise investigates conditional branching in an HCS12 assembly language
program. The objective of this exercise is familiarization with HCS12 condition codes
and branch instructions as well as data allocation assembler directives. An assembly
language program is created and simulated in CodeWarrior.
For the expressions in step 2 and the input values in step 5 of the lab procedure, calculate
and write the results of each arithmetic operation (i.e., F, G, H, and Result) in evaluating
the expression from left to right, observing standard algebraic order of operations. Note
where overflow would occur for byte operations. If byte overflow would occur in
evaluating an expression, stop calculation at that point, and write zero for the result of
that expression. In lab, these calculations will be used to test your program. Include
these calculations in your report’s results section to validate your program’s results.
1. Create a new CodeWarrior directory (folder) and project on your X: drive for this
2. Following the guidelines listed below, write a properly commented and properly
formatted HCS12 assembly language program to compute these expressions.
= 4P - 2Q - R + 81
3P - 7Q + 2R + 11
P - Q + 3R - 107
F+G+H The expressions, as written above without any simplification, must be evaluated
from left to right, observing standard algebraic order of operations
All constants and variables must be byte values. Any constant operands required
(e.g., 81, 11, etc.) must be declared using assembler EQUate directives. All
variables (i.e., F, G, H, P, Q, R, and Result) must be stored in RAM.
All instructions must operate only on byte operands. (Note—this requirement
means that any multiplication operations must be implemented with a
combination of shift, addition, and/or subtraction instructions.)
Your program must check for overflow after every operation. If overflow occurs
during the computation of any output variable (F, G, H, or Result), that variable
must be set to zero. Page 1 of 2 0306-250 20091 Lab Exercise 3: Condition Codes and Branching Page 2 of 2 3. Assemble the program in CodeWarrior compiler to create a listing file.
4. Link the program in CodeWarrior to create a linker map file.
5. Simulate the program in the simulator with the two sets of input variables (i.e., P, Q,
and R) shown below. To set the values of the variables, modify the memory contents
in the simulator (i.e., so you do not have to reassemble the program for different
Input Set 1: = P = 2; Q = -3; R = -4
Input Set 2: = P = 13; Q = -14; R =15
6. After simulation of the program with each set of input values, capture the final
simulation results (i.e., generate a bitmap copy of the simulator window by pressing
Ctrl-Alt-Print Screen) showing the final contents of the HCS12 registers as well as the
final memory values of F, G, H, and Result for each set of input values.
7. Print your listing file, linker map file, and grading sheet, and then demonstrate step 5
for your lab instructor, who will sign them.
Write a report consisting of the following sections.
F Your conclusion should answer this question: Could you reduce or eliminate
overflow by changing the order of operations within the expressions (A, B, C,
Your writing should follow the rules of professional technical writing and should meet
the specifications in “Laboratory and Report Guidelines” on the course reference material
web page. Staple your cover page, report, listing file, and grading sheet (in that order),
and submit them at the beginning of the next lab session. Late reports are penalized 20%
per day late, where “day late” is calculated by rounding submitted time to the nearest
greater or equal integer number of days late (i.e., ceiling function). ...
View Full Document
This note was uploaded on 05/06/2010 for the course EECC 0306-250 taught by Professor Roymelton during the Fall '10 term at RIT.
- Fall '10