%\batchmode
\documentclass[12pt]{article}
\oddsidemargin=0in
\evensidemargin=0in
\textwidth=6.25in              % A4 paper is 8.25in wide
\headheight=0pt
\headsep=0pt
\topmargin=0.5in
\textheight=8.5in              % A4 paper is 11.7in high
\parskip=1.5ex
\abovedisplayskip=1.5ex
\belowdisplayskip=1.0ex
\raggedbottom
\newtheorem{theorem}{Theorem}
\begin{document}
%\thispagestyle{empty}
\title{Core competency test for  ECE 372/373}
\date{}
\author{N. Natarajan}
\maketitle
\section{Basics}
You should be able to answer the following given sufficient time.
In the test, you will be asked to answer 10 such questions in 20
minutes (average of 2 minutes a question. Some may take longer but
most should not take more than a minute or so.) The test is a
closed book test and you will be allowed to bring only the
Motorola reference books.
\begin{enumerate}
\item
Convert the following decimal numbers into 16 bit {\em signed}
hexadecimal numbers: 100, 272, -1, -2, -255
\item
Convert the following 8-bit signed hexadecimal numbers to decimal:
{\bf \$AC, \$60, \$FF, \$22, \$04}
\item
Perform the following 8-bit addition and indicate which of the {\bf C, V, N, Z} flags will be set
\[
\begin{array}{llllll}
\$20 + \$70~~~ & Answer  =  ~~~~~~~~~~ & C =  ~~~~~~ & N = ~~~~~ & Z = ~~~~~ & V = \\
\$2A + \$8F~~~ & Answer  =  ~~~~~~~~ & C =  ~~~ & N = ~~~~ & Z = ~~~~ & V = \\
\$5A + \$A6~~~ & Answer  =  ~~~~~~~~ & C =  ~~~ & N = ~~~~ & Z = ~~~~ & V = \\
\$A0 + \$8C~~~ & Answer  =  ~~~~~~~~ & C =  ~~~ & N = ~~~~ & Z = ~~~~ & V =
\end{array}
\]
\item
Increment by 5 a 16 bit number stored in locations \$00-\$01.
\item
Decrement by 7 a 16 bit number stored in locations \$00-\$01.
\item
Add the 16 bit number stored in locations \$00-\$01 to the 16 bit
number stored in locations \$02-\$03 store the result back in
locations \$00-\$01
\item
Shift left (once) a 16 bit number stored in locations \$00-\$01.
\item
Compare a 16 bit unsigned number stored in locations \$00-\$01
with an unsigned number stored in locations \$02-\$03 and set B
register to \$00 if they are the same, \$01 if the first number is
larger, \$FF if the first number is smaller
\item
Set register B to \$FF if both bits \#2 and \#5 in register A are set. You must use the {\em MASK}
equated as
\begin{verbatim}
    MASK EQU %00100100
\end{verbatim}
\item
Set register B to \$FF if either bits \#2 and \#5 in register A are set. You must use the {\em MASK}
equated as
\begin{verbatim}
    MASK EQU %00100100
\end{verbatim}
\item
Set register B to \$FF if exactly one of the  bits \#2 and \#5 in register A are set.
You must use  {\em MASK, BIT5, BIT2} equated as
\begin{verbatim}
    MASK EQU %00100100
    BIT5 EQU %00100000
    BIT2 EQU %00000100
\end{verbatim}
\item
Use a counting loop to subtract the contents of register Y from
register X; at the end of the loop, X should contain X-Y.
\item
Test if any of the numbers in locations \$D000-\$D03F is zero. If they are all non-zero, set register
A to any non-zero number. If at least one of them is zero, set register A to 0. You must use the following
equates:
\begin{verbatim}
    START EQU $D000
    LENGTH EQU $40
\end{verbatim}
\item
Write a {\em function} that will read a character from the input
without echoing it. The function should loop until it receives one
of the following valid characters: {\tt a A b B c C d D}. The
function should return the character in the accumulator {\tt A}.
\item
Write a {\em function}  that will set bit \#4 in memory location
{\tt \$10} without affecting other bits in that location.
\item
Write a {\em function} that will combine the values in locations
{\tt \$10} and {\tt \$11} and store the value in location {\tt
\$12}. The first four bits of the results (bits 7-4) should come
from last four bits in location {\tt \$10} and the last four bits
of the result (bits 3-0) should come from the last four bits in
location {\tt \$11}
\item
Write a {\em function} that will  turn on the A/D convertor and
wait for 400 microseconds before returning.
\item
Write a {\em function} that will read the value in the A/D channel
\#2 and return the value in accumulator {\bf B}.
\item
Write a {\em function} that will configure port D so that pins
\#4, and \#3 are output pins and all others are input pins
\item
Write a {\em function} that output the last 4 bits (bits 3-0) of
the value in accumulator {\tt B} to the pins 5-2 in port D.
\item
Write a {\em function} that will set the scaler for {\tt RTI}
interrupt so that the interrupt occurs at the fastest rate. This
function should also enable the {\tt RTI} interrupt before
returning.
\item
Write an {\em interrupt service routine} that will service the {\tt
RTI} interrupt and, as part of the service, decrement a 16 bit
value stored in locations {\tt \$10-\$11}.
\item
Write an {\em interrupt service routine} that will service the {\tt
OC2} interrupt and as part of the service, schedule the next {\tt
OC2} interrupt to occur {\tt \$2500} clock ticks after the current
interrupt (the interrupt that is being serviced).
\item
Write a {\em function} that will read a character from the input
without echoing it. The function should loop until it receives one
of the following valid characters: {\tt a A b B c C d D}. The
function should return the character in the accumulator {\tt A}.
\item
Write a {\em function}  that will set bit \#4 in memory location
{\tt \$10} without affecting other bits in that location.
\item
Write a {\em function} that will combine the values in locations
{\tt \$10} and {\tt \$11} and store the value in location {\tt
\$12}. The first four bits of the results (bits 7-4) should come
from last four bits in location {\tt \$10} and the last four bits
of the result (bits 3-0) should come from the last four bits in
location {\tt \$11}
\item
Write a {\em function} that will  turn on the A/D convertor and
wait for 400 microseconds before returning.
\item
Write a {\em function} that will read the value in the A/D channel
\#2 and return the value in accumulator {\bf B}.
\item
Write a {\em function} that will configure port D so that pins
\#4, and \#3 are output pins and all others are input pins
\item
Write a {\em function} that output the last 4 bits (bits 3-0) of
the value in accumulator {\tt B} to the pins 5-2 in port D.
\item
Write a {\em function} that will set the scaler for {\tt RTI}
interrupt so that the interrupt occurs at the fastest rate. This
function should also enable the {\tt RTI} interrupt before
returning.
\item
Write a {\em interrupt service routine} that will service the {\tt
RTI} interrupt and, as part of the service, decrement a 16 bit
value stored in locations {\tt \$10-\$11}.
\item
Write a {\em interrupt service routine} that will service the {\tt
OC2} interrupt and as part of the service, schedule the next {\tt
OC2} interrupt to occur {\tt \$2500} clock ticks after the current
interrupt (the interrupt that is being serviced).
\item
Write a {\em function} that will increment a 16 bit number stored
in locations {\tt \$0010-\$0011}. The incremented value should be
stored back in the same locations.
\item
Write a {\em function} that will add the value in register B to a
16 bit number stored in locations {\tt \$0010-\$0011} and store
the answer back in the same locations.
\item
Write a {\em function} that will test the value in location {\tt
\$1003} and set the {\bf B} register to {\tt \$07} if the bits \#0
and \#1 are both set. Or else it should load the value {\tt \$11}
in  the {\bf B} register.
\item
Write a {\em function} that will test the value in location {\tt
\$1003} and set the {\bf B} register to {\tt \$07} if at least one
of the bits \#0 and \#1 are set. Or else it should load the value
{\tt \$11} in  the {\bf B} register.
\item
Write a {\em function} that will test the value in location {\tt
\$1003} and set the {\bf B} register to {\tt \$07} if none of the
bits \#0 and \#1 are set. Or else it should load the value {\tt
\$11} in  the {\bf B} register.
\item
Write a {\em function} that will test the value in location {\tt
\$1003} and set the {\bf B} register to {\tt \$07} if exactly one
of the bits \#0 and \#1 are set. Or else it should load the value
{\tt \$11} in  the {\bf B} register.
%\item
%Write a {\em function} that will add a 64 bit number stored in
%locations {\tt \$00-\$07} to a 64 bit number stored in locations
%{\tt \$10-\$17} and store it as a 64 bit number stored in
%locations {\tt \$20-\$27}.
\item
Write a {\em function} that will count the number of times the
value {\tt \$0A} occurs in the memory locations {\tt \$00-\$0F}.
The function should return the answer in the {\bf B} register.
\end{enumerate}
\end{document}
