\contentsline {program}{\numberline {2.1}{\ignorespaces Definitions of integral-type variables.}}{10} \contentsline {program}{\numberline {2.2}{\ignorespaces An example showing use of \ensuremath {\@mathvf {printf}}\textsf {\textmd {\textup {()}}}.}}{12} \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} \contentsline {program}{\numberline {2.4}{\ignorespaces A program that uses \ensuremath {\@mathvf {printf}}\textsf {\textmd {\textup {()}}} to display integers.}}{18} \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} \contentsline {program}{\numberline {2.6}{\ignorespaces Some examples of expressions.}}{19} \contentsline {program}{\numberline {2.7}{\ignorespaces This program demonstrates the compound assignment operators.}}{22} \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} \contentsline {program}{\numberline {2.9}{\ignorespaces This program shows the use of the bitwise\nobreakspace {}OR operator, `\textsf {\textmd {\textup {$\@mathsf {|}$}}}'.}}{28} \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} \contentsline {program}{\numberline {2.11}{\ignorespaces examples of valid statements in C.}}{31} \contentsline {program}{\numberline {2.12}{\ignorespaces A program that uses an \textsf {\textbf {\textup {if}}} statement and the modulus operator, `\textsf {\textmd {\textup {\%}}}'.}}{33} \contentsline {program}{\numberline {2.13}{\ignorespaces A program using \textsf {\textbf {\textup {while}}}.}}{35} \contentsline {program}{\numberline {2.14}{\ignorespaces A program equivalent to \vref {prg:while}, except that it uses a \textsf {\textbf {\textup {for}}} loop.}}{37} \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} \contentsline {program}{\numberline {2.16}{\ignorespaces A program using two nested \textsf {\textbf {\textup {for}}} loops.}}{39} \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} \contentsline {program}{\numberline {2.18}{\ignorespaces Using the \textsf {\textbf {\textup {break}}} statement.}}{41} \contentsline {program}{\numberline {2.19}{\ignorespaces A program demonstrating the \textsf {\textbf {\textup {continue}}} statement.}}{42} \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} \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} \contentsline {program}{\numberline {2.22}{\ignorespaces A program that shows parameters begin passed to a function.}}{48} \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} \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} \contentsline {program}{\numberline {D.1}{\ignorespaces A definition of \ensuremath {\@mathvf {DelayMs}}\textsf {\textmd {\textup {()}}}.}}{86} \contentsline {program}{\numberline {D.2}{\ignorespaces The assembly language implementation of \ensuremath {\@mathvf {kbhit}}\textsf {\textmd {\textup {()}}}.}}{88} \contentsline {program}{\numberline {D.3}{\ignorespaces The implementation of the library function \ensuremath {\@mathvf {getch}}\textsf {\textmd {\textup {()}}}.}}{88} \contentsline {program}{\numberline {D.4}{\ignorespaces The library function \ensuremath {\@mathvf {WriteSevenSegment}}\textsf {\textmd {\textup {()}}}.}}{89} \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} \contentsline {program}{\numberline {H.1}{\ignorespaces All your programs will have a form similar to this.}}{104}