diff --git a/20230530/io-ports-and-interrupts.pdf b/20230530/io-ports-and-interrupts.pdf
new file mode 120000
index 0000000000000000000000000000000000000000..bcd46f7afb35605b20bdb05637e6de0a039893ec
--- /dev/null
+++ b/20230530/io-ports-and-interrupts.pdf
@@ -0,0 +1 @@
+../common/io-ports-and-interrupts.pdf
\ No newline at end of file
diff --git a/20230530/logo-hochschule-bochum-cvh-text-v2.pdf b/20230530/logo-hochschule-bochum-cvh-text-v2.pdf
new file mode 120000
index 0000000000000000000000000000000000000000..4aa99b8f81061aca6dcaf43eed2d9efef40555f8
--- /dev/null
+++ b/20230530/logo-hochschule-bochum-cvh-text-v2.pdf
@@ -0,0 +1 @@
+../common/logo-hochschule-bochum-cvh-text-v2.pdf
\ No newline at end of file
diff --git a/20230530/logo-hochschule-bochum.pdf b/20230530/logo-hochschule-bochum.pdf
new file mode 120000
index 0000000000000000000000000000000000000000..b6b9491e370e499c9276918182cdb82cb311bcd1
--- /dev/null
+++ b/20230530/logo-hochschule-bochum.pdf
@@ -0,0 +1 @@
+../common/logo-hochschule-bochum.pdf
\ No newline at end of file
diff --git a/20230530/morse-00.c b/20230530/morse-00.c
new file mode 100644
index 0000000000000000000000000000000000000000..69ff94def65c14d76c6829d8d1a31aaeda41ef6c
--- /dev/null
+++ b/20230530/morse-00.c
@@ -0,0 +1,44 @@
+https://stackoverflow.com/questions/28045172/morse-code-converter-in-c
+
+
+static const char *alpha[] = {
+    ".-",   //A
+    "-...", //B
+    "-.-.", //C
+    "-..",  //D
+    ".",    //E
+    "..-.", //F
+    "--.",  //G
+    "....", //H
+    "..",   //I
+    ".---", //J
+    "-.-",  //K
+    ".-..", //L
+    "--",   //M
+    "-.",   //N
+    "---",  //O
+    ".--.", //P
+    "--.-", //Q
+    ".-.",  //R
+    "...",  //S
+    "-",    //T
+    "..-",  //U
+    "...-", //V
+    ".--",  //W
+    "-..-", //X
+    "-.--", //Y
+    "--..", //Z
+};
+static const char *num[] = {
+    "-----", //0
+    ".----", //1
+    "..---", //2
+    "...--", //3
+    "....-", //4
+    ".....", //5
+    "-....", //6
+    "--...", //7
+    "---..", //8
+    "----.", //9
+};
+static const char **table[] = { alpha, num };
diff --git a/20230530/morse-01.c b/20230530/morse-01.c
new file mode 100644
index 0000000000000000000000000000000000000000..249bdd9ea4f18cf073182bed7d4a4965e94fd2a0
--- /dev/null
+++ b/20230530/morse-01.c
@@ -0,0 +1,64 @@
+static const char *morse[256] = {
+  ['0'] = "-----",
+  ['1'] = ".----",
+  ['2'] = "..---",
+  ['3'] = "...--",
+  ['4'] = "....-",
+  ['5'] = ".....",
+  ['6'] = "-....",
+  ['7'] = "--...",
+  ['8'] = "---..",
+  ['9'] = "----.",
+  ['A'] = ".-",
+  ['B'] = "-...",
+  ['C'] = "-.-.",
+  ['D'] = "-..",
+  ['E'] = ".",
+  ['F'] = "..-.",
+  ['G'] = "--.",
+  ['H'] = "....",
+  ['I'] = "..",
+  ['J'] = ".---",
+  ['K'] = "-.-",
+  ['L'] = ".-..",
+  ['M'] = "--",
+  ['N'] = "-.",
+  ['O'] = "---",
+  ['P'] = ".--.",
+  ['Q'] = "--.-",
+  ['R'] = ".-.",
+  ['S'] = "...",
+  ['T'] = "-",
+  ['U'] = "..-",
+  ['V'] = "...-",
+  ['W'] = ".--",
+  ['X'] = "-..-",
+  ['Y'] = "-.--",
+  ['Z'] = "--..",
+  ['a'] = ".-",
+  ['b'] = "-...",
+  ['c'] = "-.-.",
+  ['d'] = "-..",
+  ['e'] = ".",
+  ['f'] = "..-.",
+  ['g'] = "--.",
+  ['h'] = "....",
+  ['i'] = "..",
+  ['j'] = ".---",
+  ['k'] = "-.-",
+  ['l'] = ".-..",
+  ['m'] = "--",
+  ['n'] = "-.",
+  ['o'] = "---",
+  ['p'] = ".--.",
+  ['q'] = "--.-",
+  ['r'] = ".-.",
+  ['s'] = "...",
+  ['t'] = "-",
+  ['u'] = "..-",
+  ['v'] = "...-",
+  ['w'] = ".--",
+  ['x'] = "-..-",
+  ['y'] = "-.--",
+  ['z'] = "--.."
+};
diff --git a/20230530/pgslides.sty b/20230530/pgslides.sty
new file mode 120000
index 0000000000000000000000000000000000000000..5be1416f4216f076aa268901f52a15d775e43f64
--- /dev/null
+++ b/20230530/pgslides.sty
@@ -0,0 +1 @@
+../common/pgslides.sty
\ No newline at end of file
diff --git a/20230530/rtech-20230530.pdf b/20230530/rtech-20230530.pdf
new file mode 100644
index 0000000000000000000000000000000000000000..7a44f13a36f83d09295d0108dbd61730746d53ce
Binary files /dev/null and b/20230530/rtech-20230530.pdf differ
diff --git a/20230530/rtech-20230530.tex b/20230530/rtech-20230530.tex
new file mode 100644
index 0000000000000000000000000000000000000000..5fa1dc9e7d551a195c01fddebef2d39d1c5f1f08
--- /dev/null
+++ b/20230530/rtech-20230530.tex
@@ -0,0 +1,1004 @@
+% rtech-20230530.pdf - Lecture Slides on Computer Technology
+% Copyright (C) 2012, 2013, 2014, 2021, 2022, 2023  Peter Gerwinski
+%
+% This document is free software: you can redistribute it and/or
+% modify it either under the terms of the Creative Commons
+% Attribution-ShareAlike 3.0 License, or under the terms of the
+% GNU General Public License as published by the Free Software
+% Foundation, either version 3 of the License, or (at your option)
+% any later version.
+%
+% This document is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+% GNU General Public License for more details.
+%
+% You should have received a copy of the GNU General Public License
+% along with this document.  If not, see <http://www.gnu.org/licenses/>.
+%
+% You should have received a copy of the Creative Commons
+% Attribution-ShareAlike 3.0 Unported License along with this
+% document.  If not, see <http://creativecommons.org/licenses/>.
+
+% README: Hardwarenahe Programmierung: I/O, Endianness, Alignment
+
+\documentclass[10pt,t]{beamer}
+
+\usepackage{pgslides}
+\usepackage{pdftricks}
+%\usepackage[obeyfamily=false,mathrm=mathsf,textrm=sffamily]{siunitx}
+%\usepackage{eurosym}
+\usepackage{tikz}
+
+\newcommand{\Cin}{C\raisebox{-0.5ex}{\footnotesize in}}
+\newcommand{\Cout}{C\raisebox{-0.5ex}{\footnotesize out}}
+
+\lstdefinestyle{asm}{basicstyle=\color{structure},
+                     language={},
+                     gobble=4}
+
+\begin{psinputs}
+  \usepackage[utf8]{inputenc}
+  \usepackage[german]{babel}
+  \usepackage[T1]{fontenc}
+  \usepackage{helvet}
+  \renewcommand*\familydefault{\sfdefault}
+  \usepackage{pstricks,pst-grad,pst-circ-pg}
+  \newcommand{\invisible}{\tiny\color{white}}
+  \psset{unit=1cm}
+  \psset{logicLabelstyle=\invisible}
+  \newcommand{\logicSymbol}{\small\boldmath\bf\rule{0pt}{0.5cm}}
+  \psset{logicSymbolstyle=\logicSymbol}
+  \newcommand{\Cin}{C\raisebox{-0.5ex}{\footnotesize in}}
+  \newcommand{\Cout}{C\raisebox{-0.5ex}{\footnotesize out}}
+\end{psinputs}
+
+\title{Rechnertechnik}
+\author{Prof.\ Dr.\ rer.\ nat.\ Peter Gerwinski}
+\date{30.\ Mai 2022}
+
+\begin{document}
+
+\maketitleframe
+
+\nosectionnonumber{\inserttitle}
+
+\begin{frame}
+
+  \shownosectionnonumber
+
+  \begin{itemize}
+    \item[\textbf{1}] \textbf{Einführung}
+    \item[\textbf{2}] \textbf{Vom Schaltkreis zum Computer}
+    \item[\textbf{3}] \textbf{Assember-Programmierung}
+      \begin{itemize}
+        \item[3.1] Struktur von Assembler-Programmen
+        \item[3.2] Beispiel: Redcode
+        \item[3.3] Architekturmerkmale von Prozessore
+        \item[3.4] Der CPU-Stack
+        \color{medgreen}
+        \item[3.5] Computer-Sprachen
+      \end{itemize}
+%    \color{gray}
+    \item[\textbf{4}] \textbf{Hardwarenahe Programmierung}
+      \begin{itemize}
+        \color{orange}
+        \item[4.1] Bit-Operationen
+        \color{red}
+        \item[4.1] I/O-Ports
+        \item[4.1] Interrupts
+        \item[4.1] volatile-Variable
+        \item[4.1] Byte-Reihenfolge -- Endianness
+        \item[4.1] Speicherausrichtung -- Alignment
+      \end{itemize}
+%    \item[\textbf{6}] \textbf{Anwender-Software}
+%    \item[\textbf{7}] \textbf{Bus-Systeme}
+%    \item[\textbf{8}] \textbf{Pipelining}
+%    \item[\textbf{9}] \textbf{Ausblick}
+    \item[\textbf{\dots\hspace{-0.75em}}]
+  \end{itemize}
+
+\end{frame}
+
+\setcounter{section}{2}
+\section{Assembler-Programmierung}
+\setcounter{subsection}{4}
+\subsection{Computer-Sprachen}
+\subsubsection{Maschinensprache}
+
+\begin{frame}
+
+  \showsubsection
+  \showsubsubsection
+
+  \begin{itemize}
+    \item
+      Lade- und Speicher-Befehle\\
+      arithmetische Befehle\\
+      unbedingte und bedingte Sprungbefehle
+    \arrowitem
+      Der Computer kann "`alles"' -- \newterm{Turing-Vollständigkeit}
+    \bigskip
+    \item
+      Maschinensprache = Zahlen \textarrow\ für Menschen schwer handhabbar
+    \arrowitem
+      Namen für die Befehle: \newterm{Mnemonics}
+    \arrowitem
+      \newterm{Assembler\/}-Sprache
+  \end{itemize}
+
+\end{frame}
+
+\subsubsection{\strut{\protect\color{gray}Maschinensprache \protect\textarrow\ }Assembler}
+
+\begin{frame}[fragile]
+
+  \showsubsubsection
+
+  Beispiel: Intel-x86-16-Bit-Assembler
+
+  \begin{itemize}
+    \item
+      Lade- und Speicher-Befehle\hfill
+        \lstinline{mov}, \dots\\
+      arithmetische Befehle\hfill
+        \lstinline{add}, \lstinline{sub}, \lstinline{inc}, \lstinline{dec},
+        \lstinline{xor}, \lstinline{cmp}, \dots\\
+      unbedingte und bedingte Sprungbefehle\hfill
+        \lstinline{jmp}, \lstinline{jz}, \lstinline{jae}, \dots
+    \item
+      Register\hfill
+        \lstinline{ax}, \lstinline{bx}, \dots
+  \end{itemize}
+
+%  \begin{onlyenv}<1>
+%    \begin{center}
+%%      \includegraphics[width=10cm]{programm-screenshot.png}
+%      \vspace*{-0.5cm}
+%    \end{center}
+%  \end{onlyenv}
+%  \begin{onlyenv}<2->
+
+    \bigskip
+
+    Beispiel: Atmel-AVR-8-Bit-Assembler
+
+    \begin{itemize}
+      \item
+        Lade- und Speicher-Befehle\hfill
+          \lstinline{ldi}, \lstinline{lds}, \lstinline{sti}, \dots\\
+        arithmetische Befehle\hfill
+          \lstinline{add}, \lstinline{sub}, \lstinline{subi},
+          \lstinline{eor}, \lstinline{cp}, \dots\\
+        unbedingte und bedingte Sprungbefehle\hfill
+          \lstinline{rjmp}, \lstinline{brsh}, \lstinline{brlo}, \dots
+      \item
+        Register\hfill
+          \lstinline{r0}, \lstinline{r1}, \dots
+    \end{itemize}
+
+    \bigskip
+
+    \textarrow\ für jeden Prozessor anders
+
+%  \end{onlyenv}
+
+\end{frame}
+
+\subsubsection{\strut{\protect\color{gray}Maschinensprache \protect\textarrow\ Assembler \protect\textarrow\ }Hochsprachen}
+
+\begin{frame}[fragile]
+
+  \showsubsubsection
+
+  Beispiel: Intel-x86-16-Bit-Assembler
+
+  \begin{itemize}
+    \item
+      Lade- und Speicher-Befehle\hfill
+        \lstinline{mov}, \dots\\
+      arithmetische Befehle\hfill
+        \lstinline{add}, \lstinline{sub}, \lstinline{inc}, \lstinline{dec},
+        \lstinline{xor}, \lstinline{cmp}, \dots\\
+      unbedingte und bedingte Sprungbefehle\hfill
+        \lstinline{jmp}, \lstinline{jz}, \lstinline{jae}, \dots
+    \item
+      Register\hfill
+        \lstinline{ax}, \lstinline{bx}, \dots
+  \end{itemize}
+
+  \bigskip
+
+  Beispiel: Atmel-AVR-8-Bit-Assembler
+
+  \begin{itemize}
+    \item
+      Lade- und Speicher-Befehle\hfill
+        \lstinline{ldi}, \lstinline{lds}, \lstinline{sti}, \dots\\
+      arithmetische Befehle\hfill
+        \lstinline{add}, \lstinline{sub}, \lstinline{subi},
+        \lstinline{eor}, \lstinline{cp}, \dots\\
+      unbedingte und bedingte Sprungbefehle\hfill
+        \lstinline{rjmp}, \lstinline{brsh}, \lstinline{brlo}, \dots
+    \item
+      Register\hfill
+        \lstinline{r0}, \lstinline{r1}, \dots
+  \end{itemize}
+
+  \bigskip
+
+  \textarrow\ für jeden Prozessor anders
+
+  \bigskip
+
+  Hochsprache \textarrow\ für jeden Prozessor gleich
+
+\end{frame}
+
+\begin{frame}[fragile]
+
+  \showsubsubsection
+
+  Compiler-Sprachen
+  \begin{itemize}
+    \item
+      \newterm{Compiler\/} übersetzt Hochsprachen-\newterm{Quelltext\/} in die Assembler-Sprache
+    \item
+      \newterm{Assembler\/} übersetzt Assembler-Quelltext in die Maschinensprache
+    \item
+      Compiler und Assembler sind Programme,\\
+      geschrieben in Maschinensprache, Assembler oder einer Hochsprache
+    \item
+      Beispiele: Fortran, Algol, Pascal, Ada, C, C++, \dots
+  \end{itemize}
+
+  \pause
+  \medskip
+  Interpreter- oder Skript-Sprachen
+  \begin{itemize}
+    \item
+      \newterm{Interpreter\/} liest Hochsprachen-\newterm{Quelltext\/} und führt ihn sofort aus
+    \item
+      Der Interpreter ist ein Programm,\\
+      geschrieben in Maschinensprache, Assembler oder einer Hochsprache
+    \item
+      Beispiele: Unix-Shell, BASIC, Perl, Python, \dots
+  \end{itemize}
+
+  \pause
+  \medskip
+  Kombinationen
+  \begin{itemize}
+    \item
+      \newterm{Compiler\/} erzeugt \newterm{Zwischencode\/} für eine \newterm{virtuelle Maschine}
+    \item
+      \newterm{Interpreter\/} liest Hochsprachen-\newterm{Zwischencode\/} und führt ihn sofort aus
+    \item
+      Die virtuelle Maschine ist ein Programm,
+      geschrieben in Maschinensprache, Assembler, einer Hoch- oder Skript-Sprache
+    \item
+      Beispiele: UCSD-Pascal, Java, \dots
+  \end{itemize}
+  \medskip
+
+\end{frame}
+
+\section{Hardwarenahe Programmierung}
+\subsection{Bit-Operationen}
+\subsubsection{Zahlensysteme}
+
+\begin{frame}[fragile]
+
+  \showsection
+  \vspace*{-\smallskipamount}
+  \showsubsection
+  \vspace*{-\medskipamount}
+  \showsubsubsection
+
+  \begin{tabular}{rlrl}
+    Basis & Name & Beispiel & Anwendung \\[\smallskipamount]
+      2 & Binärsystem & 1\,0000\,0011 & Bit-Operationen \\
+      8 & Oktalsystem & \lstinline,0403, & Dateizugriffsrechte (Unix) \\
+     10 & Dezimalsystem & \lstinline,259, & Alltag \\
+     16 & Hexadezimalsystem & \lstinline,0x103, & Bit-Operationen \\
+    256 & (keiner gebräuchlich) & 0.0.1.3 & IP-Adressen (IPv4)
+  \end{tabular}
+
+  \bigskip
+
+  \begin{itemize}
+    \item
+      Computer rechnen im Binärsystem.
+    \item
+      Für viele Anwendungen (z.\,B.\ I/O-Ports, Grafik, \dots) ist es notwendig,\\
+      Bits in Zahlen einzeln ansprechen zu können.
+  \end{itemize}
+
+\end{frame}
+
+\begin{frame}[fragile]
+
+  \showsubsubsection
+
+  \begin{tabular}{rlrlrc}
+    \qquad 000 & \bf 0 \hspace*{1.5cm} & 0000 & \bf 0 & \quad 1000 & \bf 8\\
+           001 & \bf 1                 & 0001 & \bf 1 &       1001 & \bf 9\\
+           010 & \bf 2                 & 0010 & \bf 2 &       1010 & \bf A\\
+           011 & \bf 3                 & 0011 & \bf 3 &       1011 & \bf B\\[\smallskipamount]
+           100 & \bf 4                 & 0100 & \bf 4 &       1100 & \bf C\\
+           101 & \bf 5                 & 0101 & \bf 5 &       1101 & \bf D\\
+           110 & \bf 6                 & 0110 & \bf 6 &       1110 & \bf E\\
+           111 & \bf 7                 & 0111 & \bf 7 &       1111 & \bf F\\
+  \end{tabular}
+
+  \medskip
+
+  \begin{itemize}
+    \item
+      Oktal- und Hexadezimalzahlen lassen sich ziffernweise\\
+      in Binär-Zahlen umrechnen.
+    \item
+      Hexadezimalzahlen sind eine Kurzschreibweise für Binärzahlen,\\
+      gruppiert zu jeweils 4 Bits.
+    \item
+      Oktalzahlen sind eine Kurzschreibweise für Binärzahlen,\\
+      gruppiert zu jeweils 3 Bits.
+    \item
+      Trotz Taschenrechner u.\,ä.\ lohnt es sich,\\
+      die o.\,a.\ Umrechnungstabelle \textbf{auswendig} zu kennen.
+  \end{itemize}
+
+\end{frame}
+
+\subsubsection{Bit-Operationen in Assembler}
+
+\begin{frame}[fragile]
+
+  \showsubsubsection
+
+  \begin{tabular}{lll}
+    Operation       & Verknüpfung              & Anwendung                \\[\smallskipamount]
+    \lstinline,and, & Und                      & Bits gezielt löschen     \\
+    \lstinline,or,  & Oder                     & Bits gezielt setzen      \\
+    \lstinline,eor, & Exklusiv-Oder            & Bits gezielt invertieren \\[\smallskipamount]
+    \lstinline,com, & Nicht (Einer-Komplement) & Alle Bits invertieren    \\[\smallskipamount]
+    \lstinline,lsl, & Verschiebung nach links  & Maske generieren         \\
+%    \lstinline,lsr, & Verschiebung nach rechts & Bits isolieren
+  \end{tabular}
+
+  \bigskip
+
+  Numerierung der Bits: von rechts ab 0
+
+  \medskip
+
+  \begin{tabular}{ll}
+    Bit Nr.\ 3 auf 1 setzen: &
+%    \lstinline,a |= 1 << 3;, \\
+    Oder-Verknüpfung mit einer\\&um 3 nach links geschobenen 1
+    \hfill\lstinline|0000|\,\lstinline|1000|\\[\smallskipamount]
+    Bit Nr.\ 4 auf 0 setzen: &
+%    \lstinline,a &= ~(1 << 4);, \\
+    Und-Verknüpfung mit dem Einer-Komplement \qquad\quad\strut\\&einer um 4 nach links geschobenen 1
+    \hfill\lstinline|1110|\,\lstinline|1111|\\[\smallskipamount]
+    Bit Nr.\ 0 invertieren: &
+%    \lstinline,a ^= 1 << 0;,
+    Exklusiv-Oder-Verknüpfung mit einer\\&um 0 nach links geschobenen 1
+    \hfill\lstinline|0000|\,\lstinline|0001|\\[\smallskipamount]
+    Ist Bit Nr.\ 1 eine Null? &
+    Ergibt eine Und-Verknüpfung mit einer um 1\\&nach links geschobenen 1 den Wert 0?
+    \hfill\lstinline|0000|\,\lstinline|0010|
+  \end{tabular}
+
+%  \smallskip
+%
+%  ~~Abfrage, ob Bit Nr.\ 1 gesetzt ist:\quad
+%  \lstinline{if (a & (1 << 1))}
+
+\end{frame}
+
+\iffalse
+
+\begin{frame}[fragile]
+
+  \showsubsubsection
+
+  C-Datentypen für Bit-Operationen:
+  \smallskip\par
+  \lstinline{#include <stdint.h>}
+  \medskip\par
+  \begin{tabular}{lllll}
+                    & 8 Bit & 16 Bit & 32 Bit & 64 Bit \\
+    mit Vorzeichen  & \lstinline,int8_t,
+                    & \lstinline,int16_t,
+                    & \lstinline,int32_t,
+                    & \lstinline,int64_t, \\
+    ohne Vorzeichen & \lstinline,uint8_t,
+                    & \lstinline,uint16_t,
+                    & \lstinline,uint32_t,
+                    & \lstinline,uint64_t,
+  \end{tabular}
+
+  \bigskip
+  \bigskip
+
+  Ausgabe:
+  \smallskip\par
+  \begin{lstlisting}
+    #include <stdio.h>
+    #include <stdint.h>
+    #include <inttypes.h>
+    ...
+    uint64_t x = 42;
+    printf ("Die Antwort lautet: %" PRIu64 "\n", x);
+  \end{lstlisting}
+
+\end{frame}
+
+\fi
+
+\subsection{I/O-Ports}
+
+\begin{frame}[fragile]
+
+%  \showsection
+  \showsubsection
+  \vspace*{-1.5\medskipamount}
+  {\large\textbf{\color{structure}4.3\quad Interrupts}}
+
+  \bigskip
+
+  Kommunikation mit externen Geräten
+
+  \bigskip
+
+  \begin{center}
+    \includegraphics{io-ports-and-interrupts.pdf}
+  \end{center}
+
+\end{frame}
+
+\begin{frame}[fragile]
+
+  \showsubsection
+
+  In Output-Port schreiben = Aktoren ansteuern
+
+  Beispiel: LED
+
+  \medskip
+
+  \begin{lstlisting}
+    #include <avr/io.h>
+    ...
+    DDRC = 0x70;
+    PORTC = 0x40;
+  \end{lstlisting}
+  \begin{picture}(0,0)
+    \put(3,0.67){\begin{minipage}{3cm}
+                \color{red}%
+                binär: 0111\,0000\\
+                binär: 0100\,0000
+              \end{minipage}}
+    \put(10,0.67){\makebox(0,0)[r]{\color{red}Herstellerspezifisch!}}
+  \end{picture}
+
+  \bigskip
+
+  \lstinline{DDR} = Data Direction Register\\
+  Bit = 1 für Output-Port\\
+  Bit = 0 für Input-Port
+
+  \bigskip
+
+  \emph{Details: siehe Datenblatt und Schaltplan}
+
+\end{frame}
+
+\begin{frame}[fragile]
+
+  \showsubsection
+
+  Aus Input-Port lesen = Sensoren abfragen
+
+  Beispiel: Taster
+
+  \medskip
+
+  \begin{lstlisting}
+    #include <avr/io.h>
+    ...
+    DDRC = 0xfd;
+    while ((PINC & 0x02) == 0)
+      ; /* just wait */
+  \end{lstlisting}
+  \begin{picture}(0,0)(-1.5,-0.42)
+    \put(3,0.67){\begin{minipage}{3cm}
+                \color{red}%
+                binär: 1111\,1101\\
+                binär: 0000\,0010
+              \end{minipage}}
+    \put(10,0.67){\makebox(0,0)[r]{\color{red}Herstellerspezifisch!}}
+  \end{picture}
+
+  \bigskip
+
+  \lstinline{DDR} = Data Direction Register\\
+  Bit = 1 für Output-Port\\
+  Bit = 0 für Input-Port
+
+  \bigskip
+
+  \emph{Details: siehe Datenblatt und Schaltplan}
+  
+  \bigskip
+
+  Praktikumsaufgabe: Druckknopfampel
+
+\end{frame}
+
+\subsection{Interrupts}
+
+\begin{frame}[fragile]
+
+  \showsubsection
+
+  Externes Gerät ruft (per Stromsignal) Unterprogramm auf
+
+  Zeiger hinterlegen: "`Interrupt-Vektor"'
+
+  Beispiel: eingebaute Uhr\hfill
+  \makebox(0,0)[tr]{%
+    \only<1->{\begin{minipage}[t]{4.7cm}
+        \vspace*{-0.3cm}%
+        statt Zählschleife (\lstinline{_delay_ms}):\\
+        Hauptprogramm kann\\
+        andere Dinge tun
+      \end{minipage}}%
+    }
+
+  \medskip
+
+  \begin{lstlisting}
+    #include <avr/interrupt.h>
+
+    ...
+
+
+    ISR (TIMER0B_COMP_vect)
+    {
+      PORTD ^= 0x40;
+    }
+  \end{lstlisting}
+  \begin{picture}(0,0)
+    \color{red}
+    \put(1.9,3.1){\makebox(0,0)[tr]{\tikz{\draw[-latex](0,0)--(-1.4,-1.0);}}}
+    \put(2.0,3.2){\makebox(0,0)[l]{"`Dies ist ein Interrupt-Handler."'}}
+    \put(2.3,2.6){\makebox(0,0)[tr]{\tikz{\draw[-latex](0,0)--(-0.6,-0.55);}}}
+    \put(2.4,2.6){\makebox(0,0)[l]{Interrupt-Vektor darauf zeigen lassen}}
+  \end{picture}
+
+  Initialisierung über spezielle Ports:
+  \lstinline{TCCR0B}, \lstinline{TIMSK0}
+
+  \bigskip
+
+  \emph{Details: siehe Datenblatt und Schaltplan}
+
+  \vspace*{-2.5cm}\hfill
+  {\color{red}Herstellerspezifisch!}%
+  \hspace*{1cm}
+
+\end{frame}
+
+\begin{frame}[fragile]
+
+  \showsubsection
+
+  Externes Gerät ruft (per Stromsignal) Unterprogramm auf
+
+  Zeiger hinterlegen: "`Interrupt-Vektor"'
+
+  Beispiel: Taster\hfill
+  \makebox(0,0)[tr]{%
+    \begin{minipage}[t]{4.7cm}
+      \vspace*{-0.3cm}%
+      statt \newterm{Busy Waiting\/}:\\
+      Hauptprogramm kann\\
+      andere Dinge tun
+    \end{minipage}}
+
+  \medskip
+
+  \begin{lstlisting}
+    #include <avr/interrupt.h>
+    ...
+
+    ISR (INT0_vect)
+    {
+      PORTD ^= 0x40;
+    }
+  \end{lstlisting}
+
+  \medskip
+
+  Initialisierung über spezielle Ports:
+  \lstinline{EICRA}, \lstinline{EIMSK}
+
+  \bigskip
+
+  \emph{Details: siehe Datenblatt und Schaltplan}
+
+  \vspace*{-2.5cm}\hfill
+  {\color{red}Herstellerspezifisch!}%
+  \hspace*{1cm}
+
+\end{frame}
+
+\subsection{volatile-Variable}
+
+\begin{frame}[fragile]
+
+  \showsubsection
+
+  Externes Gerät ruft (per Stromsignal) Unterprogramm auf
+
+  Zeiger hinterlegen: "`Interrupt-Vektor"'
+
+  Beispiel: Taster
+
+  \vspace*{-2.5pt}
+
+  \begin{minipage}[t]{5cm}
+    \begin{onlyenv}<1>
+      \begin{lstlisting}[gobble=8]
+        ¡#include <avr/interrupt.h>
+        ...
+
+        uint8_t key_pressed = 0;
+
+        ISR (INT0_vect)
+        {
+          key_pressed = 1;
+        }¿
+      \end{lstlisting}
+    \end{onlyenv}
+    \begin{onlyenv}<2>
+      \begin{lstlisting}[gobble=8]
+        ¡#include <avr/interrupt.h>
+        ...
+
+        volatile uint8_t key_pressed = 0;
+
+        ISR (INT0_vect)
+        {
+          key_pressed = 1;
+        }¿
+      \end{lstlisting}
+    \end{onlyenv}
+  \end{minipage}\hfill
+  \begin{minipage}[t]{6cm}
+    \begin{lstlisting}[gobble=6]
+      ¡int main (void)
+      {
+        ...
+
+        while (1)
+          {
+            while (!key_pressed)
+              ;  /* just wait */
+            PORTD ^= 0x40;
+            key_pressed = 0;
+          }
+        return 0;
+      }¿
+    \end{lstlisting}
+  \end{minipage}
+
+  \pause
+  \begin{picture}(0,0)
+    \color{red}
+    \put(10.3,4.0){\makebox(0,0)[b]{\begin{minipage}{6cm}
+        \begin{center}
+          \textbf{volatile}:\\
+          Speicherzugriff\\
+          nicht wegoptimieren
+        \end{center}
+      \end{minipage}}}
+    \put(10.3,3.95){\makebox(0,0)[tr]{\tikz{\draw[-latex](0,0)--(-0.5,-0.9);}}}
+  \end{picture}
+
+\end{frame}
+
+\begin{frame}[fragile]
+
+  \showsubsection
+
+  Was ist eigentlich \lstinline{PORTD}?
+
+  \bigskip
+  \pause
+
+  \lstinline[style=cmd]{avr-gcc -Wall -Os -mmcu=atmega328p blink-3.c -E}
+
+  \bigskip
+  \pause
+  \lstinline{PORTD = 0x01;}\\
+  \textarrow\quad
+  \lstinline[style=terminal]{(*(volatile uint8_t *)((0x0B) + 0x20)) = 0x01;}\\
+  \pause
+  \begin{picture}(0,2)(0,-1.7)
+    \color{red}
+    \put(5.75,0.3){$\underbrace{\rule{2.95cm}{0pt}}_{\mbox{Zahl: \lstinline|0x2B|}}$}
+    \pause
+    \put(1.55,0.3){$\underbrace{\rule{4.0cm}{0pt}}_{\mbox{\shortstack[t]{Umwandlung in Zeiger\\
+      auf \lstinline|volatile uint8_t|}}}$}
+    \pause
+    \put(1.32,-1){\makebox(0,0)[b]{\tikz{\draw[-latex](0,0)--(0,1.3)}}}
+    \put(1.12,-1.1){\makebox(0,0)[tl]{Dereferenzierung des Zeigers}}
+  \end{picture}
+
+  \pause
+  \textarrow\quad
+  \lstinline|volatile uint8_t|-Variable an Speicheradresse \lstinline|0x2B|
+
+  \pause
+  \bigskip
+  \bigskip
+
+  \textarrow\quad
+  \lstinline|PORTA = PORTB = PORTC = PORTD = 0| ist eine schlechte Idee.
+
+\end{frame}
+
+\subsection{Byte-Reihenfolge -- Endianness}
+\subsubsection{Konzept}
+
+\begin{frame}[fragile]
+
+  \showsubsection
+  \showsubsubsection
+
+  Eine Zahl geht über mehrere Speicherzellen.\\
+  Beispiel: 16-Bit-Zahl in 2 8-Bit-Speicherzellen
+
+  \smallskip
+
+  Welche Bits liegen wo?
+
+%  \pause
+  \bigskip
+
+  $1027 = 1024 + 2 + 1 = 0000\,0100\,0000\,0011_2 = 0403_{16}$
+
+%  \pause
+  \bigskip
+  Speicherzellen:
+
+  \medskip
+  \begin{tabular}{|c|c|l}\cline{1-2}
+    \raisebox{-0.25ex}{04} & \raisebox{-0.25ex}{03} & \strut Big-Endian "`großes Ende zuerst"' \\\cline{1-2}
+    \multicolumn{2}{c}{} & % \pause
+      für Menschen leichter lesbar % \pause
+      \\
+    \multicolumn{3}{c}{} \\[-5pt]\cline{1-2}
+    \raisebox{-0.25ex}{03} & \raisebox{-0.25ex}{04} & \strut Little-Endian "`kleines Ende zuerst"' \\\cline{1-2}
+    \multicolumn{2}{c}{} & % \pause
+      bei Additionen effizienter
+  \end{tabular}
+
+%  \pause
+  \medskip
+  \textarrow\ Geschmackssache
+%  \pause\\
+  \quad\textbf{\dots\ außer bei Datenaustausch!}
+
+%  \pause
+%  \bigskip
+%
+%  Aber: nicht verwechseln! \qquad $0304_{16} = 772$
+
+\end{frame}
+
+\begin{frame}
+
+  \showsubsection
+  \showsubsubsection
+
+  Eine Zahl geht über mehrere Speicherzellen.\\
+  Beispiel: 16-Bit-Zahl in 2 8-Bit-Speicherzellen
+
+  \smallskip
+
+  Welche Bits liegen wo?
+
+  \medskip
+
+  \textarrow\ Geschmackssache\\
+  \textbf{\dots\ außer bei Datenaustausch!}
+
+  \begin{itemize}
+    \item
+      Dateiformate
+    \item
+      Datenübertragung
+  \end{itemize}
+
+\end{frame}
+
+\subsubsection{Dateiformate}
+
+\begin{frame}
+
+  \showsubsection
+  \showsubsubsection
+
+  Audio-Formate: Reihenfolge der Bytes in 16- und 32-Bit-Zahlen
+  \begin{itemize}
+    \item
+      RIFF-WAVE-Dateien (\file{.wav}): Little-Endian
+    \item
+      Au-Dateien (\file{.au}): Big-Endian
+%    \pause
+    \item
+      ältere AIFF-Dateien (\file{.aiff}): Big-Endian
+    \item
+      neuere AIFF-Dateien (\file{.aiff}): Little-Endian
+  \end{itemize}
+
+%  \pause
+  \bigskip
+
+  Grafik-Formate: Reihenfolge der Bits in den Bytes
+  \begin{itemize}
+    \item
+      PBM-Dateien: Big-Endian\only<1->{, MSB first}
+    \item
+      XBM-Dateien: Little-Endian\only<1->{, LSB first}
+  \end{itemize}
+  \only<1->{MSB/LSB = most/least significant bit}
+
+\end{frame}
+
+\subsubsection{Datenübertragung}
+
+\begin{frame}
+
+  \showsubsection
+  \showsubsubsection
+
+  \begin{itemize}
+    \item
+      RS-232 (serielle Schnittstelle): LSB first
+    \item
+      I$^2$C: MSB first
+    \item
+      USB: beides
+    \pause
+    \medskip
+    \item
+      Ethernet: LSB first
+    \item
+      TCP/IP (Internet): Big-Endian
+  \end{itemize}
+
+\end{frame}
+
+\begin{frame}[fragile]
+
+  \showsubsection
+
+  Frage: \emph{Für welche Zahl steht der Speicherinhalt\,
+  \raisebox{2pt}{%
+    \tabcolsep0.25em
+    \begin{tabular}{|c|c|}\hline
+      \rule{0pt}{11pt}a3 & 90 \\\hline
+    \end{tabular}}
+  (hexadezimal)?}
+  
+  \pause
+  \smallskip
+  Antwort: \emph{Das kommt darauf an.} ;--)
+
+  \pause
+  \medskip
+  Little-Endian:
+
+  \smallskip
+
+  \begin{tabular}{lrl}
+    als \lstinline,int8_t,: & $-93$ & (nur erstes Byte)\\
+    als \lstinline,uint8_t,: & $163$ & (nur erstes Byte)\\
+    als \lstinline,int16_t,: & $-28509$\\
+    als \lstinline,uint16_t,: & $37027$\\
+    \lstinline,int32_t, oder größer: & $37027$
+      & (zusätzliche Bytes mit Nullen aufgefüllt)
+  \end{tabular}
+
+  \pause
+  \medskip
+  Big-Endian:
+
+  \smallskip
+
+  \begin{tabular}{lrl}
+    als \lstinline,int8_t,:   & $-93$ & (nur erstes Byte)\\
+    als \lstinline,uint8_t,:  & $163$ & (nur erstes Byte)\\
+    als \lstinline,int16_t,:  & $-23664$\\
+    als \lstinline,uint16_t,: & $41872$\\ als \lstinline,int32_t,:  & $-1550843904$ & (zusätzliche Bytes\\
+    als \lstinline,uint32_t,: & $2744123392$  & mit Nullen aufgefüllt)\\
+    als \lstinline,int64_t,:  & $-6660823848880963584$\\
+    als \lstinline,uint64_t,: & $11785920224828588032$\\
+  \end{tabular}
+
+  \vspace*{-1cm}
+
+\end{frame}
+
+\subsection{Speicherausrichtung -- Alignment}
+
+\begin{frame}[fragile]
+
+  \showsubsection
+
+  \begin{lstlisting}
+    #include <stdint.h>
+
+    uint8_t a;
+    uint16_t b;
+    uint8_t c;
+  \end{lstlisting}
+
+  \pause
+  \bigskip
+
+  Speicheradresse durch 2 teilbar -- "`16-Bit-Alignment"'
+  \begin{itemize}
+    \item
+      2-Byte-Operation: effizienter
+    \pause
+    \item
+      \dots\ oder sogar nur dann erlaubt
+    \pause
+    \arrowitem
+      Compiler optimiert Speicherausrichtung
+  \end{itemize}
+
+  \medskip
+
+  \pause
+  \begin{minipage}{3cm}
+    \begin{lstlisting}[gobble=6]
+      ¡uint8_t a;
+      uint8_t dummy;
+      uint16_t b;
+      uint8_t c;¿
+    \end{lstlisting}
+  \end{minipage}
+  \pause
+  \begin{minipage}{3cm}
+    \begin{lstlisting}[gobble=6]
+      ¡uint8_t a;
+      uint8_t c;
+      uint16_t b;¿
+    \end{lstlisting}
+  \end{minipage}
+
+  \pause
+  \vspace{-1.75cm}
+  \strut\hfill
+  \begin{minipage}{6.5cm}
+    Fazit:
+    \begin{itemize}
+      \item
+        \textbf{Adressen von Variablen\\
+        sind systemabhängig}
+      \item
+        Bei Definition von Datenformaten\\
+        Alignment beachten \textarrow\ effizienter
+    \end{itemize}
+  \end{minipage}
+
+\end{frame}
+
+\end{document}