Skip to content
Snippets Groups Projects
Commit e3786acf authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Vortragsfolien und Beispiele, 10.5.2023

parent 70c89f9a
No related branches found
No related tags found
No related merge requests found
Showing
with 627 additions and 0 deletions
;redcode
;name Antiknirps
;author Peter Gerwinski
;strategy Modifiziere den Code von Knirps, um ihn zu stoppen
;assert 1
falle DAT #0
start JMP start, <falle
END start
;redcode
;name Antiknirps
;author Peter Gerwinski
;strategy Modifiziere den Code von Knirps, um ihn zu stoppen
;assert 1
falle DAT #0
DAT #0
start JMP start, <falle
END start
;redcode
;name Antiknirps
;author Peter Gerwinski
;strategy Modifiziere den Code von Knirps, um ihn zu stoppen
;assert 1
falle DAT #0
DAT #0
start DJN start, falle
JMP start
END start
;name Cat Can
;author A. Kirchner, F. Uy, P. Gerwinski
;assert 1
;
; Your basic two sweep methodical bomber.
; Fires SPL 0 and JMP -1 at every eight
; addresses, then erases the core with
; DAT bombs.
start mov trap2, < bomb
mov trap1, < bomb
sub # 6, bomb
jmn start, bomb ; trap loop
set mov # -12, bomb
kill mov bomb, @ bomb
djn kill, bomb ; kill loop
reset jmp set, 0
bomb dat # 0, # -1024
trap1 spl 0
trap2 jmp -1
end start
;name Cat Can
;author A. Kirchner, F. Uy
;assert 1
;
; Your basic two sweep methodical bomber.
; Fires SPL 0 and JMP -1 at every eight
; addresses, then erases the core with
; DAT bombs.
start mov trap2, < bomb
mov trap1, < bomb
sub # 6, bomb
jmn start, bomb ; trap loop
set mov # -12, bomb
kill mov bomb, @ bomb
djn kill, bomb ; kill loop
reset jmp set, 0
jmp set, 0
dat # 0, # 0 ; buffer
bomb dat # 0, # -1024
trap1 spl 0, 2
trap2 jmp -1, 1
end start
;redcode
;name Dwarf
;author A. K. Dewdney, modified by Peter Gerwinski
;assert 1
bomb DAT #3
dwarf ADD #1, bomb
MOV bomb, @bomb
JMP dwarf
END dwarf ; Programs start at the first line unless
; an "END start" pseudo-op appears to indicate
; the first logical instruction. Also, nothing
; after the END instruction will be assembled.
;redcode
;name Dwarf
;author A. K. Dewdney, modified by Peter Gerwinski
;assert 1
bomb DAT #0
dwarf ADD #-1, bomb
MOV bomb, @bomb
JMP dwarf
END dwarf ; Programs start at the first line unless
; an "END start" pseudo-op appears to indicate
; the first logical instruction. Also, nothing
; after the END instruction will be assembled.
;redcode
;name Dwarf
;author A. K. Dewdney
;strategy Throw DAT bombs around memory, hitting every 4th memory cell.
;strategy This program was presented in the first Corewar article.
;assert 1
bomb DAT #0
DAT #0
dwarf ADD #4, bomb
MOV bomb, @bomb
JMP dwarf
END dwarf ; Programs start at the first line unless
; an "END start" pseudo-op appears to indicate
; the first logical instruction. Also, nothing
; after the END instruction will be assembled.
;redcode
;name Dwarf
;author A. K. Dewdney
;strategy Throw DAT bombs around memory, hitting every 4th memory cell.
;strategy This program was presented in the first Corewar article.
;assert 1
bomb DAT #0
DAT #0
dwarf ADD #5, bomb
MOV bomb, @bomb
JMP dwarf
END dwarf ; Programs start at the first line unless
; an "END start" pseudo-op appears to indicate
; the first logical instruction. Also, nothing
; after the END instruction will be assembled.
;redcode
;name Dwarf
;author A. K. Dewdney
;strategy Throw DAT bombs around memory, hitting every 4th memory cell.
;strategy This program was presented in the first Corewar article.
;assert 1
bomb DAT #0
DAT #0
dwarf ADD #6, bomb
MOV bomb, @bomb
JMP dwarf, <bomb
END dwarf ; Programs start at the first line unless
; an "END start" pseudo-op appears to indicate
; the first logical instruction. Also, nothing
; after the END instruction will be assembled.
;redcode
;name Dwarf
;author A. K. Dewdney
;strategy Throw DAT bombs around memory, hitting every 4th memory cell.
;strategy This program was presented in the first Corewar article.
;assert 1
bomb DAT #0
DAT #0
dwarf ADD #7, bomb
MOV bomb, <bomb
JMP dwarf, <bomb
END dwarf ; Programs start at the first line unless
; an "END start" pseudo-op appears to indicate
; the first logical instruction. Also, nothing
; after the END instruction will be assembled.
;redcode
;name Dwarf
;author A. K. Dewdney
;strategy Throw DAT bombs around memory, hitting every 4th memory cell.
;strategy This program was presented in the first Corewar article.
;assert 1
dwarf MOV bomb, @bomb
ADD #-1, bomb
JMN dwarf, bomb
ADD #-6, bomb
JMP dwarf
bomb DAT #-6
END dwarf
;redcode
;name Dwarf
;author A. K. Dewdney
;strategy Throw DAT bombs around memory, hitting every 4th memory cell.
;strategy This program was presented in the first Corewar article.
;assert 1
bomb DAT #0
dwarf ADD #4, bomb
MOV bomb, @bomb
JMP dwarf
END dwarf ; Programs start at the first line unless
; an "END start" pseudo-op appears to indicate
; the first logical instruction. Also, nothing
; after the END instruction will be assembled.
;redcode
;name fini
;version (8.1990)
;author Bodo Müller
;assert 1
;+--------------------------------------------------------------------------+
;| FINI ( = Endstufe von PARALYSE) Version 1.0 by B.M. Aug. '90 |
;+--------------------------------------------------------------------------+
NUM DAT #-2
START MOV NUM, <POS
LOOP JMP START
POS DAT #-3
END START
;redcode
;name Dwarf
;author A. K. Dewdney
;strategy Throw DAT bombs around memory, hitting every 4th memory cell.
;strategy This program was presented in the first Corewar article.
;assert 1
bomb DAT #0
DAT #0
dwarf ADD #7, bomb
MOV knirps, <bomb
JMP dwarf, <bomb
knirps MOV 0, 1
END dwarf ; Programs start at the first line unless
; an "END start" pseudo-op appears to indicate
; the first logical instruction. Also, nothing
; after the END instruction will be assembled.
../common/logo-hochschule-bochum-cvh-text-v2.pdf
\ No newline at end of file
../common/logo-hochschule-bochum.pdf
\ No newline at end of file
../common/pgslides.sty
\ No newline at end of file
File added
% rtech-20230510.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: Assembler-Programmierung: Redcode (Fortsetzung)
\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{10.\ 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
\color{orange}
\item[3.2] Beispiel: Redcode
\item[\dots]
\end{itemize}
% \color{gray}
% \item[\textbf{3}] \textbf{Architekturmerkmale von Prozessoren}
% \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{9}] \textbf{Ausblick}
\item[\textbf{\dots\hspace{-0.75em}}]
\end{itemize}
\end{frame}
\setcounter{section}{2}
\section{Assembler-Programmierung}
\setcounter{subsection}{1}
\subsection{Beispiel: Redcode}
\begin{frame}[fragile]
\showsubsection
Beispiel: Redcode (ICWS '86) -- Core War[s] (Krieg der Kerne)\\
Virtuelle Maschine: Memory Array Redcode Simulator (MARS)
\bigskip
\begin{minipage}[t]{7.2cm}
Instruktionen:\\[\smallskipamount]
\lstinline{dat B} -- Daten \only<1->{-- "`Du hast verloren!"'}\\
\lstinline{mov A, B} -- kopiere A nach B\\
\lstinline{add A, B} -- addiere A zu B\\
\lstinline{sub A, B} -- subtrahiere A von B\\
\lstinline{jmp A} -- unbedingter Sprung nach A\\
\lstinline{jmz A, B} -- Sprung nach A, wenn B $=$ 0\\
\lstinline{jmn A, B} -- Sprung nach A, wenn B $\ne$ 0\\
\lstinline{djn A, B} -- "`decrement and jump if not zero"'\\
\lstinline{cmp A, B} -- "`compare"': überspringe, falls gleich\\
\lstinline{spl A} -- "`split"': Programm verzweigen
\end{minipage}\hfill
\begin{minipage}[t]{4.7cm}
Adressierungsarten:\\[\smallskipamount]
grundsätzlich: Speicher relativ\\[\smallskipamount]
\lstinline{#} -- unmittelbar\\
\lstinline{$} -- direkt\\
\lstinline{@} -- indirekt\\
\lstinline{<} -- indirekt mit Prä-Dekrement
% \pause[5]
\bigskip
Programm "`Nothing"':
\begin{lstlisting}[gobble=6]
jmp 0
\end{lstlisting}
% \pause
\bigskip
Programm "`Knirps"':
\begin{lstlisting}[gobble=6]
mov 0, 1
\end{lstlisting}
\smallskip
\textcolor{red}{Wie schreibt man\\knirpsresistente Programme?}
\end{minipage}
\end{frame}
\begin{frame}[fragile]
\showsubsection
Unbedingte Verzweigung
Beispiel: Endlosschleife von "`Dwarf"'
\begin{minipage}[t]{1.2cm}
\begin{lstlisting}[style=asm,gobble=6]
bomb
start
\end{lstlisting}
\end{minipage}%
\begin{minipage}[t]{3cm}
\begin{lstlisting}[style=asm,gobble=6]
dat #0
add #4, bomb
mov bomb, @bomb
jmp start
end start
\end{lstlisting}
\end{minipage}\hfill
\begin{minipage}[t]{3.9cm}
\small
\bigskip
Instruktionen:\\[\smallskipamount]
\lstinline{dat B}\\
\lstinline{mov A, B}\\
\lstinline{add A, B}\\
\lstinline{sub A, B}\\
\lstinline{jmp A}\\
\lstinline{jmz A, B} -- "`jump if zero"'\\
\lstinline{jmn A, B} -- "`if not zero"'\\
\lstinline{djn A, B} -- "`dec. \& jmn"'\\
\lstinline{cmp A, B} -- vgl.\ \& überspr.\\
\lstinline{spl A} -- verzweigen
\end{minipage}%
\begin{minipage}[t]{2.7cm}
\small
\bigskip
Adressierungsarten:\\[\medskipamount]
grundsätzlich:\\
Speicher relativ\\[\medskipamount]
\lstinline{#} -- unmittelbar\\[\smallskipamount]
\lstinline{$} -- direkt\\[\smallskipamount]
\lstinline{@} -- indirekt\\[\smallskipamount]
\lstinline{<} -- indirekt mit\\
\hspace*{0.52cm}Prä-Decrement
\end{minipage}
% \pause
\bigskip
Problem: Wenn die Speichergröße nicht durch 4 teilbar ist,\\
\phantom{Problem: }bringt "`Dwarf"' sich selbst zum Absturz.\\[\smallskipamount]
% \pause
Lösung: \textcolor{red}{Haben Sie Ideen?}
\textcolor{red}{\textarrow\ Übungsaufgabe}
\end{frame}
\begin{frame}[fragile]
\showsubsection
\alt<2->{Mehrere Threads}{Bedingte Verzweigung}
Beispiel: \alt<2->{Multithreading}{Kopierschleife} von "`Mice"'
\begin{minipage}[t]{1.2cm}
\begin{lstlisting}[style=asm,gobble=6]
ptr
start
loop
dest
\end{lstlisting}
\end{minipage}%
\begin{minipage}[t]{3cm}
\begin{lstlisting}[style=asm,gobble=6]
dat #0
mov #12, ptr
mov @ptr, <dest
djn loop, ptr
spl @dest
add #653, dest
jmz start, ptr
dat #833
end start
\end{lstlisting}
\end{minipage}\hfill
\begin{minipage}[t]{3.9cm}
\small
\bigskip
Instruktionen:\\[\smallskipamount]
\lstinline{dat B}\\
\lstinline{mov A, B}\\
\lstinline{add A, B}\\
\lstinline{sub A, B}\\
\lstinline{jmp A}\\
\lstinline{jmz A, B} -- "`jump if zero"'\\
\lstinline{jmn A, B} -- "`if not zero"'\\
\lstinline{djn A, B} -- "`dec. \& jmn"'\\
\lstinline{cmp A, B} -- vgl.\ \& überspr.\\
\lstinline{spl A} -- verzweigen
\end{minipage}%
\begin{minipage}[t]{2.7cm}
\small
\bigskip
Adressierungsarten:\\[\medskipamount]
grundsätzlich:\\
Speicher relativ\\[\medskipamount]
\lstinline{#} -- unmittelbar\\[\smallskipamount]
\lstinline{$} -- direkt\\[\smallskipamount]
\lstinline{@} -- indirekt\\[\smallskipamount]
\lstinline{<} -- indirekt mit\\
\hspace*{0.52cm}Prä-Decrement
\end{minipage}
\pause[3]
\bigskip
Gegenmaßnahme: "`Zeitfalle"'\\
\textarrow\ Programm "`Catcan"'
% \smallskip
%
% Problem: Wenn die Speichergröße nicht durch 8 teilbar ist,\\
% \phantom{Problem: }bringt "`Catcan"' sich selbst zum Absturz.
\end{frame}
\begin{frame}[fragile]
\showsubsection
Selbstmodifizierender Code
Beispiel: Selbsterkennung von "`Fini"'
\begin{minipage}[t]{1.2cm}
\begin{lstlisting}[language={},gobble=6]
num
start
pos
\end{lstlisting}
\end{minipage}%
\begin{minipage}[t]{0.9cm}
\begin{lstlisting}[language={},gobble=6]
dat #-2
mov num, <pos
jmp start
dat #-3
end start
\end{lstlisting}
\end{minipage}\hfill
\begin{minipage}[t]{3.9cm}
\small
\bigskip
Instruktionen:\\[\smallskipamount]
\lstinline{dat B}\\
\lstinline{mov A, B}\\
\lstinline{add A, B}\\
\lstinline{sub A, B}\\
\lstinline{jmp A}\\
\lstinline{jmz A, B} -- "`jump if zero"'\\
\lstinline{jmn A, B} -- "`if not zero"'\\
\lstinline{djn A, B} -- "`dec. \& jmn"'\\
\lstinline{cmp A, B} -- vgl.\ \& überspr.\\
\lstinline{spl A} -- verzweigen
\end{minipage}%
\begin{minipage}[t]{2.7cm}
\small
\bigskip
Adressierungsarten:\\[\medskipamount]
grundsätzlich:\\
Speicher relativ\\[\medskipamount]
\lstinline{#} -- unmittelbar\\[\smallskipamount]
\lstinline{$} -- direkt\\[\smallskipamount]
\lstinline{@} -- indirekt\\[\smallskipamount]
\lstinline{<} -- indirekt mit\\
\hspace*{0.52cm}Prä-Decrement
\end{minipage}
\end{frame}
\begin{frame}[fragile]
\showsubsection
\strut
\strut\makebox(0,0)[bl]{\large\color{structure}\textbf{Praktikumsversuch}}
\begin{minipage}[t]{5cm}
\medskip
Schreiben Sie ein\\
Redcode-Programm,\\
das die Gegner\\
\file{Nothing}, \file{Knirps}\\
und \file{Mice} besiegt.
\medskip
ICWS-86-Standard,\\
max.\ 64 Prozesse,\\
Speichergröße zufällig\\
von 512 bis 8192
\medskip
Teams bis zu 3 Personen\\
sind zulässig.
\end{minipage}\hfill
\begin{minipage}[t]{3.9cm}
\small
\bigskip
Instruktionen:\\[\smallskipamount]
\lstinline{dat B}\\
\lstinline{mov A, B}\\
\lstinline{add A, B}\\
\lstinline{sub A, B}\\
\lstinline{jmp A}\\
\lstinline{jmz A, B} -- "`jump if zero"'\\
\lstinline{jmn A, B} -- "`if not zero"'\\
\lstinline{djn A, B} -- "`dec. \& jmn"'\\
\lstinline{cmp A, B} -- vgl.\ \& überspr.\\
\lstinline{spl A} -- verzweigen
\end{minipage}%
\begin{minipage}[t]{2.7cm}
\small
\bigskip
Adressierungsarten:\\[\medskipamount]
grundsätzlich:\\
Speicher relativ\\[\medskipamount]
\lstinline{#} -- unmittelbar\\[\smallskipamount]
\lstinline{$} -- direkt\\[\smallskipamount]
\lstinline{@} -- indirekt\\[\smallskipamount]
\lstinline{<} -- indirekt mit\\
\hspace*{0.52cm}Prä-Decrement
\end{minipage}
\end{frame}
\end{document}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment