Skip to content
Snippets Groups Projects
Select Git revision
  • 0ba264323975d1dc4dd71499afc9d06ee4ce3d5e
  • master default
2 results

blink-11.c

Blame
  • Forked from Peter Gerwinski / hp
    Source project has a limited visibility.
    hp-20231102.tex 21.43 KiB
    % hp-20231102.pdf - Lecture Slides on Low-Level Programming
    % Copyright (C) 2012, 2013, 2015, 2016, 2017, 2018, 2019, 2020, 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: Bibliotheken
    
    \documentclass[10pt,t]{beamer}
    
    \usepackage{pgslides}
    \usepackage{pdftricks}
    \usepackage{tikz}
    
    \begin{psinputs}
      \usepackage[utf8]{inputenc}
      \usepackage[german]{babel}
      \usepackage[T1]{fontenc}
      \usepackage{helvet}
      \renewcommand*\familydefault{\sfdefault}
      \usepackage{pstricks,pst-grad}
    \end{psinputs}
    
    \newcommand{\redurl}[1]{\href{#1}{\color{red}\nolinkurl{#1}}}
    
    \title{Hardwarenahe Programmierung}
    \author{Prof.\ Dr.\ rer.\ nat.\ Peter Gerwinski}
    \date{2.\ November 2023}
    
    \begin{document}
    
    \maketitleframe
    
    %\date{\begin{picture}(0,0)
    %        \color{red}
    %        \put(0.65,1.05){\makebox(0,0)[t]{$\underbrace{\rule{1.45cm}{0pt}}_{%
    %          \mbox{\emph{rerum naturalium\/} = der natürlichen Dinge (lat.)}}$}}
    %        \put(1.65,-3){\makebox(0,0)[bl]{\redurl{https://www.peter.gerwinski.de/physik/}}}
    %      \end{picture}%
    %      12.\ Oktober 2023}
    %
    %\maketitleframe
    
    \title{Hardwarenahe Programmierung}
    
    \nosectionnonumber{\inserttitle}
    
    \begin{frame}
    
      \shownosectionnonumber
    
      \begin{itemize}
        \item[\textbf{1}] \textbf{Einführung}
          \hfill\makebox(0,0)[br]{\raisebox{2.25ex}{\url{https://gitlab.cvh-server.de/pgerwinski/hp}}}
        \item[\textbf{2}] \textbf{Einführung in C}
          \begin{itemize}
            \vspace{-1.5\smallskipamount}
            \item[\dots]
            \item[2.11] Arrays und Strings
            \item[2.12] Strukturen
            \item[2.13] Dateien und Fehlerbehandlung
            \item[2.14] Parameter des Hauptprogramms
            \color{medgreen}
            \item[2.15] String-Operationen
          \end{itemize}
        \item[\textbf{3}] \textbf{Bibliotheken}
          \begin{itemize}
            \color{medgreen}
            \item[3.1] Der Präprozessor
            \item[3.2] Bibliotheken einbinden
            \item[3.3] Bibliotheken verwenden
            \color{orange}
            \item[3.4] Callbacks
            \color{red}
            \item[3.5] Projekt organisieren: make
          \end{itemize}
        \item[\textbf{4}] \textbf{Hardwarenahe Programmierung}
        \vspace*{-\smallskipamount}
        \item[\textbf{\dots}]
    %    \item[\textbf{5}] \textbf{Algorithmen}
    %    \item[\textbf{6}] \textbf{Ergänzungen und Ausblicke}
      \end{itemize}
    
    \end{frame}
    
    \section{Einführung}
    \section{Einführung in C}
    \setcounter{subsection}{14}
    \subsection{String-Operationen}
    
    \begin{frame}[fragile]
    
      \showsubsection
    
    %  \vspace*{-0.4cm}
      \begin{lstlisting}
        #include <stdio.h>
        #include <string.h>
    
        int main (void)
        {
          char hello[] = "Hello, world!\n";
    
          printf ("%s\n", hello);
          printf ("%zd\n", strlen (hello));
    
          printf ("%s\n", hello + 7);
          printf ("%zd\n", strlen (hello + 7));
    
          hello[5] = 0;
          printf ("%s\n", hello);
          printf ("%zd\n", strlen (hello));
    
          return 0;
        }
      \end{lstlisting}
      \vspace*{-1cm}
    
    \end{frame}
    
    \begin{frame}[fragile]
    
      \showsubsection
    
    %  \vspace*{-0.4cm}
      \begin{lstlisting}
        #include <stdio.h>
        #include <string.h>
    
        int main (void)
        {
          char *anton = "Anton";
          char *zacharias = "Zacharias";
    
          printf ("%d\n", strcmp (anton, zacharias));
          printf ("%d\n", strcmp (zacharias, anton));
          printf ("%d\n", strcmp (anton, anton));
    
          char buffer[100] = "Huber ";
          strcat (buffer, anton);
          printf ("%s\n", buffer);
    
          return 0;
        }
      \end{lstlisting}
      \vspace*{-1cm}
    
    \end{frame}
    
    \begin{frame}[fragile]
    
      \showsubsection
    
    %  \vspace*{-0.4cm}
      \begin{lstlisting}
        #include <stdio.h>
        #include <string.h>
    
        int main (void)
        {
          char buffer[100] = "";
          sprintf (buffer, "Die Antwort lautet: %d", 42);
          printf ("%s\n", buffer);
    
          char *answer = strstr (buffer, "Antwort");
          printf ("%s\n", answer);
          printf ("found at: %zd\n", answer - buffer);
    
          return 0;
        }
      \end{lstlisting}
      \vspace*{-1cm}
    
    \end{frame}
    
    \begin{frame}[fragile]
    
      \showsubsection
    
    %  \vspace*{-0.4cm}
      \begin{lstlisting}
        #include <stdio.h>
        #include <string.h>
    
        int main (void)
        {
          char buffer[100] = "";
          snprintf (buffer, 100, "Die Antwort lautet: %d", 42);
          printf ("%s\n", buffer);
    
          char *answer = strstr (buffer, "Antwort");
          printf ("%s\n", answer);
          printf ("found at: %zd\n", answer - buffer);
    
          return 0;
        }
      \end{lstlisting}
    
    \end{frame}
    
    \begin{frame}
    
      \showsection
    
      Sprachelemente weitgehend komplett
    
      \bigskip
      Es fehlen:
      \begin{itemize}
        \item
          Ergänzungen (z.\,B.\ ternärer Operator, \lstinline{union}, \lstinline{unsigned}, \lstinline{volatile})
        \item
          Bibliotheksfunktionen (z.\,B.\ \lstinline{malloc()})
        \arrowitem
          werden eingeführt, wenn wir sie brauchen
        \bigskip
        \item
          Konzepte (z.\,B.\ rekursive Datenstrukturen, Klassen selbst bauen)
        \arrowitem
          werden eingeführt, wenn wir sie brauchen, oder:
        \arrowitem
          Literatur\\[\smallskipamount]
          (z.\,B.\ Wikibooks: C-Programmierung,\\
          Dokumentation zu Compiler und Bibliotheken)
        \bigskip
        \item
          Praxiserfahrung
        \arrowitem
          Übung und Praktikum: nur Einstieg
        \arrowitem
          selbständig arbeiten
      \end{itemize}
    \end{frame}
    
    \section{Bibliotheken}
    \subsection{Der Präprozessor}
    
    \begin{frame}[fragile]
    
      \showsection
      \showsubsection
    
      \lstinline{#include}: %\pause:
      Text einbinden
      \begin{itemize}
    %    \pause
        \item
          \lstinline{#include <stdio.h>}: Standard-Verzeichnisse -- Standard-Header
    %    \pause
        \item
          \lstinline{#include "answer.h"}: auch aktuelles Verzeichnis -- eigene Header
      \end{itemize}
    
    %  \pause
      \bigskip
    
      \lstinline{#define SIX 6}: Text ersetzen lassen -- Konstante definieren
      \begin{itemize}
    %    \pause
        \item
          Kein Semikolon!
    %    \pause
        \item
          Berechnungen in Klammern setzen:\\
          \lstinline{#define SIX (1 + 5)}
    %    \pause
        \item
          Konvention: Großbuchstaben
      \end{itemize}
    
    \end{frame}
    
    \subsection{Bibliotheken einbinden}
    
    \begin{frame}[fragile]
    
      \showsection
      \showsubsection
    
      Inhalt der Header-Datei: externe Deklarationen
    
    %  \pause
      \smallskip
      \lstinline{extern int answer (void);}
    
    %  \pause
      \smallskip
      \lstinline{extern int printf (__const char *__restrict __format, ...);}
    
    %  \pause
      \bigskip
      Funktion wird "`anderswo"' definiert
      \begin{itemize}
    %    \pause
        \item
          separater C-Quelltext: mit an \lstinline[style=terminal]{gcc} übergeben
    %    \pause
        \item
          Zusammenfügen zu ausführbarem Programm durch den \newterm{Linker}
    %    \pause
        \item
          vorcompilierte Bibliothek: \lstinline[style=terminal]{-lfoo}\\
    %      \pause
          = Datei \file{libfoo.a} in Standard-Verzeichnis
      \end{itemize}
    
    \end{frame}
    
    \subsection{Bibliothek verwenden (Beispiel: GTK)}
    
    \begin{frame}[fragile]
    
      \showsubsection
    
      \begin{itemize}
        \item
          \lstinline{#include <gtk/gtk.h>}
        \pause
        \smallskip
        \item
          Mit \lstinline[style=cmd]{pkg-config --cflags --libs gtk4} erfährt man,\\
          welche Optionen und Bibliotheken man an \lstinline[style=cmd]{gcc}
          übergeben muß\alt<4->{.}{:}
          \pause
          \begin{onlyenv}<3>
            \begin{lstlisting}[style=terminal,gobble=10]
              $ ¡pkg-config --cflags --libs gtk4¿
              -I/usr/include/gtk-4.0 -I/usr/include/pango-1.0 -I/usr/
              include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/i
              nclude -I/usr/include/harfbuzz -I/usr/include/freetype2
              -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/
              include/blkid -I/usr/include/fribidi -I/usr/include/cai
              ro -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.
              0 -I/usr/include/x86_64-linux-gnu -I/usr/include/graphe
              ne-1.0 -I/usr/lib/x86_64-linux-gnu/graphene-1.0/include
              -mfpmath=sse -msse -msse2 -pthread -lgtk-4 -lpangocairo
              -1.0 -lpango-1.0 -lharfbuzz -lgdk_pixbuf-2.0 -lcairo-go
              bject -lcairo -lgraphene-1.0 -lgio-2.0 -lgobject-2.0 -l
              glib-2.0 
            \end{lstlisting}
            \vspace*{-3cm}
          \end{onlyenv}
        \pause
        \arrowitem
          Compiler-Aufruf:
          \begin{onlyenv}<4>
            \begin{lstlisting}[style=terminal,gobble=10]
              $ ¡gcc -Wall -O hello-gtk.c -I/usr/include/gtk-4.0 -I/u
              sr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib
              /x86_64-linux-gnu/glib-2.0/include -I/usr/include/harfb
              uzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I
              /usr/include/libmount -I/usr/include/blkid -I/usr/inclu
              de/fribidi -I/usr/include/cairo -I/usr/include/pixman-1
              -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/x86_64-lin
              ux-gnu -I/usr/include/graphene-1.0 -I/usr/lib/x86_64-li
              nux-gnu/graphene-1.0/include -mfpmath=sse -msse -msse2
              -pthread -lgtk-4 -lpangocairo -1.0 -lpango-1.0 -lharfbu
              zz -lgdk_pixbuf-2.0 -lcairo-gobject -lcairo -lgraphene-
              1.0 -lgio-2.0 -lgobject-2.0 -l glib-2.0 -o hello-gtk¿
            \end{lstlisting}
            \vspace*{-2cm}
          \end{onlyenv}
          \begin{onlyenv}<5->
            \begin{lstlisting}[style=terminal,gobble=10]
              $ ¡gcc -Wall -O hello-gtk.c $(pkg-config --cflags --libs
                     gtk4) -o hello-gtk¿
            \end{lstlisting}
          \end{onlyenv}
          \begin{onlyenv}<5>
            \begin{picture}(0,0)(0.3,0.3)
              \color{red}
              \put(6.6,-0.6){\makebox(0,0)[bl]{\tikz{\draw[-latex](0,0)--(3,1.5);}}}
              \put(6.3,-0.7){\makebox(0,0)[t]{\shortstack{\strut Optionen:\\
                               \strut u.\,a.\ viele Include-Verzeichnisse:\\
                               \lstinline[style=cmd]{-I/usr/include/gtk-4.0}}}}
              \put(10.0,-2.1){\makebox(0,0)[bl]{\tikz{\draw[-latex](0,0)--(1.5,3);}}}
              \put(10.3,-2.2){\makebox(0,0)[t]{\shortstack{\strut Bibliotheken:\\
                                \strut u.\,a.\ \lstinline[style=cmd]{-lgtk-4}}}}
            \end{picture}
          \end{onlyenv}
        \pause
        \pause
        \item
          Auf manchen Plattformen kommt es auf die Reihenfolge an:
          \begin{lstlisting}[style=terminal,gobble=8]
            $ ¡gcc -Wall -O $(pkg-config --cflags gtk4) \
                   hello-gtk.c $(pkg-config --libs gtk4) \
                   -o hello-gtk¿
          \end{lstlisting}
          (Backslash = "`Es geht in der nächsten Zeile weiter."')
      \end{itemize}
    
    \end{frame}
    
    \subsection{Callbacks}
    
    \begin{frame}[fragile]
    
      \showsubsection
    
      Selbst geschriebene Funktion übergeben: \newterm{Callback}
    
      \bigskip
    
      \begin{lstlisting}[xleftmargin=1em]
        static void hello (GtkWidget *this, gpointer user_data)
        {
          char *world = user_data;
          printf ("Hello, %s!\n", world);
        }
      
        ...
    
        g_signal_connect (button, "clicked", G_CALLBACK (hello), "world");
      \end{lstlisting}
    
      \medskip
    
      \begin{itemize}
        \arrowitem 
          GTK ruft immer dann, wenn der Button betätigt wurde,\\
          die Funktion \lstinline{hello} auf.
      \end{itemize}
    
      \pause
      \begin{picture}(0,0)(1.1,0.8)
        \color{red}
        \put(9.7,5.1){\makebox(0,0)[br]{\tikz{\draw[-latex](0,0)--(-0.3,0.5);}}}
        \put(10.0,5.0){\makebox(0,0)[t]{\shortstack{\strut optionale Zusatzinformationen\\
                         \strut für hello(), hier ein String\\
                         \strut oft ein Zeiger auf ein struct}}}
        \put(10.5,3.5){\makebox(0,0)[tl]{\tikz{\draw[-latex](0,0)--(0.3,-0.5);}}}
      \end{picture}
    
    \end{frame}
    
    \begin{frame}[fragile]
    
      \showsubsection
    
      Selbst geschriebene Funktion übergeben: \newterm{Callback}
    
      \bigskip
    
      \begin{lstlisting}[xleftmargin=1em]
        static void draw (GtkDrawingArea *drawing_area, cairo_t *c,
                          int width, int height, gpointer user_data)
        {
          /* Zeichenbefehle */
          ...
        }
      
        ...
    
        gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area),
                                           draw, NULL, NULL);
      \end{lstlisting}
    
      \medskip
    
      \begin{itemize}
        \arrowitem 
          GTK ruft immer dann, wenn es etwas zu zeichnen gibt,\\
          die Funktion \lstinline{draw} auf.
      \end{itemize}
    
      \pause
      \begin{picture}(0,0)
        \color{red}
        \put(10.0,4.9){\makebox(0,0)[br]{\tikz{\draw[-latex](0,0)--(-0.3,0.9);}}}
        \put(10.0,4.8){\makebox(0,0)[t]{\shortstack{\strut repräsentiert den\\
                         \strut Bildschirm, auf den\\
                         \strut gezeichnet werden soll}}}
      \end{picture}
    
    \end{frame}
    
    \iffalse
    
    \begin{frame}[fragile]
    
      \showsubsection
    
      Selbst geschriebene Funktion übergeben: \newterm{Callback}
    
      \bigskip
    
      \begin{lstlisting}[xleftmargin=1em]
        gboolean timer (GtkWidget *widget)
        {
          /* Rechenbefehle */
          ...
    
          gtk_widget_queue_draw_area (widget, 0, 0, WIDTH, HEIGHT);
          g_timeout_add (50, (GSourceFunc) timer, widget);
          return FALSE;
        }
      
        ...
    
        g_timeout_add (50, (GSourceFunc) timer, drawing_area);
      \end{lstlisting}
    
      \medskip
    
      \begin{itemize}
        \arrowitem 
          GTK+ ruft nach 50 Millisekunden
          die Funktion \lstinline{timer} auf.
      \end{itemize}
    
      \pause
      \begin{picture}(0,0)(-0.07,0.2)
        \color{red}
        \put(9.7,6.7){\makebox(0,0)[t]{\shortstack{\strut Dieser Bereich soll\\
                        \strut neu gezeichnet werden.}}}
        \put(9.7,5.7){\makebox(0,0)[tr]{\tikz{\draw[-latex](0,0)--(-0.6,-0.8);}}}
        \pause
        \put(4.3,3.2){\makebox(0,0)[br]{\tikz{\draw[-latex](0,0)--(-0.7,0.6);}}}
        \put(4.3,3.1){\makebox(0,0)[t]{\shortstack{\strut In weiteren 50 Millisekunden soll\\
                        \strut die Funktion erneut aufgerufen werden.}}}
        \pause
        \put(9.3,2.9){\makebox(0,0)[br]{\tikz{\draw[-latex](0,0)--(-3.3,0.9);}}}
        \put(9.8,2.8){\makebox(0,0)[t]{\shortstack{\strut Explizite Typumwandlung\\
                        \strut eines Zeigers (später)}}}
      \end{picture}
    
    \end{frame}
    
    \fi
    
    \nosectionnonumber{\inserttitle}
    
    \begin{frame}
    
      \shownosectionnonumber
    
      \begin{itemize}
        \item[\textbf{1}] \textbf{Einführung}
          \hfill\makebox(0,0)[br]{\raisebox{2.25ex}{\url{https://gitlab.cvh-server.de/pgerwinski/hp}}}
        \item[\textbf{2}] \textbf{Einführung in C}
          \begin{itemize}
            \vspace{-1.5\smallskipamount}
            \item[\dots]
            \item[2.11] Arrays und Strings
            \item[2.12] Strukturen
            \item[2.13] Dateien und Fehlerbehandlung
            \item[2.14] Parameter des Hauptprogramms
            \color{medgreen}
            \item[2.15] String-Operationen
          \end{itemize}
        \item[\textbf{3}] \textbf{Bibliotheken}
          \begin{itemize}
            \color{medgreen}
            \item[3.1] Der Präprozessor
            \item[3.2] Bibliotheken einbinden
            \item[3.3] Bibliotheken verwenden
            \color{orange}
            \item[3.4] Callbacks
            \color{red}
            \item[3.5] Projekt organisieren: make
          \end{itemize}
        \item[\textbf{4}] \textbf{Hardwarenahe Programmierung}
        \vspace*{-\smallskipamount}
        \item[\textbf{\dots}]
    %    \item[\textbf{5}] \textbf{Algorithmen}
    %    \item[\textbf{6}] \textbf{Ergänzungen und Ausblicke}
      \end{itemize}
    
    \end{frame}
    
    \subsection{Projekt organisieren: make}
    
    \begin{frame}[fragile]
    
      \showsubsection
      \begin{itemize}
        \item
          \only<4->{explizite und implizite} Regeln
          \begin{onlyenv}<2>
            \smallskip
            \begin{lstlisting}[language=make,gobble=10]
              philosophy: philosophy.o answer.o
                      gcc philosophy.o answer.o -o philosophy
    
              answer.o: answer.c answer.h
                      gcc -Wall -O answer.c -c
    
              philosophy.o: philosophy.c answer.h
                      gcc -Wall -O philosophy.c -c
            \end{lstlisting}
          \end{onlyenv}
          \begin{onlyenv}<4>
            \smallskip
            \begin{lstlisting}[language=make,gobble=10]
              TARGET = philosophy
              OBJECTS = philosophy.o answer.o
              HEADERS = answer.h
              CFLAGS = -Wall -O
    
              $(TARGET): $(OBJECTS)
                      gcc $(OBJECTS) -o $(TARGET)
    
              %.o: %.c $(HEADERS)
                      gcc $(CFLAGS) $< -c
    
              clean:
                      rm -f $(OBJECTS) $(TARGET)
            \end{lstlisting}
          \end{onlyenv}
        \item
          Makros
          \begin{onlyenv}<3>
            \smallskip
            \begin{lstlisting}[language=make,gobble=10]
              TARGET = philosophy
              OBJECTS = philosophy.o answer.o
              HEADERS = answer.h
              CFLAGS = -Wall -O
    
              $(TARGET): $(OBJECTS)
                      gcc $(OBJECTS) -o $(TARGET)
    
              answer.o: answer.c $(HEADERS)
                      gcc $(CFLAGS) answer.c -c
    
              philosophy.o: philosophy.c $(HEADERS)
                      gcc $(CFLAGS) philosophy.c -c
    
              clean:
                      rm -f $(OBJECTS) $(TARGET)
            \end{lstlisting}
            \vspace*{-1cm}
          \end{onlyenv}
        \begin{onlyenv}<5->
          \smallskip
          \arrowitem
            3 Sprachen: C, Präprozessor, make
        \end{onlyenv}
      \end{itemize}
    
    \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 C}
    
    \begin{frame}[fragile]
    
      \showsubsubsection
    
      \begin{tabular}{lll}
        C-Operator     & Verknüpfung              & Anwendung                \\[\smallskipamount]
        \lstinline,&,  & Und                      & Bits gezielt löschen     \\
        \lstinline,|,  & Oder                     & Bits gezielt setzen      \\
        \lstinline,^,  & Exklusiv-Oder            & Bits gezielt invertieren \\
        \lstinline,~,  & Nicht                    & Alle Bits invertieren    \\[\smallskipamount]
        \lstinline,<<, & Verschiebung nach links  & Maske generieren         \\
        \lstinline,>>, & 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;, \\
        Bit Nr.\ 4 auf 0 setzen: &
        \lstinline,a &= ~(1 << 4);, \\
        Bit Nr.\ 0 invertieren: &
        \lstinline,a ^= 1 << 0;,
      \end{tabular}
    
      \smallskip
    
      ~~Abfrage, ob Bit Nr.\ 1 gesetzt ist:\quad
      \lstinline{if (a & (1 << 1))}
    
    \end{frame}
    
    \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}
    
    \end{document}