 |

Lab 4
Some Math Operations
Introduction
Eight-bit micro-controllers such as the MC68HC11
are limited to some extent by the word size. Simple methods of number
representation limit the capacity of a register to 256 discrete values, e.g.,
-128 to +127. There are methods by which this capacity can be expanded by using
two or more bytes to store an operand (called double or multiple precision
arithmetic). One can, within some limits, also do BCD (binary coded decimal)
addition with an HC11. This lab is intended to
demonstrate ways in which math operations can be chained to afford number
capacities larger than one byte.
Before the Lab
You must write three programs for extended math operations.
-
Write a
generalized subroutine for adding two multiple-precision numbers that are
stored beginning at location $C100 and $C120. This arbitrarily limits the
size of the numbers to 32 (decimal) bytes; most applications will require a
capacity no larger than 3 or 4 bytes. When you enter the subroutine,
Accumulator A should hold the size (# of bytes) of the numbers to be added.
When you return from the subroutine, Acc A is destroyed and the sum is
stored beginning at location $C100. NOTE: Chained adds should be done from
the least significant byte up to preserve proper operation of the carry
bit. You should store your numbers to be added with the LEAST SIGNIFICANT
byte at the end of the table, i.e., $C10F and $C11F. In this way the
numbers will read correctly as you read UP in memory. Don't forget to clear
the carry before you start.
-
Modify this subroutine for chained adding of
BCD numbers. The same precautions apply.
-
The MC68HC11
has a MUL
instruction that does an unsigned 8 x 8 bit multiply (from Acc A and Acc B)
and leaves the answer in the D register. This instruction can be put to
good use for doing a 16 x 16 bit multiply that yields a 32-bit answer. The
algorithm works something like this. Consider two 16-bit numbers. Each has
a high and low byte. We will call these numbers AB (A = Hi, B = lo) and CD
(C = hi, D = lo). Multiplication works just like you learned in third
grade.
A B -------16-bit multiplicand
* C D -------16-bit multiplier
--------
B*D -------16-bit partial product
# 1
B*C -------16-bit partial product
# 2
A*D -------16-bit partial product
# 3
A*C -------16-bit partial product
# 4
-----------
X1X2X3X4
-------32-bit product
Note that this will require multiple-precision adds of essentially four 4-byte numbers (by padding either before or after each two-byte number with zeros). You might take advantage of your multiple-precision add subroutine.
-
Modify this program to implement 32 x 8 bit multiplication.
In the Lab
Test all three of your programs. Use at least three independent data sets to
insure that they work properly. Note that the operands can be entered directly
in memory with the BUFFALO program. Record the results of each operation and
check, using a hex calculator if necessary.
After the Lab
Generate neat, commented program listings for submission.
Calculate the actual time required to execute the 16 x 16 bit
multiply and 32 x 8 bit multiply (recalling that the clock rate of the Axiom
board is 2.4576 MHz) . Be sure to include any overhead required for subroutine
calls. If a TI TMS320C25 requires 30 nsec to
complete the same operation, how much faster is it than the Axiom board? Discuss
appropriate applications for each type of processor.
If we had a 16 bit processor instead of an 8-bit HC11, how
would you implement 16 x 16 bit multiplication? How about 32 x 8 bit multiply?
(Explain briefly)
| EE-218 Homepage |
Syllabus
| Schedule | Lab News | Faculty |
Contact
Information | Lab Info | Project
|
Department of Electrical Engineering and Computer Science
Box 1824 Station B
Nashville, TN 37235
Phone: 322-2771
Fax: 343-6702
|
Search |
Site Index
| People Finder
| Phone
Directory | VUnet |
VUmail | VU
Library | Help
|
Last Updated:
Saturday, March 05, 2005
Turker Keskinpala
Copyright © 2003
Vanderbilt University
|