\def\BookletBaseClass{book}

\documentclass[openany,twoside,a5paper]{book}
%\documentclass[openany,twoside]{booklet}
%\documentclass[oddleft]{booklet}

\usepackage{acro}[1995/02/19]

\usepackage{%
   vmargin,%
   fancyheadings,%
   varioref,%
   rcs,%
   lgrind,%
   emlines2,%
   multicol,%
   cols,%
   makeidx,%
   array,%
   nbox,%
   xr,%
   explanation,%
   booktabs,%
   version,%
   prog,%
   enumerate,%
   amstext,%
   %showkeys,%
   amssymb,%
   amsmath,%
   theorem,%
   nick,%
   lastpage,%
   float,%
   answers,%
   verbatim}

\setpapersize{A5}%
\shiftmargins
\setmarginsrb{13mm}% left For a book, the inner.
             {9mm}% top
             {20mm}% right For a book, the outer.
             {10mm}% bottom
             {12pt}% headheight---increase to stop fancyhead warn
             {4mm}%  headsep
             {0pt}%  footheight
             {8mm}% footskip

\RCS$Revision: 1.8 $
\RCS$Date: 1996/02/27 13:52:58 $

\providecommand{\revision}{ver \RCSRevision{}%
                        ,\hspace{0.8ex} \RCSDate%
                      }

\DeclareRobustCommand{\referenceNum}{EE/27/LA/20/95} % 6, 7,..., 21.

% Turn off lgrind's special handling of the vertical bar:
%|-

% For the external references (xr.sty):
\externaldocument[asmpv114:]{../56ptws0/asmpv114}

\pagestyle{fancyplain}

\newcommand*{\file}[1]{\texttt{#1}}

\setlength{\extrarowheight}{1.5pt} % Is this okay?

\newcommand*{\clearemptydoublepage}%
        {\newpage{\pagestyle{empty}\cleardoublepage}}

\newcommand*{\headSize}{\scriptsize}

\newcommand*{\outerHead}{\textbf{\normalsize\thepage}}
\newcommand*{\outerRightFoot}{\tiny\referenceNum}
\newcommand*{\outerLeftFoot}{\tiny\revision}

\renewcommand*{\chaptermark}[1]{\markboth{#1}{#1}}
\renewcommand*{\sectionmark}[1]{\markright{\thesection\ \ #1}}

\lhead%
[\fancyplain{}{\outerHead}]%
%{\fancyplain{}{\bfseries\rightmark}}
{\fancyplain{}{\textbf{Errata: corrections to errors in this book}}}

\rhead%
[\fancyplain{}{\textbf{Errata: corrections to errors in this book}}]%
% %[\fancyplain{}{\bfseries\leftmark}]%
{\fancyplain{}{\outerHead}}

\lfoot[\fancyplain{}{\outerLeftFoot}]{}
\rfoot[]{\fancyplain{}{\outerRightFoot}}
\cfoot[\fancyplain{}{}]{\fancyplain{}{}}

\DeclareRobustCommand{\Lsh}{\textless\!\!\textless}
\DeclareRobustCommand{\Rsh}{\textgreater\!\!\textgreater}
% \newcommand{\nBox}[2][40mm]{\parbox[c][3\baselineskip][c]{#1}{\centering#2}}

% From asmprim.tex:
%\renewcommand*{\chaptermark}[1]{\markboth{#1}{#1}}
%\renewcommand*{\sectionmark}[1]{\markright{\thesection\ #1}}
%\newcommand*{\outerLeftFoot}{\tiny\revision}
%\newcommand*{\outerRightFoot}{\tiny\referenceNum}
%\lfoot[\fancyplain{}{\outerLeftFoot}]{}
%\rfoot[]{\fancyplain{}{\outerRightFoot}}

% !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
% Belongs in lect2.dtx!
% !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
\raggedbottom

\newcommand*{\qc}{\textsf{Quincy}\xspace}

\providecommand{\DP}{\textsf{MS-DOS Prompt}\xspace}
\providecommand{\ed}{\textsf{MS-DOS Editor}\xspace}
\providecommand{\hp}{\textsf{HP Real-time C Debugger}\xspace}
\providecommand{\te}{\textsf{Terminal}\xspace}

\renewcommand{\floatpagefraction}{0.75} % default is .5, to increase
% density.
\renewcommand*{\bottomfraction}{0.6} % default is 0.3
\renewcommand*{\topfraction}{0.85} % default is 0.7
\renewcommand*{\textfraction}{0.1} % default is 0.2

\floatstyle{ruled}
\floatname{program}{Program example}
\newfloat{program}{tbhp}{lop}[chapter]

\newcommand*{\tableFontSize}{\footnotesize}

% Stuff for the title page:

\DeclareFontFamily{U}{cminch}{}
\DeclareFontShape{U}{cminch}{b}{n}
     {
      <72><217><434> cminch
      }{}

\DeclareFixedFont{\cmthreeinch}{U}{cminch}{b}{n}{217}
\DeclareFixedFont{\cmfourinch}{U}{cminch}{b}{n}{434}

\newcommand*{\HRule}{\rule{\linewidth}{1mm}}
\newlength{\embeddedWidth}
\settowidth{\embeddedWidth}{\sffamily\Huge\bfseries embedded}
\newlength{\cWidth}
\newlength{\cHeight}
\settowidth{\cWidth}{\cmfourinch\char'103}
\settoheight{\cHeight}{\cmfourinch\char'103}
\newlength{\cPos}
\setlength{\cPos}{0.6\cWidth}
\addtolength{\cPos}{-\embeddedWidth}

%\title{\raggedleft
%\sffamily\Huge\bfseries {\raggedright Learning and using\\[1ex]}
%{\cmfourinch\char'103}\hspace*{-0.6\cWidth}\raisebox{0.5\cHeight}[0pt][0pt]{%
%\parbox{\embeddedWidth}{in\\embedded\\systems}}\hspace*{\cPos}\mbox{}\\[1ex]
%\Large Nick Urbanik\\[1.5ex]
%\normalsize example programs by {\large Vincent Hui}\\[6ex]
%\normalsize \RCSDate\\[2ex]
%Hong Kong Technical College (Tsing Yi)\\[2ex]
%Department of Electrical and Communications Engineering
%}
%\author{}
%\date{}

%\title{Learning and using C with embedded systems: a laboratory guide for
%  \emph{Digital Systems and Microprocessors}}
%\author{Nick Urbanik \and Vincent Hui\thanks{Vincent Hui contributed most of the
%    examples in this booklet.}\\[2ex]
%Department of Electrical and Communications Engineering\\
%Hong Hong Technical College (Tsing Yi)}
%\date{\RCSDate}


% The set up for the exercises:

\theorembodyfont{\rmfamily}
\theoremstyle{margin}% This is my modified thm.sty.
\newtheorem{exercise}{Exercise}[chapter]
\newtheorem{example}{Example}[chapter]
\theoremheaderfont{\scshape}
\Newassociation{Solution}{Soln}{exsolns}
\renewcommand{\Solnlabel}[1]{\textsc{Solution } #1}

\makeindex
\newcommand*{\nn}[1]{#1n} % For index entries in footnotes.

\renewcommand*{\bibname}{References}

\begin{document}
\pagenumbering{Alph}
\thispagestyle{plain}
%{\bfseries\Huge Errata}
\chapter*{Errata: corrections to errors in this book}


\section*{Please add these corrections first}

Unfortunately, this book was printed before the proof reading was
complete.  There are a number of errors in the book; those I could
find are corrected here.  I will be grateful to any reader---student or
staff---who can point out any other errors, whether factual, spelling,
typographical or gramatical.  I am interested in feedback about
ways I can improve the next edition.\footnote{I know many cross references and
index items will be wrong, as mentioned on
page~\pageref{pag:wrongRefs}, but getting these right in the next
edition of this book is trivial.}

\section*{Major errors and omissions}

\begin{description}
\item[page 55, 6th bulletted point]
The dip switches are connected to port C, not to port~A\e.  The second
sentence should read:
\begin{quote}
This is the port~C data register on the \PIT.
\end{quote}
and \emph{not}
\begin{quote}
This is the port~A data register on the \PIT.
\end{quote}


\item[page 110, solution to exercise 2.6 (g)]
\mbox{}\\[-2ex]
\begin{enumerate}
\item[(g)] To solve this, you really need to look at
table~A.1 on page~116 which shows operator
precedence, or in other words, which operator is evaluated first.
\label{soln:precedenceExample}

From that table, we see that `@>=@', `@<=@', `@<@' and `@>@' have
precedence level 10, `@&&@' has precedence level 5, `@!@' has the
high priority of 14, `@||@' has a priority of 4 and binary `@-@' has a
priority of 12.  The expressions are evaluated in order of this
priority, those with a higher precedence level first.  Let us put
parentheses around this expression to see how it is evaluated by the C
compiler.

@  10 >= 0 && 30 <= 30 || ! ( 50 < 0 ) && 7 - 3 > 5@\\
@= ( ( ( 10 >= 0 ) && ( 30 <= 30 ) ) )@\\
@|| ( ! ( 50 < 0 ) && ( ( 7 - 3 ) > 5 ) )@\\
@= ( 1 && 1 ) || ( ! 0 && ( 4 > 5 ) )@\\
@= 1 || ( 1 && 0 )@\\
@= 1 || 0@\\
@= 1@, which has the logical value @true@.
\end{enumerate}

\item[page 117, solution to exercise 3.1]
Replace the whole of the solution part (a) with the following:

\begin{enumerate}[(a)]
\item If there are three address line inputs to the address decoder,
  A$_{23\text{--}21}$, then a new range of addresses is selected
  when A$_{21}$ changes.  So the lowest address, A00000\hex is active
  when A$_{23}$ = 1, A$_{22}$ = 0 and A$_{21}$ = 1.  This three-bit
  number is 101\bin.  When this three-bit number is incremented,
  then the \DUART will cease to be activated.  This will happen
  when A$_{23}$ = 1, A$_{22}$ = 1 and A$_{21}$ = 0.  The highest address
  with A$_{23}$ = 1, A$_{22}$ = 0 and A$_{21}$ = 1 is BFFFFF\hex.
  That is the highest address at which the chip select of the
  \DUART will be activated.
\end{enumerate}
The second part should be labelled (b), not \textbf{2.}
\end{description}

\section*{Minor corrections}

\begin{description}
\item[page 1, section 1.1.1, 4th line from bottom]
Write @#include <flight.h>@ instead of @#include <flight.h@.

\item[page 3, top line]
Delete the word `the' in front of the reference to [Sum]\e.

\item[page 34, second line of section 2.8.5]
Write C instead of \Cpp.

\item[page 41, Program example 2.18]
Write @printf( "the '2' key is ok.\n" );@ instead of
@printf( "the key '2' key is ok." );@

\item[page 44, eleventh line from top]
The word ``to'' has been wrongly written as ``fo''.

\item[page 48, eighth line of exercise 2.14]
\hspace{2.5em} Write ``function'' instead of\break ``fucntion''.

\item[page 49, first line of exercise 2.15]
A space is missing after the function name, @SevenSegment()@; write
``@SevenSegment()@ in'' rather than @SevenSegment()@in''.

\item[page 50, second line of text after the program]
Write ``\ldots like that shown in figure 2.2 on the facing page''
instead of
``\ldots like that shown in figure 2.15 on the preceding page''

\item[page 54, seventh line of section 2.11] Write: ``one such guide
is [C$^+$] which is\ldots'' instead of ``one such guide is [ea]
which is\ldots''.  This refers to a document called \emph{The Indian Hill
Style Guide}, which is mentioned in the references section on page
120.

\item[page 59, fourth line of section 3.2.2]
Write ``address bus'' instead of ``address lines''.

\item[page 59, bottom line of page]
Write $2^{15} - 1 = 32767$ instead of $2^{15} = 32767$.

\item[page 60, eighth line from the top]
The word ``circuit'' is repeated.  Delete one.

\item[page 71, in \texttt{Algorithm ReadKey}]
There are many equals signs that should be assignments.  Replace all
cases of `\inst{=}' with `\inst{:=}'.

\item[page 86, second line of section D.7.1]
Replace the word ``microseconds'' with ``milliseconds''.

\item[page 87, 12th line from the top]
Write the sentence ``The program will terminate when you press a key
on the \PC rather than requiring you to press the \textsf{RESET} button on the
\FLIGHT.'' instead of ``The program will terminate when you press a key
rather than requiring you to press the \acro{RESET} button on the
\FLIGHT.''

\item[page 87, bottom line before the program example]
The program example is wrongly said to be on the next page; in fact it
is on the same page.

\item[page 88, two lines before the program example]
Replace the word\break ``od'' with the word ``on''.

\item[page 88, all of section D.7.4]
%@-
There are many `@' symbols that have appeared.  Delete them.
%@+

\item[page 99, 13th line from the top]
Write:

\texttt{error1.c: 1: Unknown preprocessing directive.}

instead of

\verb|\texttt{error1.c: 1: Unknown preprocessing directive.}|

\item[page 102, 5th line of section H1]
Write ``compile'' instead of ``assemble''.

\item[page 102, title of section H.2] The title should be: ``The
general procedure for editing, compiling, downloading and running a
program'', not ``The general procedure for editing, assembling,
downloading and running an assembly language program''.  Of course,
the name should be changed to this in the table of contents on
page~vii.

\item[page 121, top line]
Write ``Frequently'' instead of ``Requently''.
\end{description}

In addition, in my impatience to print this book, I compiled it one
time too few.  The result of this is that many cross-references are
\label{pag:wrongRefs}%
wrong and will be in error by one page.  The same is true of the 
index, and possibly the table of contents and table of program examples.

Section 3.3 about the keypad, pages 68--73, is rather biased towards
an assembly language implementation.  The description does not match
the @ReadKey()@ function (given on page 90) very well.
\end{document}


