\documentstyle[12pt]{article}
\voffset=-1in 
\hoffset=-0.5in 
\textwidth=6.6in 
\textheight=9in


\begin{document}
\parindent=0pt
\parskip=10pt


\begin{center} 
{\bf EE 308 -- LAB 02} \\[.1in]
{\bf Assembly Language Programming}\\[.2in]
{\bf Introduction and Objectives}\\
\end{center}

The purpose of this lab is to write a few assembly language
programs and test them on your EVBU.

\begin{center}
{\bf Pre-Lab}
\end{center}
Most of these programs have been given as homework.  Make sure you have
the programs clearly thought out and written down before you come to
lab.  You should put all your code starting at memory location {\sf 0x0100}.
You are encouraged to bring the programs in on disk.


\begin{center}
{\bf The Lab}
\end{center}

\begin{enumerate}

\item 
Test your program that increments memory location {\sf 0x1004} indefinitely.
Report what happens to port B when you run this program on the simulator.
Check that the port B lines are being asserted on your EVBU.

\item
Test your program to clear memory locations {\sf 0x0180} to {\sf
0x01FF}.  Check that your program works both on the simulator and
the EVBU.  Use the {\tt BUFFALO BF} (Bulk Fill) command to change the EVBU
RAM that is not being used by your program to {\sf 0xFF} before
running your program.

\item
Test your program to move all data in locations {\sf 0xE000} ---
{\sf 0xE05C} to locations {\sf 0x0180} --- {\sf 0x01DC}.  It is
inconvenient to check this program on the simulator. Why?  Does the
simulator have a {\tt BF} command that you could use to get around
the problem? Check your program on your EVBU.

\item  
Test your program that puts the greatest one-byte 2's complement
number from memory locations {\sf 0xE000} through {\sf 0xE01F} in
accumulator {\sf A}. Does it make sense to do this on the simulator?
The answer I got is {\sf 0x7E}.

\item  
Test your program that puts the greatest unsigned number from memory
locations {\sf 0xE000} through {\sf 0xE01F} in accumulator {\sf A}.
The answer I got is {\sf 0xE3}.

\item 
Test your program that counts the number of negative numbers in the
memory locations {\sf 0xE000} through {\sf 0xFE77}.  Store the result
in memory starting at location {\sf 0x0000}.  The answer I got is
{\sf 0x0B4A}.  
\end{enumerate}

\newpage

\begin{center}
{\bf Loading Programs into EEPROM}
\end{center}

You can load programs into the on-chip EEPROM.  When loaded in EEPROM
your program will remain on your HC11 even after turning off power.
Before loading your program into EEPROM, you must re-assemble it
 after instructing the assembler to start your code at address
{\sf 0xB600}.

The details of how to do this are given in the {\bf Universal
Evaluation Board User's Manual} in Section~4.4.2.  Basically, you will
use {\tt BUFFALO} to change the baud rate of the HC11 to 300~baud;
then you will change the baud rate of your {\tt Windows Terminal} to
300~baud, and download your program to the HC11.  After your program
is downloaded, you can change the baud rate of your {\tt Terminal}
back to 9600, and reset or power cycle your HC11 to restore 9600~baud
communicatons.  (Make sure {\tt BUFFALO} confirms that your program has been
downloaded before you reset your HC11.)

After the code is in the EEPROM, you can run it in one of two ways --
1) From {\tt BUFFALO}, set the program counter to {\sf 0xB600} and {\tt
`g`} (or {\tt `g B600`}); or 2) Move jumper J2 from {\it MONITOR} to
{\it EEPROM}, and reset or power-cycle the EVBU.  (Note that if you
run your program using method~2), you cannot easily re-enter {\tt
BUFFALO} to check the results of your program.  We will use method~2
in later labs where we won't need to re-enter {\tt BUFFALO} after
running a program.)

\begin{enumerate}
\setcounter{enumi}{6}
\item
Load your last program (which counts the number of negative numbers)
into EEPROM.  Run it by giving the {\tt g B600} command from {\tt
BUFFALO}.  Verify that the performance is the same as when you ran
it from RAM.

\item
Turn off power to your EVBU.  Turn power back on, and rerun your
program by giving the  {\tt g B600} command from {\tt BUFFALO}.
Verify that your program stayed in EEPROM.

\end{enumerate}

\end{document}
