\relax \newlabel{1@xvr}{{}{vii}} \newlabel{1@vr}{{}{vii}} \newlabel{2@xvr}{{}{ix}} \newlabel{2@vr}{{}{ix}} \newlabel{3@xvr}{{}{ix}} \newlabel{3@vr}{{}{ix}} \newlabel{4@xvr}{{}{ix}} \newlabel{4@vr}{{}{ix}} \newlabel{5@xvr}{{}{x}} \newlabel{5@vr}{{}{x}} \newlabel{6@xvr}{{}{x}} \newlabel{6@vr}{{}{x}} \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}} \@writefile{toc}{\contentsline {section}{\numberline {1.3}Embedded systems}{3}} \newlabel{sec:embedded}{{1.3}{3}} \citation{flight} \@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}{7}} \newlabel{14@xvr}{{}{8}} \newlabel{14@vr}{{}{8}} \newlabel{15@xvr}{{}{8}} \newlabel{15@vr}{{}{8}} \@writefile{toc}{\contentsline {section}{\numberline {2.2}Integral types}{8}} \newlabel{16@xvr}{{}{8}} \newlabel{16@vr}{{}{8}} \newlabel{qes:variable}{{a}{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}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.2.1}Definitions and declarations of integer-type variables}{9}} \newlabel{sec:declarations}{{2.2.1}{9}} \newlabel{17@xvr}{{}{9}} \newlabel{17@vr}{{}{9}} \newlabel{18@xvr}{{}{9}} \newlabel{18@vr}{{}{9}} \@writefile{lop}{\contentsline {program}{\numberline {2.1}{\ignorespaces Definitions of integral-type variables.}}{9}} \newlabel{prg:definition}{{2.1}{9}} \newlabel{19@xvr}{{}{10}} \newlabel{19@vr}{{}{10}} \@writefile{toc}{\contentsline {section}{\numberline {2.3}The meaning of \textsf {\textbf {\textup {\#include}}}}{10}} \newlabel{sec:include}{{2.3}{10}} \newlabel{20@xvr}{{}{10}} \newlabel{20@vr}{{}{10}} \newlabel{21@xvr}{{}{10}} \newlabel{21@vr}{{}{10}} \@writefile{toc}{\contentsline {section}{\numberline {2.4}Comments in the C language}{10}} \newlabel{sec:comments}{{2.4}{10}} \@writefile{toc}{\contentsline {section}{\numberline {2.5}C is case sensitive}{11}} \newlabel{sec:caseSensitive}{{2.5}{11}} \@writefile{toc}{\contentsline {section}{\numberline {2.6}The use of \textmd {\textsf {\textsl {printf}()}}}{11}} \newlabel{22@xvr}{{}{11}} \newlabel{22@vr}{{}{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}} \@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 {'}}}.}}{12}} \newlabel{prg:printfNewline}{{2.3}{12}} \@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}{13}} \@writefile{toc}{\contentsline {subsubsection}{Displaying an \textsf {\textbf {\textup {unsigned char}}}}{14}} \@writefile{toc}{\contentsline {subsubsection}{Displaying a \textsf {\textbf {\textup {long int}}}}{15}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.6.2}Displaying a string}{15}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.6.3}A warning about the format characters and \textmd {\textsf {\textsl {printf}()}}}{15}} \@writefile{toc}{\contentsline {subsubsection}{A summary of the format characters}{15}} \newlabel{23@xvr}{{}{15}} \newlabel{23@vr}{{}{15}} \citation{stevens} \@writefile{lot}{\contentsline {table}{\numberline {2.2}{\ignorespaces The format characters for use with \ensuremath {\@mathvf {printf}}\textsf {\textmd {\textup {()}}}.}}{16}} \newlabel{tab:formatChars}{{2.2}{16}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.6.4}Example programs showing the use of \textmd {\textsf {\textsl {printf}()}}}{16}} \newlabel{24@xvr}{{}{16}} \newlabel{24@vr}{{}{16}} \newlabel{25@xvr}{{}{16}} \newlabel{25@vr}{{}{16}} \@writefile{lop}{\contentsline {program}{\numberline {2.4}{\ignorespaces A program that uses \ensuremath {\@mathvf {printf}}\textsf {\textmd {\textup {()}}} to display integers.}}{17}} \newlabel{pgm:printfInteger}{{2.4}{17}} \@writefile{toc}{\contentsline {section}{\numberline {2.7}Expressions and operators}{17}} \newlabel{sec:expression}{{2.7}{17}} \newlabel{26@xvr}{{}{17}} \newlabel{26@vr}{{}{17}} \newlabel{27@xvr}{{}{17}} \newlabel{27@vr}{{}{17}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.7.1}Expressions and operators---C compared with Pascal}{17}} \newlabel{28@xvr}{{}{17}} \newlabel{28@vr}{{}{17}} \@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$.}}{18}} \newlabel{prg:integralTypes}{{2.5}{18}} \@writefile{lop}{\contentsline {program}{\numberline {2.6}{\ignorespaces Some examples of expressions.}}{18}} \newlabel{prg:expressions}{{2.6}{18}} \newlabel{29@xvr}{{}{18}} \newlabel{29@vr}{{}{18}} \@writefile{lof}{\contentsline {figure}{\numberline {2.1}{\ignorespaces A comparison between Pascal and C operators}}{19}} \newlabel{tab:operPas}{{2.1}{19}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.7.2}The assignment operator \textmd {\textsf {=}}}{19}} \newlabel{30@xvr}{{}{20}} \newlabel{30@vr}{{}{20}} \newlabel{31@xvr}{{}{20}} \newlabel{31@vr}{{}{20}} \newlabel{32@xvr}{{}{20}} \newlabel{32@vr}{{}{20}} \@writefile{lop}{\contentsline {program}{\numberline {2.7}{\ignorespaces Some examples comparing assignment and initialisation.}}{20}} \newlabel{prg:initialisation}{{2.7}{20}} \@writefile{toc}{\contentsline {subsubsection}{The assignment operator and \IO }{20}} \newlabel{33@xvr}{{}{21}} \newlabel{33@vr}{{}{21}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.7.3}The compound assignment operators}{21}} \newlabel{34@xvr}{{}{21}} \newlabel{34@vr}{{}{21}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.7.4}The relational operators}{21}} \newlabel{35@xvr}{{}{21}} \newlabel{35@vr}{{}{21}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.7.5}The increment and decrement operators, \textmd {\textsf {++}} and \textmd {\textsf {$--$}}}{21}} \newlabel{36@xvr}{{}{21}} \newlabel{36@vr}{{}{21}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.7.6}The logical operators}{21}} \@writefile{lop}{\contentsline {program}{\numberline {2.8}{\ignorespaces This program demonstrates the compound assignment operators.}}{22}} \newlabel{prg:compound}{{2.8}{22}} \@writefile{toc}{\contentsline {subsubsection}{The value of \ensuremath {\@mathvf {true}} and \ensuremath {\@mathvf {false}}}{23}} \newlabel{sec:trueFalse}{{2.7.6}{23}} \newlabel{37@xvr}{{}{23}} \newlabel{37@vr}{{}{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 {\&}}}{24}} \newlabel{sec:and}{{2.7.7}{24}} \newlabel{38@xvr}{{}{25}} \newlabel{38@vr}{{}{25}} \newlabel{39@xvr}{{}{25}} \newlabel{39@vr}{{}{25}} \newlabel{40@xvr}{{}{25}} \newlabel{40@vr}{{}{25}} \newlabel{41@xvr}{{}{25}} \newlabel{41@vr}{{}{25}} \@writefile{lop}{\contentsline {program}{\numberline {2.9}{\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.}}{25}} \newlabel{prg:and}{{2.9}{25}} \@writefile{toc}{\contentsline {subsubsection}{Using bitwise AND to examine the ROW bits in the keypad}{25}} \newlabel{sec:keyand}{{2.7.7}{25}} \newlabel{42@xvr}{{}{25}} \newlabel{42@vr}{{}{25}} \@writefile{toc}{\contentsline {subsubsection}{The C bitwise OR operator, \textmd {\textsf {\textbar }}}{26}} \newlabel{43@xvr}{{}{27}} \newlabel{43@vr}{{}{27}} \@writefile{toc}{\contentsline {subsubsection}{The C bitwise NOT operator, $\sim $}{27}} \newlabel{44@xvr}{{}{27}} \newlabel{44@vr}{{}{27}} \@writefile{toc}{\contentsline {subsubsection}{The C bitwise exclusive-OR operator, {\fontencoding {OMX}\fontfamily {cmex}\fontseries {m}\fontshape {n}\selectfont \ignorespaces \char '142}}{27}} \@writefile{lop}{\contentsline {program}{\numberline {2.10}{\ignorespaces This program shows the use of the bitwise\nobreakspace {}OR operator, `\textsf {\textmd {\textup {$\@mathsf {|}$}}}'.}}{28}} \newlabel{prg:or}{{2.10}{28}} \newlabel{45@xvr}{{}{29}} \newlabel{45@vr}{{}{29}} \@writefile{lop}{\contentsline {program}{\numberline {2.11}{\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}'.}}{29}} \newlabel{prg:xor}{{2.11}{29}} \@writefile{toc}{\contentsline {subsubsection}{The shift operators, \Lsh \ and \Rsh }{29}} \@writefile{toc}{\contentsline {section}{\numberline {2.8}Statements}{30}} \newlabel{sec:statements}{{2.8}{30}} \newlabel{46@xvr}{{}{30}} \newlabel{46@vr}{{}{30}} \newlabel{47@xvr}{{}{30}} \newlabel{47@vr}{{}{30}} \newlabel{48@xvr}{{}{30}} \newlabel{48@vr}{{}{30}} \newlabel{49@xvr}{{}{30}} \newlabel{49@vr}{{}{30}} \@writefile{lop}{\contentsline {program}{\numberline {2.12}{\ignorespaces examples of valid statements in C.}}{30}} \newlabel{prg:statements}{{2.12}{30}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.8.1}The null statement}{30}} \newlabel{sec:nullStatement}{{2.8.1}{30}} \newlabel{50@xvr}{{}{30}} \newlabel{50@vr}{{}{30}} \newlabel{pag:badNullStatement2}{{2.8.1}{30}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.8.2}Compound statements}{31}} \newlabel{sec:block}{{2.8.2}{31}} \newlabel{51@xvr}{{}{31}} \newlabel{51@vr}{{}{31}} \newlabel{52@xvr}{{}{31}} \newlabel{52@vr}{{}{31}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.8.3}\textsf {\textbf {\textup {if}}} statement}{31}} \newlabel{53@xvr}{{}{32}} \newlabel{53@vr}{{}{32}} \@writefile{lop}{\contentsline {program}{\numberline {2.13}{\ignorespaces A program that uses an \textsf {\textbf {\textup {if}}} statement and the modulus operator, `\textsf {\textmd {\textup {\%}}}'.}}{32}} \newlabel{prg:ifMod}{{2.13}{32}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.8.4}The \textsf {\textbf {\textup {while}}} statement}{33}} \newlabel{54@xvr}{{}{33}} \newlabel{54@vr}{{}{33}} \newlabel{55@xvr}{{}{33}} \newlabel{55@vr}{{}{33}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.8.5}The \textsf {\textbf {\textup {for}}} statement}{33}} \newlabel{sec:whileExamp}{{2.8.4}{34}} \@writefile{lop}{\contentsline {program}{\numberline {2.14}{\ignorespaces A program using \textsf {\textbf {\textup {while}}}.}}{34}} \newlabel{prg:while}{{2.14}{34}} \newlabel{56@xvr}{{}{35}} \newlabel{56@vr}{{}{35}} \newlabel{57@xvr}{{}{35}} \newlabel{57@vr}{{}{35}} \newlabel{58@xvr}{{}{35}} \newlabel{58@vr}{{}{35}} \newlabel{ex:forLoopSquare}{{2.7}{35}} \newlabel{ex:while2For}{{2.8}{35}} \newlabel{60@xvr}{{}{36}} \newlabel{60@vr}{{}{36}} \newlabel{59@xvr}{{}{36}} \newlabel{59@vr}{{}{36}} \@writefile{lop}{\contentsline {program}{\numberline {2.15}{\ignorespaces A program equivalent to \vref {prg:while}, except that it uses a \textsf {\textbf {\textup {for}}} loop.}}{36}} \newlabel{prg:for}{{2.15}{36}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.8.6}The \textsf {\textbf {\textup {do}}} statement}{37}} \newlabel{61@xvr}{{}{37}} \newlabel{61@vr}{{}{37}} \newlabel{62@xvr}{{}{37}} \newlabel{62@vr}{{}{37}} \newlabel{63@xvr}{{}{37}} \newlabel{63@vr}{{}{37}} \newlabel{66@xvr}{{}{37}} \newlabel{66@vr}{{}{37}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.8.7}Nested loops}{37}} \newlabel{67@xvr}{{}{37}} \newlabel{67@vr}{{}{37}} \newlabel{68@xvr}{{}{37}} \newlabel{68@vr}{{}{37}} \newlabel{64@xvr}{{}{38}} \newlabel{64@vr}{{}{38}} \newlabel{65@xvr}{{}{38}} \newlabel{65@vr}{{}{38}} \@writefile{lop}{\contentsline {program}{\numberline {2.16}{\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.16}{38}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.8.8}The \textsf {\textbf {\textup {break}}} statement}{38}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.8.9}The \textsf {\textbf {\textup {continue}}} statement}{38}} \newlabel{sec:continue}{{2.8.9}{38}} \@writefile{lop}{\contentsline {program}{\numberline {2.17}{\ignorespaces A program using two nested \textsf {\textbf {\textup {for}}} loops.}}{39}} \newlabel{prg:nestedFor}{{2.17}{39}} \newlabel{70@xvr}{{}{39}} \newlabel{70@vr}{{}{39}} \newlabel{69@xvr}{{}{40}} \newlabel{69@vr}{{}{40}} \@writefile{lop}{\contentsline {program}{\numberline {2.18}{\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.18}{40}} \@writefile{toc}{\contentsline {section}{\numberline {2.9}Arrays}{40}} \newlabel{sec:arrays}{{2.9}{40}} \@writefile{lop}{\contentsline {program}{\numberline {2.19}{\ignorespaces Using the \textsf {\textbf {\textup {break}}} statement.}}{41}} \newlabel{prg:break}{{2.19}{41}} \@writefile{lop}{\contentsline {program}{\numberline {2.20}{\ignorespaces A program demonstrating the \textsf {\textbf {\textup {continue}}} statement.}}{42}} \newlabel{prg:continue}{{2.20}{42}} \citation{perry} \@writefile{toc}{\contentsline {subsection}{\numberline {2.9.1}Array indexing errors}{43}} \newlabel{71@xvr}{{}{43}} \newlabel{71@vr}{{}{43}} \newlabel{72@xvr}{{}{43}} \newlabel{72@vr}{{}{43}} \@writefile{lop}{\contentsline {program}{\numberline {2.21}{\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.21}{44}} \@writefile{toc}{\contentsline {section}{\numberline {2.10}Functions}{44}} \@writefile{lop}{\contentsline {program}{\numberline {2.22}{\ignorespaces A program that uses a nested \textsf {\textbf {\textup {for}}} loop to sort an array. (This is called a \emph {bubble sort}).}}{45}} \newlabel{prg:bsort}{{2.22}{45}} \newlabel{73@xvr}{{}{46}} \newlabel{73@vr}{{}{46}} \@writefile{lop}{\contentsline {program}{\numberline {2.23}{\ignorespaces A program that shows parameters begin passed to a function.}}{46}} \newlabel{prg:parameters}{{2.23}{46}} \newlabel{74@xvr}{{}{47}} \newlabel{74@vr}{{}{47}} \newlabel{ex:sevSeg}{{2.15}{48}} \newlabel{75@xvr}{{}{49}} \newlabel{75@vr}{{}{49}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.10.1}Function return values}{49}} \newlabel{78@xvr}{{}{49}} \newlabel{78@vr}{{}{49}} \@writefile{lof}{\contentsline {figure}{\numberline {2.2}{\ignorespaces The output required for the program in exercise\nobreakspace {}\vref {ex:sevSeg}.}}{50}} \newlabel{77@xvr}{{}{50}} \newlabel{77@vr}{{}{50}} \newlabel{fig:sevSegOutput}{{2.2}{50}} \@writefile{toc}{\contentsline {subsubsection}{The return type of \textmd {\textsf {\textit {main}()}}}{50}} \@writefile{toc}{\contentsline {subsection}{\numberline {2.10.2}The function parameter list}{50}} \@writefile{lop}{\contentsline {program}{\numberline {2.24}{\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.}}{51}} \newlabel{prg:silly}{{2.24}{51}} \citation{IHSG} \newlabel{ex:delay}{{2.16}{52}} \newlabel{79@xvr}{{}{52}} \newlabel{79@vr}{{}{52}} \@writefile{toc}{\contentsline {section}{\numberline {2.11}Indentation of your programs}{53}} \@writefile{toc}{\contentsline {chapter}{\numberline {3}Input and output}{54}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \newlabel{sec:i/o}{{3}{54}} \newlabel{sec:switches(a6)}{{3}{55}} \@writefile{toc}{\contentsline {section}{\numberline {3.1}I/O ports and the 68230 parallel interface/\penalty \z@ {}timer chip}{55}} \newlabel{sec:ioports}{{3.1}{55}} \newlabel{80@xvr}{{}{55}} \newlabel{80@vr}{{}{55}} \newlabel{81@xvr}{{}{55}} \newlabel{81@vr}{{}{55}} \citation{nickAsm} \citation{horvath} \citation{flight} \newlabel{82@xvr}{{}{56}} \newlabel{82@vr}{{}{56}} \newlabel{83@xvr}{{}{56}} \newlabel{83@vr}{{}{56}} \newlabel{84@xvr}{{}{56}} \newlabel{84@vr}{{}{56}} \newlabel{85@xvr}{{}{56}} \newlabel{85@vr}{{}{56}} \newlabel{86@xvr}{{}{56}} \newlabel{86@vr}{{}{56}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.1.1}The interface card}{56}} \newlabel{87@xvr}{{}{56}} \newlabel{87@vr}{{}{56}} \@writefile{toc}{\contentsline {section}{\numberline {3.2}The \acro {FLIGHT-68K}\xspace microprocessor\xspace board}{56}} \newlabel{88@xvr}{{}{56}} \newlabel{88@vr}{{}{56}} \newlabel{89@xvr}{{}{56}} \newlabel{89@vr}{{}{56}} \@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.}}{57}} \newlabel{fig:portBC}{{3.1}{57}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.2.1}Octal tristate buffers on the interface board}{58}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.2.2}Address decoder for the 68230 \acro {PI\Slash {}{}T}\xspace }{58}} \newlabel{90@xvr}{{}{58}} \newlabel{90@vr}{{}{58}} \@writefile{toc}{\contentsline {subsubsection}{Partial address decoding}{58}} \newlabel{91@xvr}{{}{58}} \newlabel{91@vr}{{}{58}} \citation{flight} \@writefile{toc}{\contentsline {subsection}{\numberline {3.2.3}The other connections between the 68000 and the \acro {PI\Slash {}{}T}\xspace }{59}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.2.4}The 68230 parallel interface/\penalty \z@ {}timer chip}{59}} \newlabel{sec:68230}{{3.2.4}{59}} \citation{nickAsm} \newlabel{92@xvr}{{}{60}} \newlabel{92@vr}{{}{60}} \newlabel{93@xvr}{{}{60}} \newlabel{93@vr}{{}{60}} \newlabel{94@xvr}{{}{60}} \newlabel{94@vr}{{}{60}} \@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.}}{60}} \newlabel{tab:portAddr}{{3.1}{60}} \@writefile{toc}{\contentsline {subsubsection}{The seven segment display}{60}} \newlabel{95@xvr}{{}{60}} \newlabel{95@vr}{{}{60}} \newlabel{96@xvr}{{}{60}} \newlabel{96@vr}{{}{60}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.2.5}The dip switches}{60}} \newlabel{97@xvr}{{}{60}} \newlabel{97@vr}{{}{60}} \citation{moto68230} \citation{moto68230} \citation{moto68230} \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''.}}{61}} \newlabel{fig:sevenseg}{{3.2}{61}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.2.6}Register addresses in the 68230 \acro {PI\Slash {}{}T}\xspace on the \acro {FLIGHT-68K}\xspace }{61}} \newlabel{98@xvr}{{}{61}} \newlabel{98@vr}{{}{61}} \@writefile{toc}{\contentsline {paragraph}{The \acro {PI\Slash {}{}T}\xspace has many modes:}{61}} \newlabel{sec:submode1x}{{3.2.6}{61}} \@writefile{toc}{\contentsline {paragraph}{Submode 1X}{61}} \@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.}}{62}} \newlabel{tab:registerAddr}{{3.2}{62}} \citation{moto68230} \newlabel{100@xvr}{{}{63}} \newlabel{100@vr}{{}{63}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.2.7}Initialising the \acro {PI\Slash {}{}T}\xspace for bit \IO }{63}} \newlabel{sec:initPitForBitIO}{{3.2.7}{63}} \newlabel{101@xvr}{{}{63}} \newlabel{101@vr}{{}{63}} \@writefile{toc}{\contentsline {paragraph}{What does it all mean?}{63}} \newlabel{102@xvr}{{}{63}} \newlabel{102@vr}{{}{63}} \newlabel{99@xvr}{{}{63}} \newlabel{99@vr}{{}{63}} \@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 {PBCR}}) to put these ports into submode\nobreakspace {}1X.}}{64}} \newlabel{tab:submode1x}{{3.3}{64}} \@writefile{toc}{\contentsline {subsubsection}{Choosing inputs and outputs: the data direction registers}{64}} \newlabel{sec:ddr}{{3.2.7}{64}} \@writefile{toc}{\contentsline {subsubsection}{Initialising the \acro {PI\Slash {}{}T}\xspace for bit \IO : a summary}{65}} \newlabel{103@xvr}{{}{65}} \newlabel{103@vr}{{}{65}} \newlabel{104@xvr}{{}{65}} \newlabel{104@vr}{{}{65}} \newlabel{105@xvr}{{}{65}} \newlabel{105@vr}{{}{65}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.2.8}How the interface card is connected to the parallel chip}{65}} \@writefile{lof}{\contentsline {figure}{\numberline {3.3}{\ignorespaces The two settings for the jumper on the interface board}}{65}} \newlabel{fig:jump}{{3.3}{65}} \@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.}}{66}} \newlabel{prg:startupCode}{{3.1}{66}} \newlabel{106@xvr}{{}{66}} \newlabel{106@vr}{{}{66}} \@writefile{toc}{\contentsline {section}{\numberline {3.3}The keypad}{67}} \newlabel{sec:keypad}{{3.3}{67}} \@writefile{lof}{\contentsline {figure}{\numberline {3.4}{\ignorespaces The connection of the keypad to the 68230 parallel interface/\penalty \z@ {}timer chip}}{67}} \newlabel{fig:keypad}{{3.4}{67}} \newlabel{107@xvr}{{}{67}} \newlabel{107@vr}{{}{67}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.3.1}Scanning the keypad}{68}} \@writefile{toc}{\contentsline {subsubsection}{The method}{68}} \newlabel{sec:readKeyExplain}{{3.3.1}{68}} \newlabel{108@xvr}{{}{68}} \newlabel{108@vr}{{}{68}} \newlabel{pag:readkey}{{3.3.1}{69}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.3.2}Debouncing the keys}{70}} \newlabel{sec:debouncing}{{3.3.2}{70}} \newlabel{109@xvr}{{}{70}} \newlabel{109@vr}{{}{70}} \@writefile{toc}{\contentsline {subsection}{\numberline {3.3.3}How to detect if any key has been pressed}{70}} \newlabel{sec:keyPressed}{{3.3.3}{70}} \newlabel{qes:rowtest}{{3.5}{71}} \@writefile{toc}{\contentsline {chapter}{\numberline {A}The operators in C and their precedence}{72}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \newlabel{sec:operators}{{A}{72}} \newlabel{110@xvr}{{}{72}} \newlabel{110@vr}{{}{72}} \@writefile{toc}{\contentsline {section}{\numberline {A.1}Operator precedence}{72}} \newlabel{111@xvr}{{}{73}} \newlabel{111@vr}{{}{73}} \@writefile{lop}{\contentsline {program}{\numberline {A.1}{\ignorespaces Multiple assignment.}}{73}} \newlabel{prg:assignment}{{A.1}{73}} \newlabel{112@xvr}{{}{73}} \newlabel{112@vr}{{}{73}} \@writefile{lot}{\contentsline {table}{\numberline {A.1}{\ignorespaces A list of all operators provided in the C programming language, showing level of precedence.}}{74}} \newlabel{tab:operatorPrecedence}{{A.1}{74}} \@writefile{toc}{\contentsline {chapter}{\numberline {B}The \acro {ASCII}\xspace code for representing characters}{76}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \newlabel{sec:ascii}{{B}{76}} \newlabel{113@xvr}{{}{76}} \newlabel{113@vr}{{}{76}} \@writefile{lot}{\contentsline {table}{\numberline {B.1}{\ignorespaces The \acro {ASCII}\xspace table}}{77}} \newlabel{tab:ascii}{{B.1}{77}} \@writefile{toc}{\contentsline {chapter}{\numberline {C}The memory map of the 68000 system in the laboratory}{78}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \newlabel{114@xvr}{{}{78}} \newlabel{114@vr}{{}{78}} \newlabel{115@xvr}{{}{78}} \newlabel{115@vr}{{}{78}} \newlabel{116@xvr}{{}{78}} \newlabel{116@vr}{{}{78}} \@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}$.}}{79}} \newlabel{fig:memmap}{{C.1}{79}} \@writefile{toc}{\contentsline {chapter}{\numberline {D}The compile, assemble and link process}{80}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \newlabel{sec:compiler}{{D}{80}} \newlabel{117@xvr}{{}{80}} \newlabel{117@vr}{{}{80}} \newlabel{118@xvr}{{}{80}} \newlabel{118@vr}{{}{80}} \newlabel{119@xvr}{{}{80}} \newlabel{119@vr}{{}{80}} \@writefile{toc}{\contentsline {section}{\numberline {D.1}The preprocessor}{80}} \newlabel{sec:preprocessor}{{D.1}{80}} \newlabel{120@xvr}{{}{80}} \newlabel{120@vr}{{}{80}} \@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.}}{81}} \newlabel{fig:compiler}{{D.1}{81}} \@writefile{toc}{\contentsline {section}{\numberline {D.2}The translator (or the main part of the C compiler)}{82}} \@writefile{toc}{\contentsline {section}{\numberline {D.3}The listing file and the map file}{82}} \@writefile{toc}{\contentsline {section}{\numberline {D.4}The assembler}{82}} \@writefile{toc}{\contentsline {section}{\numberline {D.5}Relocatable object file}{83}} \@writefile{toc}{\contentsline {section}{\numberline {D.6}The linker}{83}} \@writefile{toc}{\contentsline {subsection}{\numberline {D.6.1}The startup code}{83}} \newlabel{sec:startupCode}{{D.6.1}{83}} \newlabel{121@xvr}{{}{83}} \newlabel{121@vr}{{}{83}} \newlabel{122@xvr}{{}{83}} \newlabel{122@vr}{{}{83}} \@writefile{toc}{\contentsline {section}{\numberline {D.7}The library}{84}} \newlabel{sec:library}{{D.7}{84}} \newlabel{123@xvr}{{}{84}} \newlabel{123@vr}{{}{84}} \newlabel{124@xvr}{{}{84}} \newlabel{124@vr}{{}{84}} \@writefile{toc}{\contentsline {subsection}{\numberline {D.7.1}The file \texttt {flight.h}}{84}} \newlabel{sec:flight.h}{{D.7.1}{84}} \newlabel{125@xvr}{{}{84}} \newlabel{125@vr}{{}{84}} \@writefile{toc}{\contentsline {subsection}{\numberline {D.7.2}The library function \ensuremath {\@mathvf {DelayMs}}\textsf {\textmd {\textup {()}}}}{84}} \newlabel{sec:delayMs}{{D.7.2}{84}} \newlabel{126@xvr}{{}{85}} \newlabel{126@vr}{{}{85}} \@writefile{lop}{\contentsline {program}{\numberline {D.1}{\ignorespaces A definition of \ensuremath {\@mathvf {DelayMs}}\textsf {\textmd {\textup {()}}}.}}{85}} \newlabel{prg:delayMs}{{D.1}{85}} \@writefile{toc}{\contentsline {subsection}{\numberline {D.7.3}The library function \ensuremath {\@mathvf {kbhit}}\textsf {\textmd {\textup {()}}}}{85}} \newlabel{sec:kbhit}{{D.7.3}{85}} \newlabel{127@xvr}{{}{85}} \newlabel{127@vr}{{}{85}} \newlabel{128@xvr}{{}{85}} \newlabel{128@vr}{{}{85}} \citation{flight} \citation{nickAsm} \citation{flight} \newlabel{129@xvr}{{}{86}} \newlabel{129@vr}{{}{86}} \newlabel{130@xvr}{{}{86}} \newlabel{130@vr}{{}{86}} \@writefile{lop}{\contentsline {program}{\numberline {D.2}{\ignorespaces The assembly language implementation of \ensuremath {\@mathvf {kbhit}}\textsf {\textmd {\textup {()}}}.}}{86}} \newlabel{prg:kbhit}{{D.2}{86}} \@writefile{toc}{\contentsline {subsection}{\numberline {D.7.4}The library function \ensuremath {\@mathvf {getch}}\textsf {\textmd {\textup {()}}}}{86}} \newlabel{sec:getch}{{D.7.4}{86}} \newlabel{131@xvr}{{}{86}} \newlabel{131@vr}{{}{86}} \@writefile{lop}{\contentsline {program}{\numberline {D.3}{\ignorespaces The implementation of the library function \ensuremath {\@mathvf {getch}}\textsf {\textmd {\textup {()}}}.}}{87}} \newlabel{prg:getch}{{D.3}{87}} \@writefile{toc}{\contentsline {subsection}{\numberline {D.7.5}The library function \ensuremath {\@mathvf {WriteSevenSegment}}\textsf {\textmd {\textup {()}}}}{87}} \newlabel{sec:writeSevenSegment}{{D.7.5}{87}} \newlabel{132@xvr}{{}{87}} \newlabel{132@vr}{{}{87}} \@writefile{toc}{\contentsline {subsection}{\numberline {D.7.6}The library function \ensuremath {\@mathvf {ReadKey}}\textsf {\textmd {\textup {()}}}}{87}} \newlabel{133@xvr}{{}{87}} \newlabel{133@vr}{{}{87}} \newlabel{134@xvr}{{}{87}} \newlabel{134@vr}{{}{87}} \newlabel{135@xvr}{{}{87}} \newlabel{135@vr}{{}{87}} \@writefile{lop}{\contentsline {program}{\numberline {D.4}{\ignorespaces The library function \ensuremath {\@mathvf {WriteSevenSegment}}\textsf {\textmd {\textup {()}}}.}}{88}} \newlabel{prg:sevseg}{{D.4}{88}} \@writefile{lot}{\contentsline {table}{\numberline {D.1}{\ignorespaces The return values of the library function \ensuremath {\@mathvf {ReadKey}}\textsf {\textmd {\textup {()}}}.}}{88}} \newlabel{tab:readKeyRetVal}{{D.1}{88}} \@writefile{toc}{\contentsline {section}{\numberline {D.8}The \textsf {make} program}{88}} \newlabel{136@xvr}{{}{89}} \newlabel{136@vr}{{}{89}} \@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}.}}{89}} \newlabel{prg:readkey}{{D.5}{89}} \@writefile{toc}{\contentsline {chapter}{\numberline {E}Why C and not assembly language?}{90}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \newlabel{sec:ansi}{{E}{90}} \citation{drDobbs} \citation{stevens} \@writefile{toc}{\contentsline {chapter}{\numberline {F}The \textsf {Quincy}\xspace interpreter---get it and use it!}{92}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \newlabel{sec:qc}{{F}{92}} \@writefile{toc}{\contentsline {section}{\numberline {F.1}What is \textsf {Quincy}\xspace ?}{92}} \@writefile{toc}{\contentsline {subsection}{\numberline {F.1.1}What is an interpreter?}{92}} \@writefile{toc}{\contentsline {subsection}{\numberline {F.1.2}What can I do with \textsf {Quincy}\xspace ?}{93}} \@writefile{toc}{\contentsline {section}{\numberline {F.2}How to get a copy of \textsf {Quincy}\xspace }{93}} \newlabel{sec:howCopyQc}{{F.2}{93}} \@writefile{toc}{\contentsline {chapter}{\numberline {G}Compiler errors: they are there to help you}{95}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \newlabel{sec:errors}{{G}{95}} \@writefile{toc}{\contentsline {section}{\numberline {G.1}What do I do if there are lots of error messages?}{95}} \@writefile{toc}{\contentsline {section}{\numberline {G.2}Error messages from different parts of the compiler}{96}} \newlabel{137@xvr}{{}{96}} \newlabel{137@vr}{{}{96}} \newlabel{138@xvr}{{}{96}} \newlabel{138@vr}{{}{96}} \@writefile{toc}{\contentsline {subsection}{\numberline {G.2.1}Error messages from the preprocessor}{96}} \@writefile{toc}{\contentsline {subsection}{\numberline {G.2.2}Error messages from the main part of the compiler}{97}} \newlabel{pag:testc}{{G.2.2}{97}} \newlabel{139@xvr}{{}{98}} \newlabel{139@vr}{{}{98}} \@writefile{toc}{\contentsline {subsection}{\numberline {G.2.3}Error messages from the linker}{98}} \newlabel{140@xvr}{{}{99}} \newlabel{140@vr}{{}{99}} \@writefile{toc}{\contentsline {subsection}{\numberline {G.2.4}The ``my computer looks sick!'' error message}{99}} \newlabel{sec:sickComputerError}{{G.2.4}{99}} \@writefile{toc}{\contentsline {chapter}{\numberline {H}Editing, compiling, downloading and running a program}{101}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \newlabel{sec:ecdr}{{H}{101}} \@writefile{toc}{\contentsline {section}{\numberline {H.1}The program design}{101}} \@writefile{toc}{\contentsline {section}{\numberline {H.2}The general procedure for editing, compiling, downloading and running a program}{101}} \newlabel{141@xvr}{{}{102}} \newlabel{141@vr}{{}{102}} \@writefile{toc}{\contentsline {section}{\numberline {H.3}Editing the program}{102}} \newlabel{142@xvr}{{}{102}} \newlabel{142@vr}{{}{102}} \@writefile{lop}{\contentsline {program}{\numberline {H.1}{\ignorespaces Most of your programs will have a form similar to this.}}{103}} \newlabel{prg:progTemplate}{{H.1}{103}} \newlabel{143@xvr}{{}{103}} \newlabel{143@vr}{{}{103}} \newlabel{pag:badNullStatement}{{2}{103}} \newlabel{144@xvr}{{}{103}} \newlabel{144@vr}{{}{103}} \@writefile{toc}{\contentsline {section}{\numberline {H.4}Compiling your program}{104}} \newlabel{145@xvr}{{}{104}} \newlabel{145@vr}{{}{104}} \@writefile{toc}{\contentsline {section}{\numberline {H.5}Downloading the program}{104}} \newlabel{pag:monitor}{{3}{105}} \@writefile{toc}{\contentsline {section}{\numberline {H.6}Running the program}{105}} \@writefile{toc}{\contentsline {chapter}{\numberline {I}Solutions to exercises}{106}} \@writefile{lof}{\addvspace {10\p@ }} \@writefile{lot}{\addvspace {10\p@ }} \newlabel{sec:solutions}{{I}{106}} \newlabel{146@xvr}{{}{109}} \newlabel{146@vr}{{}{109}} \newlabel{soln:precedenceExample}{{g}{109}} \newlabel{147@xvr}{{}{112}} \newlabel{147@vr}{{}{112}} \newlabel{148@xvr}{{}{112}} \newlabel{148@vr}{{}{112}} \newlabel{149@xvr}{{}{113}} \newlabel{149@vr}{{}{113}} \newlabel{150@xvr}{{}{115}} \newlabel{150@vr}{{}{115}} \newlabel{151@xvr}{{}{116}} \newlabel{151@vr}{{}{116}} \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}{119}} \newlabel{sec:references}{{I}{119}} \bibcite{nickAsm}{Urb96} \@writefile{toc}{\contentsline {chapter}{Index}{121}} \newlabel{LastPage}{{}{126}}