\relax \newlabel{1@xvr}{{}{viii}} \newlabel{1@vr}{{}{viii}} \newlabel{2@xvr}{{}{x}} \newlabel{2@vr}{{}{x}} \newlabel{3@xvr}{{}{xi}} \newlabel{3@vr}{{}{xi}} \newlabel{4@xvr}{{}{xi}} \newlabel{4@vr}{{}{xi}} \newlabel{5@xvr}{{}{xi}} \newlabel{5@vr}{{}{xi}} \newlabel{6@xvr}{{}{xi}} \newlabel{6@vr}{{}{xi}} \citation{stevens} \@writefile{toc}{\contentsline {chapter}{\numberline {1}Introduction}{1}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \@writefile{toc}{\contentsline {section}{\numberline {1.1}How should you learn the C language?}{1}} \newlabel{7@xvr}{{}{1}} \newlabel{7@vr}{{}{1}} \@writefile{toc}{\contentsline {subsection}{\numberline {1.1.1}Practice!}{1}} \newlabel{8@xvr}{{}{1}} \newlabel{8@vr}{{}{1}} \citation{kernighan} \citation{stevens} \citation{stevens} \citation{perry} \citation{cFaq} \@writefile{toc}{\contentsline {subsection}{\numberline {1.1.2}The \textsf {Quincy}\xspace interpreter}{2}} \newlabel{9@xvr}{{}{2}} \newlabel{9@vr}{{}{2}} \newlabel{10@xvr}{{}{2}} \newlabel{10@vr}{{}{2}} \@writefile{toc}{\contentsline {subsection}{\numberline {1.1.3}Use your laboratory!}{2}} \newlabel{sec:openDoorPolicy}{{1.1.3}{2}} \@writefile{toc}{\contentsline {subsection}{\numberline {1.1.4}Books about C programming}{2}} \citation{horvath} \citation{nickAsm} \citation{cktCellar} \@writefile{toc}{\contentsline {section}{\numberline {1.2}The convention used here for C programs}{3}} \citation{flight} \@writefile{toc}{\contentsline {section}{\numberline {1.3}Embedded systems}{4}} \newlabel{sec:embedded}{{1.3}{4}} \@writefile{toc}{\contentsline {section}{\numberline {1.4}How should I use this book?}{4}} \newlabel{11@xvr}{{}{4}} \newlabel{11@vr}{{}{4}} \@writefile{toc}{\contentsline {chapter}{\numberline {2}The C programming language}{6}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \@writefile{toc}{\contentsline {section}{\numberline {2.1}Constant values in C}{6}} \newlabel{sec:constant}{{2.1}{6}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.1.1}Constant integer values}{6}} \newlabel{sec:intConstants}{{2.1.1}{6}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.1.2}Constant character values}{7}} \newlabel{12@xvr}{{}{7}} \newlabel{12@vr}{{}{7}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.1.3}Constant strings}{7}} \newlabel{13@xvr}{{}{7}} \newlabel{13@vr}{{}{7}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.1.4}Named constants in C}{8}} \newlabel{sec:namedConstants}{{2.1.4}{8}} \newlabel{14@xvr}{{}{8}} \newlabel{14@vr}{{}{8}} \@writefile{toc}{\contentsline {section}{\numberline {2.2}Integral types}{8}} \newlabel{15@xvr}{{}{8}} \newlabel{15@vr}{{}{8}} \@writefile{lot}{\contentsline {table}{\numberline {2.1}{\ignorespaces The sizes of different integral types used by our 68000 C\nobreakspace {}cross-compiler in the laboratory. Note that with \textsf {Quincy}\xspace and \acro {MS-DOS}\xspace compilers, \textsf {\textbf {\textup {int}}} and \textsf {\textbf {\textup {unsigned int}}} are the same size as a \textsf {\textbf {\textup {short}}}.}}{9}} \newlabel{tab:intSize}{{2.1}{9}} \newlabel{qes:variable}{{a}{9}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.2.1}Definitions and declarations of integer-type variables}{9}} \newlabel{sec:declarations}{{2.2.1}{9}} \newlabel{16@xvr}{{}{9}} \newlabel{16@vr}{{}{9}} \@writefile{lop}{\contentsline {program}{\numberline {2.1}{\ignorespaces Definitions of integral-type variables.}}{10}} \newlabel{prg:definition}{{2.1}{10}} \newlabel{17@xvr}{{}{10}} \newlabel{17@vr}{{}{10}} \newlabel{18@xvr}{{}{10}} \newlabel{18@vr}{{}{10}} \@writefile{toc}{\contentsline {section}{\numberline {2.3}The meaning of \textsf {\textbf {\textup {\#include}}}}{10}} \newlabel{sec:include}{{2.3}{10}} \newlabel{19@xvr}{{}{10}} \newlabel{19@vr}{{}{10}} \newlabel{20@xvr}{{}{11}} \newlabel{20@vr}{{}{11}} \@writefile{toc}{\contentsline {section}{\numberline {2.4}Comments in the C language}{11}} \newlabel{sec:comments}{{2.4}{11}} \@writefile{toc}{\contentsline {section}{\numberline {2.5}C is case sensitive}{11}} \@writefile{toc}{\contentsline {section}{\numberline {2.6}The use of \textmd {\textsf {\textsl {printf}()}}}{11}} \@writefile{lop}{\contentsline {program}{\numberline {2.2}{\ignorespaces An example showing use of \ensuremath {\@mathvf {printf}}\textsf {\textmd {\textup {()}}}.}}{12}} \newlabel{prg:printf}{{2.2}{12}} \newlabel{21@xvr}{{}{12}} \newlabel{21@vr}{{}{12}} \@writefile{lop}{\contentsline {program}{\numberline {2.3}{\ignorespaces An example showing use of \ensuremath {\@mathvf {printf}}\textsf {\textmd {\textup {()}}} and the newline character, \textsf {\textmd {\textup {'}}}\texttt {\texttt {\char '134}\penalty \z@ {}n}\textsf {\textmd {\textup {'}}}.}}{13}} \newlabel{prg:printfNewline}{{2.3}{13}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.6.1}Displaying variables}{13}} \@writefile{toc}{\contentsline {subsubsection}{Displaying an integer}{13}} \@writefile{toc}{\contentsline {subsubsection}{Displaying a \textsf {\textbf {\textup {short}}} integer}{14}} \@writefile{toc}{\contentsline {subsubsection}{Displaying an \textsf {\textbf {\textup {unsigned char}}}}{15}} \@writefile{toc}{\contentsline {subsubsection}{Displaying a \textsf {\textbf {\textup {long int}}}}{15}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.6.2}Displaying a string}{16}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.6.3}A warning about the format characters and \textmd {\textsf {\textsl {printf}()}}}{16}} \@writefile{toc}{\contentsline {subsubsection}{A summary of the format characters}{16}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.6.4}Example programs showing the use of \textmd {\textsf {\textsl {printf}()}}}{16}} \newlabel{22@xvr}{{}{16}} \newlabel{22@vr}{{}{16}} \citation{stevens} \@writefile{lot}{\contentsline {table}{\numberline {2.2}{\ignorespaces The format characters for use with \ensuremath {\@mathvf {printf}}\textsf {\textmd {\textup {()}}}.}}{17}} \newlabel{tab:formatChars}{{2.2}{17}} \newlabel{23@xvr}{{}{17}} \newlabel{23@vr}{{}{17}} \@writefile{toc}{\contentsline {section}{\numberline {2.7}Expressions and operators}{17}} \newlabel{24@xvr}{{}{17}} \newlabel{24@vr}{{}{17}} \newlabel{25@xvr}{{}{17}} \newlabel{25@vr}{{}{17}} \@writefile{lop}{\contentsline {program}{\numberline {2.4}{\ignorespaces A program that uses \ensuremath {\@mathvf {printf}}\textsf {\textmd {\textup {()}}} to display integers.}}{18}} \newlabel{pgm:printfInteger}{{2.4}{18}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.7.1}Expressions and operators---C compared with Pascal}{18}} \newlabel{26@xvr}{{}{18}} \newlabel{26@vr}{{}{18}} \newlabel{27@xvr}{{}{18}} \newlabel{27@vr}{{}{18}} \@writefile{lop}{\contentsline {program}{\numberline {2.5}{\ignorespaces A program that uses \ensuremath {\@mathvf {printf}}\textsf {\textmd {\textup {()}}} to display a few variables of type \textsf {\textbf {\textup {int}}}, \textsf {\textbf {\textup {unsigned int}}}, \textsf {\textbf {\textup {unsigned short}}}, \textsf {\textbf {\textup {char}}}. If you use \textsf {Quincy}\xspace , an integer must be in the range $-2^{15}..2^{15} - 1$, and an unsigned integer must be in the range $0..2^{16}-1$.}}{19}} \newlabel{prg:integralTypes}{{2.5}{19}} \@writefile{lop}{\contentsline {program}{\numberline {2.6}{\ignorespaces Some examples of expressions.}}{19}} \newlabel{prg:expressions}{{2.6}{19}} \@writefile{lof}{\contentsline {figure}{\numberline {2.1}{\ignorespaces A comparison between Pascal and C operators}}{20}} \newlabel{tab:operPas}{{2.1}{20}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.7.2}The assignment operator \textmd {\textsf {=}}}{20}} \@writefile{toc}{\contentsline {subsubsection}{The assignment operator and \IO }{21}} \newlabel{28@xvr}{{}{21}} \newlabel{28@vr}{{}{21}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.7.3}The compound assignment operators}{21}} \newlabel{29@xvr}{{}{21}} \newlabel{29@vr}{{}{21}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.7.4}The relational operators}{21}} \newlabel{30@xvr}{{}{21}} \newlabel{30@vr}{{}{21}} \@writefile{lop}{\contentsline {program}{\numberline {2.7}{\ignorespaces This program demonstrates the compound assignment operators.}}{22}} \newlabel{prg:compound}{{2.7}{22}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.7.5}The increment and decrement operators, \textmd {\textsf {++}} and \textmd {\textsf {$--$}}}{23}} \newlabel{31@xvr}{{}{23}} \newlabel{31@vr}{{}{23}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.7.6}The logical operators}{23}} \@writefile{toc}{\contentsline {subsubsection}{The value of \ensuremath {\@mathvf {true}} and \ensuremath {\@mathvf {false}}}{23}} \newlabel{sec:trueFalse}{{2.7.6}{23}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.7.7}The bitwise operators and bit patterns}{24}} \@writefile{toc}{\contentsline {subsubsection}{The C bitwise AND operator, \textmd {\textsf {\&}}}{25}} \newlabel{sec:and}{{2.7.7}{25}} \newlabel{32@xvr}{{}{25}} \newlabel{32@vr}{{}{25}} \newlabel{33@xvr}{{}{25}} \newlabel{33@vr}{{}{25}} \newlabel{34@xvr}{{}{25}} \newlabel{34@vr}{{}{25}} \@writefile{lop}{\contentsline {program}{\numberline {2.8}{\ignorespaces A program that shows how to use the bitwise AND operator `\textsf {\textmd {\textup {\&}}}' to clear bits 0, 1, 2 and 3 of an integer variable.}}{26}} \newlabel{prg:and}{{2.8}{26}} \@writefile{toc}{\contentsline {subsubsection}{Using bitwise AND to examine the ROW bits in the keypad}{26}} \newlabel{sec:keyand}{{2.7.7}{26}} \newlabel{35@xvr}{{}{26}} \newlabel{35@vr}{{}{26}} \@writefile{toc}{\contentsline {subsubsection}{The C bitwise OR operator, \textmd {\textsf {\textbar }}}{27}} \newlabel{36@xvr}{{}{27}} \newlabel{36@vr}{{}{27}} \@writefile{lop}{\contentsline {program}{\numberline {2.9}{\ignorespaces This program shows the use of the bitwise\nobreakspace {}OR operator, `\textsf {\textmd {\textup {$\@mathsf {|}$}}}'.}}{28}} \newlabel{prg:or}{{2.9}{28}} \@writefile{toc}{\contentsline {subsubsection}{The C bitwise NOT operator, $\sim $}{28}} \newlabel{37@xvr}{{}{29}} \newlabel{37@vr}{{}{29}} \@writefile{toc}{\contentsline {subsubsection}{The C bitwise exclusive-OR operator, {\fontencoding {OMX}\fontfamily {cmex}\fontseries {m}\fontshape {n}\selectfont \ignorespaces \char '142}}{29}} \newlabel{38@xvr}{{}{29}} \newlabel{38@vr}{{}{29}} \@writefile{lop}{\contentsline {program}{\numberline {2.10}{\ignorespaces This program shows the use of the bitwise\nobreakspace {}exclusive-OR operator, `{\fontencoding {OMX}\fontfamily {cmex}\fontseries {m}\fontshape {n}\selectfont \ignorespaces \char '142}'.}}{30}} \newlabel{prg:xor}{{2.10}{30}} \@writefile{toc}{\contentsline {subsubsection}{The shift operators, \Lsh \ and \Rsh }{30}} \@writefile{toc}{\contentsline {section}{\numberline {2.8}Statements}{31}} \newlabel{sec:statements}{{2.8}{31}} \newlabel{39@xvr}{{}{31}} \newlabel{39@vr}{{}{31}} \newlabel{40@xvr}{{}{31}} \newlabel{40@vr}{{}{31}} \newlabel{41@xvr}{{}{31}} \newlabel{41@vr}{{}{31}} \newlabel{42@xvr}{{}{31}} \newlabel{42@vr}{{}{31}} \@writefile{lop}{\contentsline {program}{\numberline {2.11}{\ignorespaces examples of valid statements in C.}}{31}} \newlabel{prg:statements}{{2.11}{31}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.8.1}The null statement}{31}} \newlabel{43@xvr}{{}{31}} \newlabel{43@vr}{{}{31}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.8.2}Compound statements}{31}} \newlabel{sec:block}{{2.8.2}{31}} \newlabel{44@xvr}{{}{32}} \newlabel{44@vr}{{}{32}} \newlabel{45@xvr}{{}{32}} \newlabel{45@vr}{{}{32}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.8.3}\textsf {\textbf {\textup {if}}} statement}{32}} \newlabel{46@xvr}{{}{33}} \newlabel{46@vr}{{}{33}} \@writefile{lop}{\contentsline {program}{\numberline {2.12}{\ignorespaces A program that uses an \textsf {\textbf {\textup {if}}} statement and the modulus operator, `\textsf {\textmd {\textup {\%}}}'.}}{33}} \newlabel{prg:ifMod}{{2.12}{33}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.8.4}The \textsf {\textbf {\textup {while}}} statement}{34}} \newlabel{47@xvr}{{}{34}} \newlabel{47@vr}{{}{34}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.8.5}The \textsf {\textbf {\textup {for}}} statement}{34}} \newlabel{sec:whileExamp}{{2.8.4}{35}} \@writefile{lop}{\contentsline {program}{\numberline {2.13}{\ignorespaces A program using \textsf {\textbf {\textup {while}}}.}}{35}} \newlabel{prg:while}{{2.13}{35}} \newlabel{48@xvr}{{}{36}} \newlabel{48@vr}{{}{36}} \newlabel{49@xvr}{{}{36}} \newlabel{49@vr}{{}{36}} \newlabel{50@xvr}{{}{36}} \newlabel{50@vr}{{}{36}} \newlabel{ex:forLoopSquare}{{2.7}{36}} \newlabel{52@xvr}{{}{37}} \newlabel{52@vr}{{}{37}} \newlabel{51@xvr}{{}{37}} \newlabel{51@vr}{{}{37}} \@writefile{lop}{\contentsline {program}{\numberline {2.14}{\ignorespaces A program equivalent to \vref {prg:while}, except that it uses a \textsf {\textbf {\textup {for}}} loop.}}{37}} \newlabel{prg:for}{{2.14}{37}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.8.6}The \textsf {\textbf {\textup {do}}} statement}{37}} \newlabel{53@xvr}{{}{37}} \newlabel{53@vr}{{}{37}} \newlabel{54@xvr}{{}{37}} \newlabel{54@vr}{{}{37}} \newlabel{55@xvr}{{}{37}} \newlabel{55@vr}{{}{37}} \newlabel{56@xvr}{{}{38}} \newlabel{56@vr}{{}{38}} \newlabel{57@xvr}{{}{38}} \newlabel{57@vr}{{}{38}} \@writefile{lop}{\contentsline {program}{\numberline {2.15}{\ignorespaces This program uses a \textsf {\textbf {\textup {do}}} loop, and produces the same output as the \textsf {\textbf {\textup {while}}} and \textsf {\textbf {\textup {for}}} loop programs, \vref {prg:while} and \vref {prg:for}.}}{38}} \newlabel{prg:do}{{2.15}{38}} \newlabel{58@xvr}{{}{38}} \newlabel{58@vr}{{}{38}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.8.7}Nested loops}{38}} \newlabel{59@xvr}{{}{38}} \newlabel{59@vr}{{}{38}} \newlabel{60@xvr}{{}{38}} \newlabel{60@vr}{{}{38}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.8.8}The \textsf {\textbf {\textup {break}}} statement}{38}} \@writefile{lop}{\contentsline {program}{\numberline {2.16}{\ignorespaces A program using two nested \textsf {\textbf {\textup {for}}} loops.}}{39}} \newlabel{prg:nestedFor}{{2.16}{39}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.8.9}The \textsf {\textbf {\textup {continue}}} statement}{39}} \newlabel{sec:continue}{{2.8.9}{39}} \newlabel{61@xvr}{{}{40}} \newlabel{61@vr}{{}{40}} \@writefile{lop}{\contentsline {program}{\numberline {2.17}{\ignorespaces A program showing nested \textsf {\textbf {\textup {while}}} loops. The output in the terminal window is exactly the same as for program\nobreakspace {}\vref {prg:nestedFor}.}}{40}} \newlabel{prg:nestedWhile}{{2.17}{40}} \@writefile{lop}{\contentsline {program}{\numberline {2.18}{\ignorespaces Using the \textsf {\textbf {\textup {break}}} statement.}}{41}} \newlabel{prg:break}{{2.18}{41}} \newlabel{62@xvr}{{}{41}} \newlabel{62@vr}{{}{41}} \@writefile{toc}{\contentsline {section}{\numberline {2.9}Arrays}{41}} \newlabel{sec:arrays}{{2.9}{41}} \@writefile{lop}{\contentsline {program}{\numberline {2.19}{\ignorespaces A program demonstrating the \textsf {\textbf {\textup {continue}}} statement.}}{42}} \newlabel{prg:continue}{{2.19}{42}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.9.1}Array indexing errors}{43}} \newlabel{sec:arrayIndexingErrors}{{2.9.1}{43}} \newlabel{63@xvr}{{}{44}} \newlabel{63@vr}{{}{44}} \@writefile{lop}{\contentsline {program}{\numberline {2.20}{\ignorespaces A program to use an array to look up patterns to display on the \acro {LED}\xspace {}s in the laboratory.}}{44}} \newlabel{prg:niceLed}{{2.20}{44}} \citation{perry} \newlabel{64@xvr}{{}{45}} \newlabel{64@vr}{{}{45}} \newlabel{ex:while2For}{{2.12}{45}} \@writefile{toc}{\contentsline {section}{\numberline {2.10}Functions}{45}} \@writefile{lop}{\contentsline {program}{\numberline {2.21}{\ignorespaces A program that uses a nested \textsf {\textbf {\textup {for}}} loop to sort an array. (This is called a \emph {bubble sort}).}}{46}} \newlabel{prg:bsort}{{2.21}{46}} \newlabel{65@xvr}{{}{47}} \newlabel{65@vr}{{}{47}} \newlabel{66@xvr}{{}{47}} \newlabel{66@vr}{{}{47}} \@writefile{lop}{\contentsline {program}{\numberline {2.22}{\ignorespaces A program that shows parameters begin passed to a function.}}{48}} \newlabel{prg:parameters}{{2.22}{48}} \newlabel{ex:sevSeg}{{2.15}{49}} \newlabel{67@xvr}{{}{50}} \newlabel{67@vr}{{}{50}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.10.1}Function return values}{50}} \@writefile{lof}{\contentsline {figure}{\numberline {2.2}{\ignorespaces The output required for the program in exercise\nobreakspace {}\vref {ex:sevSeg}.}}{51}} \newlabel{69@xvr}{{}{51}} \newlabel{69@vr}{{}{51}} \newlabel{fig:sevSegOutput}{{2.2}{51}} \newlabel{70@xvr}{{}{51}} \newlabel{70@vr}{{}{51}} \@writefile{toc}{\contentsline {subsubsection}{The return type of \textmd {\textsf {\textit {main}()}}}{51}} \@writefile{lop}{\contentsline {program}{\numberline {2.23}{\ignorespaces A program that calls a \ensuremath {\@mathvf {Silly}}\textsf {\textmd {\textup {()}}} function that shows how \textsf {\textbf {\textup {return}}} terminates execution of a function.}}{52}} \newlabel{prg:silly}{{2.23}{52}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.10.2}The function parameter list}{52}} \newlabel{ex:delay}{{2.16}{53}} \newlabel{71@xvr}{{}{53}} \newlabel{71@vr}{{}{53}} \citation{IHSG} \@writefile{toc}{\contentsline {section}{\numberline {2.11}Indentation of your programs}{54}} \@writefile{toc}{\contentsline {chapter}{\numberline {3}Input and output}{55}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \newlabel{sec:i/o}{{3}{55}} \newlabel{sec:switches(a6)}{{3}{56}} \@writefile{toc}{\contentsline {section}{\numberline {3.1}I/O ports and the 68230 parallel interface/\penalty \z@ {}timer chip}{56}} \newlabel{sec:ioports}{{3.1}{56}} \newlabel{72@xvr}{{}{56}} \newlabel{72@vr}{{}{56}} \newlabel{73@xvr}{{}{57}} \newlabel{73@vr}{{}{57}} \newlabel{74@xvr}{{}{57}} \newlabel{74@vr}{{}{57}} \newlabel{75@xvr}{{}{57}} \newlabel{75@vr}{{}{57}} \newlabel{76@xvr}{{}{57}} \newlabel{76@vr}{{}{57}} \newlabel{77@xvr}{{}{57}} \newlabel{77@vr}{{}{57}} \newlabel{78@xvr}{{}{57}} \newlabel{78@vr}{{}{57}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.1.1}The interface card}{57}} \newlabel{79@xvr}{{}{57}} \newlabel{79@vr}{{}{57}} \@writefile{toc}{\contentsline {section}{\numberline {3.2}The \acro {FLIGHT-68K}\xspace microprocessor\xspace board}{58}} \@writefile{lof}{\contentsline {figure}{\numberline {3.1}{\ignorespaces The connections between the 68000 and the parallel chip on the \acro {FLIGHT-68K}\xspace microprocessor\xspace board, and the connections to port\nobreakspace {}B and port\nobreakspace {}C on the interface board.}}{58}} \newlabel{fig:portBC}{{3.1}{58}} \newlabel{80@xvr}{{}{58}} \newlabel{80@vr}{{}{58}} \citation{nickAsm} \citation{horvath} \citation{flight} \newlabel{81@xvr}{{}{59}} \newlabel{81@vr}{{}{59}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.2.1}Octal tristate buffers on the interface board}{59}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.2.2}Address decoder for the 68230 \acro {PI\Slash {}{}T}\xspace }{59}} \newlabel{82@xvr}{{}{59}} \newlabel{82@vr}{{}{59}} \@writefile{toc}{\contentsline {subsubsection}{Partial address decoding}{59}} \newlabel{83@xvr}{{}{59}} \newlabel{83@vr}{{}{59}} \citation{flight} \@writefile{toc}{\contentsline {subsection}{\numberline {3.2.3}The other connections between the 68000 and the \acro {PI\Slash {}{}T}\xspace }{60}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.2.4}The 68230 parallel interface/\penalty \z@ {}timer chip}{60}} \newlabel{sec:68230}{{3.2.4}{60}} \citation{nickAsm} \newlabel{84@xvr}{{}{61}} \newlabel{84@vr}{{}{61}} \newlabel{85@xvr}{{}{61}} \newlabel{85@vr}{{}{61}} \newlabel{86@xvr}{{}{61}} \newlabel{86@vr}{{}{61}} \@writefile{lot}{\contentsline {table}{\numberline {3.1}{\ignorespaces The port addresses in the 68230 \acro {PI\Slash {}{}T}\xspace and their names we have used in the laboratory.}}{61}} \newlabel{tab:portAddr}{{3.1}{61}} \@writefile{toc}{\contentsline {subsubsection}{The seven segment display}{61}} \newlabel{87@xvr}{{}{61}} \newlabel{87@vr}{{}{61}} \newlabel{88@xvr}{{}{61}} \newlabel{88@vr}{{}{61}} \citation{moto68230} \@writefile{lof}{\contentsline {figure}{\numberline {3.2}{\ignorespaces The bits for each segment in the seven segment display. Note that DP stands for ``decimal point''.}}{62}} \newlabel{fig:sevenseg}{{3.2}{62}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.2.5}The dip switches}{62}} \newlabel{89@xvr}{{}{62}} \newlabel{89@vr}{{}{62}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.2.6}Register addresses in the 68230 \acro {PI\Slash {}{}T}\xspace on the \acro {FLIGHT-68K}\xspace }{62}} \newlabel{sec:registerAddresses}{{3.2.6}{62}} \newlabel{90@xvr}{{}{62}} \newlabel{90@vr}{{}{62}} \@writefile{toc}{\contentsline {paragraph}{The \acro {PI\Slash {}{}T}\xspace has many modes:}{62}} \@writefile{lot}{\contentsline {table}{\numberline {3.2}{\ignorespaces The addresses of registers in the 68230 \acro {PI\Slash {}{}T}\xspace on the \acro {FLIGHT-68K}\xspace . All addresses and offsets are in hexadecimal.}}{63}} \newlabel{tab:registerAddr}{{3.2}{63}} \citation{moto68230} \newlabel{sec:submode1x}{{3.2.6}{64}} \@writefile{toc}{\contentsline {paragraph}{Submode 1X}{64}} \newlabel{91@xvr}{{}{64}} \newlabel{91@vr}{{}{64}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.2.7}Initialising the \acro {PI\Slash {}{}T}\xspace for bit \IO }{64}} \newlabel{sec:initPitForBitIO}{{3.2.7}{64}} \newlabel{92@xvr}{{}{64}} \newlabel{92@vr}{{}{64}} \@writefile{toc}{\contentsline {paragraph}{What does it all mean?}{64}} \newlabel{93@xvr}{{}{64}} \newlabel{93@vr}{{}{64}} \@writefile{lot}{\contentsline {table}{\numberline {3.3}{\ignorespaces The values to be written into individual bits of the port\nobreakspace {}A control register (\ensuremath {\@mathvf {PACR}}) and the port\nobreakspace {}B control register (\ensuremath {\@mathvf {PBDR}}) to put these ports into submode\nobreakspace {}1X.}}{65}} \newlabel{tab:submode1x}{{3.3}{65}} \@writefile{toc}{\contentsline {subsubsection}{Choosing inputs and outputs: the data direction registers}{66}} \newlabel{sec:ddr}{{3.2.7}{66}} \@writefile{toc}{\contentsline {subsubsection}{Initialising the \acro {PI\Slash {}{}T}\xspace for bit \IO : a summary}{66}} \newlabel{94@xvr}{{}{66}} \newlabel{94@vr}{{}{66}} \newlabel{95@xvr}{{}{66}} \newlabel{95@vr}{{}{66}} \newlabel{96@xvr}{{}{66}} \newlabel{96@vr}{{}{66}} \@writefile{lop}{\contentsline {program}{\numberline {3.1}{\ignorespaces The function \ensuremath {\@mathvf {InitParallelChip}}\textsf {\textmd {\textup {()}}}, which is called by the startup code which is executed before \ensuremath {\@mathvf {main}}\textsf {\textmd {\textup {()}}} begins. The purpose of \ensuremath {\@mathvf {InitParallelChip}}\textsf {\textmd {\textup {()}}} is to initialise the \acro {PI\Slash {}{}T}\xspace appropriately for the interface board with the \acro {LED}\xspace {}s, seven-segment display, dip-switches and $3 \times 4$ telephone keypad.}}{67}} \newlabel{prg:startupCode}{{3.1}{67}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.2.8}How the interface card is connected to the parallel chip}{67}} \newlabel{97@xvr}{{}{67}} \newlabel{97@vr}{{}{67}} \@writefile{lof}{\contentsline {figure}{\numberline {3.3}{\ignorespaces The two settings for the jumper on the interface board}}{68}} \newlabel{fig:jump}{{3.3}{68}} \@writefile{toc}{\contentsline {section}{\numberline {3.3}The keypad}{68}} \newlabel{sec:keypad}{{3.3}{68}} \newlabel{98@xvr}{{}{68}} \newlabel{98@vr}{{}{68}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.3.1}Scanning the keypad}{68}} \@writefile{lof}{\contentsline {figure}{\numberline {3.4}{\ignorespaces The connection of the keypad to the 68230 parallel interface/\penalty \z@ {}timer chip}}{69}} \newlabel{fig:keypad}{{3.4}{69}} \@writefile{toc}{\contentsline {subsubsection}{The method}{69}} \newlabel{sec:readKeyExplain}{{3.3.1}{69}} \newlabel{99@xvr}{{}{69}} \newlabel{99@vr}{{}{69}} \newlabel{pag:readkey}{{3.3.1}{71}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.3.2}Debouncing the keys}{71}} \newlabel{sec:debouncing}{{3.3.2}{71}} \newlabel{100@xvr}{{}{72}} \newlabel{100@vr}{{}{72}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.3.3}How to detect if any key has been pressed}{72}} \newlabel{sec:keyPressed}{{3.3.3}{72}} \newlabel{qes:rowtest}{{3.5}{73}} \@writefile{toc}{\contentsline {chapter}{\numberline {A}The operators in C and their precedence}{74}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \newlabel{sec:operators}{{A}{74}} \newlabel{101@xvr}{{}{74}} \newlabel{101@vr}{{}{74}} \@writefile{toc}{\contentsline {section}{\numberline {A.1}Operator precedence}{74}} \@writefile{lot}{\contentsline {table}{\numberline {A.1}{\ignorespaces A list of all operators provided in the C programming language, showing level of precedence.}}{76}} \newlabel{tab:operatorPrecedence}{{A.1}{76}} \@writefile{toc}{\contentsline {chapter}{\numberline {B}The \acro {ASCII}\xspace code for representing characters}{77}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \newlabel{sec:ascii}{{B}{77}} \newlabel{102@xvr}{{}{77}} \newlabel{102@vr}{{}{77}} \@writefile{lot}{\contentsline {table}{\numberline {B.1}{\ignorespaces The \acro {ASCII}\xspace table}}{78}} \newlabel{tab:ascii}{{B.1}{78}} \@writefile{toc}{\contentsline {chapter}{\numberline {C}The memory map of the 68000 system in the laboratory}{79}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \newlabel{103@xvr}{{}{79}} \newlabel{103@vr}{{}{79}} \newlabel{104@xvr}{{}{79}} \newlabel{104@vr}{{}{79}} \newlabel{105@xvr}{{}{79}} \newlabel{105@vr}{{}{79}} \@writefile{lof}{\contentsline {figure}{\numberline {C.1}{\ignorespaces A memory map of the \acro {FLIGHT-68K}\xspace microprocessor\xspace board. M means megabytes; K means kilobytes. $1\@mathrm {M}= 2^{20}$; $1\@mathrm {K}= 2^{10}$.}}{80}} \newlabel{fig:memmap}{{C.1}{80}} \@writefile{toc}{\contentsline {chapter}{\numberline {D}The compile, assemble and link process}{81}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \newlabel{sec:compiler}{{D}{81}} \newlabel{106@xvr}{{}{81}} \newlabel{106@vr}{{}{81}} \@writefile{toc}{\contentsline {section}{\numberline {D.1}The preprocessor}{81}} \newlabel{sec:preprocessor}{{D.1}{81}} \newlabel{107@xvr}{{}{81}} \newlabel{107@vr}{{}{81}} \@writefile{lof}{\contentsline {figure}{\numberline {D.1}{\ignorespaces The programs involved in compiling the program \meta {prog}\texttt {.c}. Note that the files \meta {prog}\texttt {.i}, \meta {prog}\texttt {.s} are deleted automatically unless you ask the compiler to keep them. Also \meta {prog}\texttt {.lst} will only be created if you ask the compiler to make it.}}{82}} \newlabel{fig:compiler}{{D.1}{82}} \@writefile{toc}{\contentsline {section}{\numberline {D.2}The translator (or the main part of the C compiler)}{83}} \@writefile{toc}{\contentsline {section}{\numberline {D.3}The listing file and the map file}{83}} \@writefile{toc}{\contentsline {section}{\numberline {D.4}The assembler}{83}} \@writefile{toc}{\contentsline {section}{\numberline {D.5}Relocatable object file}{84}} \@writefile{toc}{\contentsline {section}{\numberline {D.6}The linker}{84}} \@writefile{toc}{\contentsline {subsection}{\numberline {D.6.1}The startup code}{84}} \newlabel{sec:startupCode}{{D.6.1}{84}} \newlabel{108@xvr}{{}{85}} \newlabel{108@vr}{{}{85}} \newlabel{109@xvr}{{}{85}} \newlabel{109@vr}{{}{85}} \@writefile{toc}{\contentsline {section}{\numberline {D.7}The library}{85}} \newlabel{sec:library}{{D.7}{85}} \newlabel{110@xvr}{{}{85}} \newlabel{110@vr}{{}{85}} \newlabel{111@xvr}{{}{85}} \newlabel{111@vr}{{}{85}} \@writefile{toc}{\contentsline {subsection}{\numberline {D.7.1}The file \texttt {flight.h}}{85}} \newlabel{sec:flight.h}{{D.7.1}{85}} \newlabel{112@xvr}{{}{85}} \newlabel{112@vr}{{}{85}} \@writefile{toc}{\contentsline {subsection}{\numberline {D.7.2}The library function \ensuremath {\@mathvf {DelayMs}}\textsf {\textmd {\textup {()}}}}{86}} \newlabel{sec:delayMs}{{D.7.2}{86}} \newlabel{113@xvr}{{}{86}} \newlabel{113@vr}{{}{86}} \@writefile{lop}{\contentsline {program}{\numberline {D.1}{\ignorespaces A definition of \ensuremath {\@mathvf {DelayMs}}\textsf {\textmd {\textup {()}}}.}}{86}} \newlabel{prg:delayMs}{{D.1}{86}} \citation{flight} \citation{nickAsm} \citation{flight} \@writefile{toc}{\contentsline {subsection}{\numberline {D.7.3}The library function \ensuremath {\@mathvf {kbhit}}\textsf {\textmd {\textup {()}}}}{87}} \newlabel{sec:kbhit}{{D.7.3}{87}} \newlabel{114@xvr}{{}{87}} \newlabel{114@vr}{{}{87}} \newlabel{115@xvr}{{}{87}} \newlabel{115@vr}{{}{87}} \newlabel{116@xvr}{{}{87}} \newlabel{116@vr}{{}{87}} \newlabel{117@xvr}{{}{87}} \newlabel{117@vr}{{}{87}} \@writefile{toc}{\contentsline {subsection}{\numberline {D.7.4}The library function \ensuremath {\@mathvf {getch}}\textsf {\textmd {\textup {()}}}}{87}} \newlabel{sec:getch}{{D.7.4}{87}} \@writefile{lop}{\contentsline {program}{\numberline {D.2}{\ignorespaces The assembly language implementation of \ensuremath {\@mathvf {kbhit}}\textsf {\textmd {\textup {()}}}.}}{88}} \newlabel{prg:kbhit}{{D.2}{88}} \newlabel{118@xvr}{{}{88}} \newlabel{118@vr}{{}{88}} \@writefile{lop}{\contentsline {program}{\numberline {D.3}{\ignorespaces The implementation of the library function \ensuremath {\@mathvf {getch}}\textsf {\textmd {\textup {()}}}.}}{88}} \newlabel{prg:getch}{{D.3}{88}} \@writefile{toc}{\contentsline {subsection}{\numberline {D.7.5}The library function \ensuremath {\@mathvf {WriteSevenSegment}}\textsf {\textmd {\textup {()}}}}{88}} \newlabel{sec:writeSevenSegment}{{D.7.5}{88}} \newlabel{119@xvr}{{}{89}} \newlabel{119@vr}{{}{89}} \@writefile{lop}{\contentsline {program}{\numberline {D.4}{\ignorespaces The library function \ensuremath {\@mathvf {WriteSevenSegment}}\textsf {\textmd {\textup {()}}}.}}{89}} \newlabel{prg:sevseg}{{D.4}{89}} \@writefile{toc}{\contentsline {subsection}{\numberline {D.7.6}The library function \ensuremath {\@mathvf {ReadKey}}\textsf {\textmd {\textup {()}}}}{89}} \newlabel{120@xvr}{{}{89}} \newlabel{120@vr}{{}{89}} \newlabel{121@xvr}{{}{89}} \newlabel{121@vr}{{}{89}} \@writefile{lot}{\contentsline {table}{\numberline {D.1}{\ignorespaces The return values of the library function \ensuremath {\@mathvf {ReadKey}}\textsf {\textmd {\textup {()}}}.}}{90}} \newlabel{tab:readKeyRetVal}{{D.1}{90}} \newlabel{122@xvr}{{}{90}} \newlabel{122@vr}{{}{90}} \newlabel{123@xvr}{{}{90}} \newlabel{123@vr}{{}{90}} \@writefile{lop}{\contentsline {program}{\numberline {D.5}{\ignorespaces The library function \ensuremath {\@mathvf {ReadKey}}\textsf {\textmd {\textup {()}}}. This is an implementation of the algorithm described in section\nobreakspace {}\vref {sec:readKeyExplain}.}}{90}} \newlabel{prg:readkey}{{D.5}{90}} \@writefile{toc}{\contentsline {section}{\numberline {D.8}The \textsf {make} program}{90}} \@writefile{toc}{\contentsline {chapter}{\numberline {E}Why C and not assembly language?}{92}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \newlabel{sec:ansi}{{E}{92}} \citation{drDobbs} \citation{stevens} \@writefile{toc}{\contentsline {chapter}{\numberline {F}The \textsf {Quincy}\xspace interpreter---get it and use it!}{94}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \newlabel{sec:qc}{{F}{94}} \@writefile{toc}{\contentsline {section}{\numberline {F.1}What is \textsf {Quincy}\xspace ?}{94}} \@writefile{toc}{\contentsline {subsection}{\numberline {F.1.1}What is an interpreter?}{94}} \@writefile{toc}{\contentsline {subsection}{\numberline {F.1.2}What can I do with \textsf {Quincy}\xspace ?}{95}} \@writefile{toc}{\contentsline {section}{\numberline {F.2}How to get a copy of \textsf {Quincy}\xspace }{95}} \newlabel{sec:howCopyQc}{{F.2}{95}} \@writefile{toc}{\contentsline {chapter}{\numberline {G}Compiler errors: they are there to help you}{97}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \@writefile{toc}{\contentsline {section}{\numberline {G.1}What do I do if there are lots of error messages?}{98}} \@writefile{toc}{\contentsline {section}{\numberline {G.2}Error messages from different parts of the compiler}{98}} \newlabel{124@xvr}{{}{98}} \newlabel{124@vr}{{}{98}} \newlabel{125@xvr}{{}{98}} \newlabel{125@vr}{{}{98}} \@writefile{toc}{\contentsline {subsection}{\numberline {G.2.1}Error messages from the preprocessor}{98}} \@writefile{toc}{\contentsline {subsection}{\numberline {G.2.2}Error messages from the main part of the compiler}{99}} \newlabel{pag:testc}{{G.2.2}{100}} \newlabel{126@xvr}{{}{100}} \newlabel{126@vr}{{}{100}} \@writefile{toc}{\contentsline {subsection}{\numberline {G.2.3}Error messages from the linker}{100}} \newlabel{127@xvr}{{}{101}} \newlabel{127@vr}{{}{101}} \@writefile{toc}{\contentsline {chapter}{\numberline {H}Editing, compiling, downloading and running a program}{102}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \newlabel{sec:ecdr}{{H}{102}} \@writefile{toc}{\contentsline {section}{\numberline {H.1}The program design}{102}} \@writefile{toc}{\contentsline {section}{\numberline {H.2}The general procedure for editing, assembling, downloading and running an assembly language program}{102}} \newlabel{128@xvr}{{}{103}} \newlabel{128@vr}{{}{103}} \@writefile{toc}{\contentsline {section}{\numberline {H.3}Editing the program}{103}} \newlabel{129@xvr}{{}{103}} \newlabel{129@vr}{{}{103}} \@writefile{lop}{\contentsline {program}{\numberline {H.1}{\ignorespaces All your programs will have a form similar to this.}}{104}} \newlabel{prg:progTemplate}{{H.1}{104}} \@writefile{toc}{\contentsline {section}{\numberline {H.4}Compiling your program}{105}} \@writefile{toc}{\contentsline {section}{\numberline {H.5}Downloading the program}{105}} \newlabel{pag:monitor}{{3}{106}} \@writefile{toc}{\contentsline {section}{\numberline {H.6}Running the program}{106}} \@writefile{toc}{\contentsline {chapter}{\numberline {I}Solutions to exercises}{107}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \newlabel{sec:solutions}{{I}{107}} \newlabel{130@xvr}{{}{113}} \newlabel{130@vr}{{}{113}} \newlabel{131@xvr}{{}{113}} \newlabel{131@vr}{{}{113}} \newlabel{132@xvr}{{}{113}} \newlabel{132@vr}{{}{113}} \newlabel{133@xvr}{{}{116}} \newlabel{133@vr}{{}{116}} \newlabel{134@xvr}{{}{117}} \newlabel{134@vr}{{}{117}} \bibstyle{is-alpha} \bibdata{mc68k} \bibcite{cktCellar}{CC} \bibcite{IHSG}{CEK{$^{+}$}} \bibcite{drDobbs}{DDJ} \bibcite{flight}{{Fli}88} \bibcite{horvath}{Hor92} \bibcite{kernighan}{KR88} \bibcite{moto68230}{Mot83} \bibcite{perry}{Per94} \bibcite{stevens}{Ste94} \bibcite{cFaq}{Sum} \@writefile{toc}{\contentsline {chapter}{References}{120}} \newlabel{sec:references}{{I}{120}} \bibcite{nickAsm}{Urb96} \@writefile{toc}{\contentsline {chapter}{Index}{122}} \newlabel{LastPage}{{}{126}}