diff --git a/20220607/logo-hochschule-bochum-cvh-text-v2.pdf b/20220607/logo-hochschule-bochum-cvh-text-v2.pdf new file mode 100644 index 0000000000000000000000000000000000000000..3725a72c764b4d9ab200553474e4262161f7a5b5 Binary files /dev/null and b/20220607/logo-hochschule-bochum-cvh-text-v2.pdf differ diff --git a/20220607/logo-hochschule-bochum.pdf b/20220607/logo-hochschule-bochum.pdf new file mode 100644 index 0000000000000000000000000000000000000000..8cad73dbb48a2b550bf29355b5a6ec895ce091f8 Binary files /dev/null and b/20220607/logo-hochschule-bochum.pdf differ diff --git a/20220607/pgslides.sty b/20220607/pgslides.sty new file mode 100644 index 0000000000000000000000000000000000000000..9a019ce99f03d27a17942facc56fe2145f46b6a6 --- /dev/null +++ b/20220607/pgslides.sty @@ -0,0 +1,233 @@ +% pgslides.sty - LaTeX Settings for Lecture Slides +% Copyright (C) 2012, 2013 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/>. + +\usepackage{amsfonts} +\usepackage[british,german]{babel} % Yes, really "german" and not "ngerman". +\usepackage[utf8]{luainputenc} % Without this, umlauts are broken. Weird. +\usepackage{microtype} +\usepackage[T1]{fontenc} +\usepackage{times} +\usepackage{helvet} +\renewcommand*\familydefault{\sfdefault} +\usepackage{graphicx} +\usepackage{pstricks} + +\hypersetup{colorlinks,allcolors=blue} + +%% @@@ Not necessary for slides. Why??? +%% Repair kerning: Automatically insert "\kern{-0.15em}" between "//" % (in URLs). +%\directlua{ +% local glyph = node.id ("glyph") +% local function my_kerning (head) +% for t in node.traverse (head) do +% if t.id == glyph and t.char == 47 then +% if t.next +% and t.next.next +% and t.next.next.id == glyph +% and t.next.next.char == 47 then +% local k = node.new ("kern") +% k.kern = tex.sp ("-0.15em") +% k.next = t.next +% k.prev = t +% t.next.prev = k +% t.next = k +% end +% end +% end +% node.kerning (head) +% end +% luatexbase.add_to_callback ("kerning", my_kerning, "URL kerning") +%} + +\usetheme{default} +\usefonttheme{structurebold} +\setbeamertemplate{navigation symbols}{} +\setbeamersize{text margin left = 0.3cm, text margin right = 0.2cm} +\setbeamertemplate{itemize item}{$\bullet$} +\setbeamertemplate{itemize subitem}{--} +\setbeamerfont{itemize/enumerate subbody}{size=\normalsize} +\setbeamerfont{itemize/enumerate subsubbody}{size=\normalsize} +\setbeamercolor{footline}{fg=gray} + +\newcommand{\sep}{~$\cdot$~} + +\newif\ifminimalistic +\minimalistictrue + +\institute[Hochschule Bochum\sep CVH]{% + \makebox(0,0.005)[tl]{\includegraphics[scale=0.72]{logo-hochschule-bochum-cvh-text-v2.pdf}}\hfill + \makebox(0,0)[tr]{\includegraphics[scale=0.5]{logo-hochschule-bochum.pdf}}% +} + +\setbeamertemplate{headline}{% + \leavevmode + \hbox to \textwidth{% + \ifminimalistic + \strut\hfill + \else + \rule{0pt}{5.7pt}% + \hspace*{8.55pt}\insertinstitute\hspace*{5.7pt}% + \raisebox{-30pt}{\rule{0pt}{1pt}}% + \fi + }% + \vskip0pt% +} + +\iffalse + \setbeamertemplate{footline}{} +\else + \setbeamertemplate{footline}{% + \leavevmode + \hbox to \textwidth{% + \usebeamercolor{footline}% + \usebeamerfont{footline}% + \ifminimalistic + \strut\hfill + \else + \,\insertshorttitle\sep + \insertshortauthor\sep + \insertshortinstitute\sep + \insertshortdate\hfill + \fi + \insertframenumber/\inserttotalframenumber + %Folie\,\insertframenumber\sep Seite\,\insertpagenumber\, + }% + \vskip0pt% + } +\fi + +\newcommand{\maketitleframe}{% + \ifminimalistic + \begin{frame}[t,plain] + \insertinstitute + \par\vfill + \begin{center} + {\LARGE\color{structure}\inserttitle\par}\bigskip\bigskip + {\large \insertauthor\par}\bigskip\medskip + \insertdate + \end{center} + \end{frame} + \else + \begin{frame} + \vfill + \begin{center} + {\LARGE\color{structure}\inserttitle\par}\bigskip\bigskip + {\large \insertauthor\par}\bigskip\medskip + \insertdate + \end{center} + \vfill + \end{frame} + \fi +} + +\definecolor{medgreen}{rgb}{0.0,0.5,0.0} +\definecolor{darkgreen}{rgb}{0.0,0.3,0.0} +\definecolor{lightred}{rgb}{1.0,0.7,0.7} +\definecolor{medred}{rgb}{0.5,0.0,0.0} +\definecolor{bored}{rgb}{0.89,0.0,0.098} +\definecolor{lightgray}{rgb}{0.85,0.85,0.85} +\definecolor{orange}{rgb}{1.0,0.5,0.0} +\definecolor{darkgray}{rgb}{0.4,0.4,0.4} + +\newenvironment{experts}{\color{darkgray}}{} + +\usepackage{listings} +\lstset{basicstyle=\color{structure}, + language=C, + captionpos=b, + gobble=4, + columns=fullflexible, + aboveskip=0pt, + belowskip=0pt, + moredelim=**[is][\color{structure}]{¡}{¿}, + moredelim=**[is][\only<2->{\color{structure}}]{²}{¿}, + moredelim=**[is][\only<3->{\color{structure}}]{³}{¿}, + moredelim=**[is][\only<4->{\color{structure}}]{°}{¿}, + moredelim=**[is][\only<5->{\color{structure}}]{¤}{¿}, + moredelim=**[is][\only<6->{\color{structure}}]{¢}{¿}, + moredelim=**[is][\only<7->{\color{structure}}]{æ}{¿}, + moredelim=**[is][\only<8->{\color{structure}}]{ø}{¿}} +\lstdefinestyle{terminal}{basicstyle=\ttfamily\color{darkgreen}, + language={}, + columns=fixed, + moredelim=**[is][\color{red}]{¡}{¿}, + moredelim=**[is][\color{blendedblue}]{°}{¿}, + moredelim=**[is][\sffamily\it\lstset{columns=fullflexible}]{²}{¿}} +\lstdefinestyle{cmd}{basicstyle=\ttfamily\color{red}, + language={}, + gobble=2, + columns=fixed, + moredelim=**[is][\color{darkgreen}]{¡}{¿}, + moredelim=**[is][\color{structure}]{°}{¿}, + moredelim=**[is][\sffamily\it\lstset{columns=fullflexible}]{²}{¿}} +\lstdefinestyle{shy}{basicstyle=\color{lightgray}} + +\setcounter{topnumber}{3} +\renewcommand\topfraction{0.7} +\setcounter{bottomnumber}{3} +\renewcommand\bottomfraction{0.7} +\setcounter{totalnumber}{5} +\renewcommand\textfraction{0.1} +\renewcommand\floatpagefraction{0.9} + +\setlength{\unitlength}{1cm} + +\newcommand{\protectfile}[1]{#1} +\urlstyle{sf} +\newcommand{\file}[1]{{\color{structure}\protectfile{#1}}} +\newcommand{\textarrow}{{\boldmath $\longrightarrow$}} +\newcommand{\arrowitem}{\item[\textarrow]} +\newcommand{\newterm}[1]{\emph{\color{darkgreen}#1}} +\newcommand{\BIGskip}{\vspace{1cm}} +\newcommand{\shy}{\color{lightgray}} +\newcommand{\hot}{\color{red}} +\newcommand{\shyhot}{\color{lightred}} + +\newcommand{\sectionnonumber}[1]{\section{#1}\addtocounter{section}{-1}} + +\def\showsectionnonumber{\hbox{\Large\color{structure}\bf + \vtop{\secname}\par}\bigskip} + +\newcommand{\nosectionnonumber}[1]{\gdef\nosectionnonumbername{#1}} + +\def\shownosectionnonumber{\hbox{\Large\color{structure}\bf + \vtop{\nosectionnonumbername}\par}\bigskip} + +\def\showsection{\hbox{\Large\color{structure}\bf + \vtop{\hbox{\arabic{section}}}\kern1em% + \vtop{\secname}\par}\bigskip} + +\newcommand{\subsectionnonumber}[1]{\subsection{#1}\addtocounter{subsection}{-1}} + +\def\showsubsectionnonumber{{\large\color{structure}\bf\subsecname\par}\bigskip} + +\def\showsubsection{\hbox{\large\color{structure}\bf + \vtop{\hbox{\arabic{section}.\arabic{subsection}}}\kern1em% + \vtop{\subsecname}\par}\bigskip} + +\newcommand{\subsubsectionnonumber}[1]{\subsubsection{#1}\addtocounter{subsubsection}{-1}} + +\def\showsubsubsectionnonumber{{\normalsize\color{structure}\bf\subsubsecname\par}\bigskip} + +\def\showsubsubsection{\hbox{\normalsize\color{structure}\bf + \vtop{\hbox{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}}\kern1em% + \vtop{\subsubsecname}\par}\bigskip} diff --git a/20220607/rtech-20220607.pdf b/20220607/rtech-20220607.pdf new file mode 100644 index 0000000000000000000000000000000000000000..965dd21297ffc4d87a8c2a078333167334224cf3 Binary files /dev/null and b/20220607/rtech-20220607.pdf differ diff --git a/20220607/rtech-20220607.tex b/20220607/rtech-20220607.tex new file mode 100644 index 0000000000000000000000000000000000000000..c21f5fef74c37457dc63b97d17097cfb19adec8d --- /dev/null +++ b/20220607/rtech-20220607.tex @@ -0,0 +1,574 @@ +% rtech-20220607.pdf - Lecture Slides on Computer Technology +% Copyright (C) 2012, 2013, 2014, 2021, 2022 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: Architekturmerkmale von Prozessoren, CPU-Stack + +\documentclass[10pt,t]{beamer} + +\usepackage{pgslides} +\usepackage{tikz} + +\lstdefinestyle{asm}{basicstyle=\color{structure}, + language={}, + gobble=4} + +\title{Rechnertechnik} +\author{Prof.\ Dr.\ rer.\ nat.\ Peter Gerwinski} +\date{7.\ Juni 2022} + +\begin{document} + +\maketitleframe + +\sectionnonumber{\inserttitle} + +\begin{frame} + + \showsectionnonumber + + \begin{itemize} + \item[\textbf{1}] \textbf{Einführung} + \item[\textbf{2}] \textbf{Vom Schaltkreis zum Computer} + \begin{itemize} + \item[2.1] Logik-Schaltkreise + \item[2.2] Binärdarstellung von Zahlen + \item[2.3] Vom Logik-Schaltkreis zum Addierer + \item[2.4] Negative Zahlen + \item[2.5] Vom Addierer zum Computer + \item[2.6] Computer-Sprachen + \item[2.7] Programmieren in Assembler + \color{medgreen} + \item[2.8] Struktur von Assembler-Programmen + \end{itemize} + \item[\textbf{3}] \textbf{Architekturmerkmale von Prozessoren} +% \color{gray} + \item[\textbf{4}] \textbf{Der CPU-Stack} +% \item[\textbf{5}] \textbf{Hardwarenahe Programmierung} +% \item[\textbf{6}] \textbf{Anwender-Software} +% \item[\textbf{7}] \textbf{Bus-Systeme} +% \item[\textbf{8}] \textbf{Pipelining} + \item[\textbf{\dots\hspace{-0.75em}}] +% \item[\textbf{9}] \textbf{Ausblick} + \end{itemize} + +\end{frame} + +\setcounter{section}{2} +\section{Architekturmerkmale von Prozessoren} +\subsection{Speicherarchitekturen} + +\begin{frame} + + \showsection + \showsubsection + + Bezeichnungen + \begin{itemize} + \item + \newterm{Bit\/} = 0 oder 1 -- kleinste Einheit an Information + \item + \newterm{Byte\/} = Zusammenfassung mehrerer \newterm{Bits}\\ + zu einer Binärzahl, die ein Zeichen (\newterm{Character\/}) darstellen kann,\\ + häufig 8 Bits (\newterm{Oktett\/}) + \item + \newterm{Speicherwort\/} = Zusammenfassung mehrerer Bits\\ + zu der kleinsten adressierbaren Einheit, häufig 1 Byte + \item + \newterm{RAM\/} = \newterm{Random Access Memory\/} = Hauptspeicher + \item + \newterm{ROM\/} = \newterm{Read Only Memory\/} = nur lesbarer Speicher + \end{itemize} + +\end{frame} + +\begin{frame} + + \showsubsection + + Verschiedene Arten von Speicher + \begin{itemize} + \item + \newterm{Prozessor-Register}\\ + können direkt mit ALU verbunden werden,\\ + besonders schnell (Flipflops),\\ + überschaubare Anzahl von Registern + \item + \newterm{Hauptspeicher}\\ + kann direkt adressisert und mit Prozessor-Registern abgeglichen werden,\\ + heute i.\,d.\,R.\ dynamischer Speicher (Kondensatoren) + \item + \newterm{I/O-Ports}\\ + sind spezielle Speicheradressen, über die\\ + mit externen Geräten kommuniziert wird + \item + \newterm{Massenspeicher}\\ + liegt auf externem Gerät, wird über I/O-Ports angesprochen,\\ + Festplatte, Flash-Speicher, \dots + \end{itemize} + +\end{frame} + +\begin{frame} + + \showsubsection + + \begin{itemize} + \item + \newterm{Von-Neumann-Architektur}\\ + Es gibt nur 1 Hauptspeicher, in dem sich sowohl die Befehle\\ + als auch die Daten befinden. + + \begin{onlyenv}<1> + Vorteil: Flexibilität in der Speichernutzung + + Nachteil: Befehle können überschrieben werden.\\ + $\longrightarrow$ Abstürze und Malware möglich + \end{onlyenv} + + \pause + \item + \newterm{Harvard-Architektur}\\ + Es gibt 2 Hauptspeicher. In einem befinden sich die Befehle,\\ + im anderen die Daten. + + \begin{onlyenv}<2> + Vorteil: Befehle können nicht überschrieben werden\\ + $\longrightarrow$ sicherer als Von-Neumann-Architektur + + Nachteile: Leitungen zum Speicher (Bus) müssen doppelt vorhanden sein,\\ + freier Befehlsspeicher kann nicht für Daten genutzt werden. + \end{onlyenv} + + \pause + \item + Weitere Kombinationen\\ + Hauptspeicher und I/O-Ports gemeinsam oder getrennt,\\ + Hauptspeicher und Prozessorregister gemeinsam oder getrennt + \end{itemize} + +\end{frame} + +\begin{frame} + + \showsubsection + + Beispiele: + \begin{itemize} + \item + Intel IA-32 (i386, Nachfolger und Kompatible):\\ + Von-Neumann-Architektur (plus Speicherschutzmechanismen),\\ + Prozessorregister und I/O-Ports vom Hauptspeicher getrennt + \item + Atmel AVR (z.\,B.\ ATmega):\\ + Harvard-Architektur (Befehlsspeicher als Flash-Speicher grundsätzlich auch schreibbar),\\ + Prozessorregister und I/O-Ports in gemeinsamem Adressbereich mit Hauptspeicher + \item + 6502, Renesas-Mikro-Controller:\\ + Von-Neumann-Architektur,\\ + I/O-Ports in gemeinsamem Adressbereich mit Hauptspeicher,\\ + Prozessorregister und Hauptspeicher getrennt + \end{itemize} + +\end{frame} + +\subsection{Registerarchitekturen} + +\begin{frame}[fragile] + + \showsubsection + + \vspace*{-\medskipamount} + + \begin{itemize} + \item + Mehrere Register, einzeln ansprechbar + \item + \newterm{Akkumulator\/}: Nur 1 Register kann rechnen. + \item + \newterm{Stack-Architektur\/}: Stapel, "`umgekehrte Polnische Notation"' + \end{itemize} + + \pause + + Operationen: typischerweise nur + \lstinline{=}, \lstinline{+=}, \lstinline{-=}, \lstinline{*=}, \lstinline{/=}, \dots + + \pause + \medskip + + Beispiel: \lstinline{c = a + 2 * b;} + + \pause + \medskip + + \begin{minipage}[t]{2cm} + C:\smallskip\par + \begin{lstlisting}[gobble=6] + R = b; + R *= 2; + R += a; + c = R; + \end{lstlisting} + \end{minipage}\pause + \begin{minipage}[t]{4cm} + Mehrere Register:\smallskip\par + \begin{lstlisting}[style=asm,gobble=6] + movl (b), %eax + imull $2, %eax, %eax + addl (a), %eax + movl %eax, (c) + \end{lstlisting} + \smallskip\par + (IA-32-Assembler) + \end{minipage}\pause + \begin{minipage}[t]{3cm} + Akkumulator:\smallskip\par + \begin{lstlisting}[style=asm,gobble=6] + load (b) + mul $2 + add (a) + store (c) + \end{lstlisting} + \smallskip\par + (Pseudo-Assembler) + \end{minipage}\pause + \begin{minipage}[t]{3cm} + Register-Stack:\smallskip\par + \begin{lstlisting}[style=asm,gobble=6] + push (a) + push (b) + push $2 + mul + add + pop (c) + \end{lstlisting} + \end{minipage} + +\end{frame} + +\begin{frame} + + \showsubsection + + Beispiele: + \begin{itemize} + \item + Intel IA-32 (i386, Nachfolger und Kompatible):\\ + Mehrere Register, für verschiedene Zwecke spezialisiert (unübersichtlich),\\[\smallskipamount] + Fließkommaregister: Stack-Architektur + \item + Atmel AVR (z.\,B.\ ATmega):\\ + 32 Register + \item + 6502, Renesas-Mikro-Controller:\\ + 3 Register: A, X, Y. Nur A kann rechnen $\longrightarrow$ Akkumulator + \item + Java Virtual Machine (JVM):\\ + Stack-Architektur + \item + Redcode:\\ + Jede Speicherzelle fungiert als Register + \end{itemize} + +\end{frame} + +\subsection{Befehlssätze} + +\begin{frame} + + \showsubsection + + \begin{itemize} + \item + \newterm{Complex Instruction Set Computer (CISC)} + + \smallskip + + Umfangreiche Befehlssätze, mächtige Befehle + + \begin{onlyenv}<1> + \textarrow\ komfortable manuelle Programmierung in Assembler\\ + \textarrow\ längere Abarbeitungszeit der einzelnen Befehle + + \smallskip + + Realisierung: "`Prozessor im Prozessor"' -- \newterm{Mikroprogramme} + + \smallskip + + Beispiele: IA-32, AMD-64 + \end{onlyenv} + + \medskip + \pause + \item + \newterm{Reduced Instruction Set Computer (RISC)} + + \smallskip + + wenige, wenig mächtige Befehle + + \begin{onlyenv}<2> + \textarrow\ Programmierung in Assembler für Menschen unkomfortabel\\ + \textarrow\ schnelle Abarbeitung der Befehle + + \smallskip + + Beispiele: Atmel AVR, Redcode + \end{onlyenv} + + \pause + \medskip + \item + \newterm{Very Long Instruction Word (VLIW)\/} und\\ + \newterm{Explicitly Parallel Instruction Computing (EPIC)} + + \smallskip + + mehrere Befehle gleichzeitig ausführbar + + \begin{onlyenv}<3> + \textarrow\ mehr Rechenleistung möglich\\ + \textarrow\ Programmierung sehr aufwendig + + \smallskip + + Beispiel: IA-64 + \end{onlyenv} + + \pause + \medskip + \item + \newterm{Orthogonaler Befehlssatz} + + \smallskip + + jeder Befehl mit jeder Adressierungsart kombinierbar + \end{itemize} + +\end{frame} + +\section{Der CPU-Stack\label{CPU-Stack}} +\addtocounter{subsection}{-1} +\subsection{Was ist ein Stack?} + +\begin{frame}[fragile] + + \showsection + \showsubsection + + \bigskip + +\iffalse + + \begin{minipage}[b]{6cm} + \begin{center} + "`First In -- First Out"' + + \bigskip + + \begin{picture}(6,4) + \thicklines + \color{structure} + \put(0.5,0){\line(1,0){5}} + + \put(3.5,0){\only<1-5>{\line(0,1){1}}} + \put(4.5,0){\only<1-4>{\line(0,1){1}}} + \put(3.5,1){\only<1-4>{\line(1,0){1}}} + \put(4.0,0.5){\only<1-4>{\makebox(0,0){\lstinline{3}}}} + \put(3.0,1.5){\only<1>{\makebox(0,0)[tl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,-0.45);}}}} + \put(3.0,1.5){\only<1>{\makebox(0,0)[b]{\lstinline{push (3)}}}} + + \put(2.5,0){\only<2-6>{\line(0,1){1}}} + \put(2.5,1){\only<2-5>{\line(1,0){1}}} + \put(3.0,0.5){\only<2-5>{\makebox(0,0){\lstinline{7}}}} + \put(2.0,1.5){\only<2>{\makebox(0,0)[tl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,-0.45);}}}} + \put(2.0,1.5){\only<2>{\makebox(0,0)[b]{\lstinline{push (7)}}}} + + \put(1.5,0){\only<3-6>{\line(0,1){1}}} + \put(1.5,1){\only<3-6>{\line(1,0){1}}} + \put(2.0,0.5){\only<3-6>{\makebox(0,0){\lstinline{137}}}} + \put(1.0,1.5){\only<3>{\makebox(0,0)[tl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,-0.45);}}}} + \put(1.0,1.5){\only<3>{\makebox(0,0)[b]{\lstinline{push (137)}}}} + + \put(4.55,1.05){\only<4>{\makebox(0,0)[bl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,0.45);}}}} + \put(5.00,1.60){\only<4>{\makebox(0,0)[b]{\lstinline{pop ()}: 3}}} + + \put(3.55,1.05){\only<5>{\makebox(0,0)[bl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,0.45);}}}} + \put(4.00,1.60){\only<5>{\makebox(0,0)[b]{\lstinline{pop ()}: 7}}} + + \put(2.55,1.05){\only<6>{\makebox(0,0)[bl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,0.45);}}}} + \put(3.00,1.60){\only<6>{\makebox(0,0)[b]{\lstinline{pop ()}: 137}}} + \end{picture} + + \bigskip + + FIFO = Queue = Reihe + \end{center} + \end{minipage}\hfill + +\fi + + \begin{minipage}[b]{6cm} + \begin{center} + "`Last In -- First Out"' + + \bigskip + + \begin{picture}(6,4) + \thicklines + \color{structure} + \put(1.5,0){\line(1,0){3}} + + \put(2.5,0){\line(0,1){1}} + \put(3.5,0){\line(0,1){1}} + \put(2.5,1){\line(1,0){1}} + \put(3.0,0.5){\makebox(0,0){\lstinline{3}}} + \put(2.0,1.5){\only<1>{\makebox(0,0)[tl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,-0.45);}}}} + \put(2.0,1.5){\only<1>{\makebox(0,0)[b]{\lstinline{push (3)}}}} + + \put(2.5,1){\only<2-5>{\line(0,1){1}}} + \put(3.5,1){\only<2-5>{\line(0,1){1}}} + \put(2.5,2){\only<2-5>{\line(1,0){1}}} + \put(3.0,1.5){\only<2-5>{\makebox(0,0){\lstinline{7}}}} + \put(2.0,2.5){\only<2>{\makebox(0,0)[tl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,-0.45);}}}} + \put(2.0,2.5){\only<2>{\makebox(0,0)[b]{\lstinline{push (7)}}}} + + \put(2.5,2){\only<3-4>{\line(0,1){1}}} + \put(3.5,2){\only<3-4>{\line(0,1){1}}} + \put(2.5,3){\only<3-4>{\line(1,0){1}}} + \put(3.0,2.5){\only<3-4>{\makebox(0,0){\lstinline{137}}}} + \put(2.0,3.5){\only<3>{\makebox(0,0)[tl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,-0.45);}}}} + \put(2.0,3.5){\only<3>{\makebox(0,0)[b]{\lstinline{push (137)}}}} + + \put(3.55,3.05){\only<4>{\makebox(0,0)[bl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,0.45);}}}} + \put(4.00,3.60){\only<4>{\makebox(0,0)[b]{\lstinline{pop ()}: 137}}} + + \put(3.55,2.05){\only<5>{\makebox(0,0)[bl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,0.45);}}}} + \put(4.00,2.60){\only<5>{\makebox(0,0)[b]{\lstinline{pop ()}: 7}}} + + \put(3.55,1.05){\only<6>{\makebox(0,0)[bl]{\tikz{\draw[-latex, line width=1pt](0,0)--(0.45,0.45);}}}} + \put(4.00,1.60){\only<6>{\makebox(0,0)[b]{\lstinline{pop ()}: 3}}} + \end{picture} + + \bigskip + + LIFO = Stack = Stapel + \end{center} + \end{minipage} + +% +% \dots + +\end{frame} +\subsection{Implementation} + +\begin{frame} + + \showsection + \showsubsection + + Speicher, in dem Werte "`gestapelt"' werden: \newterm{Stack} + + \begin{itemize} + \item + Speicherbereich (ein array) reservieren + \item + Variable (typischerweise: Prozessorregister) als + \newterm{Stack Pointer\/} reservieren \textarrow\ \lstinline{SP} + \item + Assembler-Befehl \lstinline[style=asm]{push foo}: \quad + \lstinline{*SP++ = foo;} + \item + Assembler-Befehl \lstinline[style=asm]{pop bar}: \quad + \lstinline{bar = *--SP;} + \end{itemize} + + \pause + \medskip + Speziell: Unterprogramme + +\end{frame} + +\subsection{Unterprogramme} + +\begin{frame}[fragile] + + \showsection + \showsubsection + + \begin{minipage}[t]{4.5cm} + Parameter: + \begin{itemize} + \item + Prozessorregister + \item + CPU-Stack + \end{itemize} + + \smallskip + + Rückgabewert: + \begin{itemize} + \item + Prozessorregister + \end{itemize} + \end{minipage}% + \begin{minipage}[t]{5cm} + Aufruf: + \begin{itemize} + \item + \lstinline[style=asm]{push IP}\\ + \lstinline[style=asm]{jmp foo} + {\color{red}\boldmath $\longleftarrow$ mov \#foo IP}\\ + \textarrow\ \lstinline[style=asm]{call foo} + \end{itemize} + Rücksprung: + \begin{itemize} + \item + \lstinline[style=asm]{pop IP}\\ + \textarrow\ \lstinline[style=asm]{ret} + \end{itemize} + \end{minipage} + +\end{frame} + +\subsection{Register sichern} + +\begin{frame} + + \showsection + \showsubsection + + Ein Unterprogramm verändert Registerinhalte. + \begin{itemize} + \item + im Hauptprogramm nötigenfalls vor Aufruf sichern + \item + im Unterprogramm vor Benutzung sichern + \item + Kombinationen (manche Register so, manche so) + \end{itemize} + +\end{frame} + +\end{document}