Chapter 3
Functions and bit manipulations
3.1 Objective
To become familiar with bit level operations and writing functions. This lab also
illustrates the use of random numbers for testing functions. Bit level operations
are used to control light emitting diodes connected to PORTA as well as for
monitoring external circuitry.
3.2 What you should do
You will be writing several functions in this laboratory exercise. You should
have only one file and you should add the new function at the end of your older
functions. Also, you will be adding items to the data section. You should not
delete earlier data items. Your main code will be changing. You should insert
your new main code before the older one, so that the most recent main code will
start immediately after the ORG statement. Try not to delete any code from your
file.
3.3 String outputs
In the last lab, we saw how to write a single byte as an ascii character. To write
a string, it is tedious to load A with one character at a time and then calling
OUTA each time. A better approach is to put all the characters in consecutive
memory locations and print them all in a loop. To do this, we need two pieces
of information, where to start and where to end. The common approach to such
situation is to specify where to start and use a special value, known as sentinel,
to indicate the end. Some of you may have used special values such as zero, one,
or 9999. It is entirely up to the programmer, but for character strings, the three
31
Kommentare zu diesen Handbüchern