1
0
mirror of synced 2024-11-21 20:44:23 +01:00

More documentation

This commit is contained in:
Christian Dietrich 2014-10-09 18:15:27 +02:00
parent a1ef38622f
commit ce17612146
5 changed files with 90 additions and 6 deletions

View File

@ -1,6 +1,6 @@
export TEXINPUTS := $(shell pwd)//:${TEXINPUTS} export TEXINPUTS := $(shell pwd)//:${TEXINPUTS}
doc: source/avremu.pdf:
cd source; latexmk -pdf -shell-escape avremu cd source; latexmk -pdf -shell-escape avremu
test: test-simple test: test-simple
@ -12,4 +12,24 @@ test-simple: source/simple-testsuite.tex
test-%: source/test-suite/%.c test-%: source/test-suite/%.c
cd source/test-suite; ./test-suite single $(shell basename $<) cd source/test-suite; ./test-suite single $(shell basename $<)
.PHONY: test-simple doc avremu.zip: source/avremu.pdf
rm -rf avremu avremu.zip
mkdir avremu
# TeX Directory
mkdir -p avremu/tex/latex/avremu
cp tex/latex/avremu/*.tex avremu/tex/latex/avremu
cp tex/latex/avremu/*.sty avremu/tex/latex/avremu
# Source directory
mkdir -p avremu/source/latex/avremu
cp -r imgs avremu/source/latex/avremu
mkdir -p avremu/source/latex/avremu/test-suite
cp source/test-suite/*.c avremu/source/latex/avremu/test-suite
cp source/simple-testsuite.tex avremu/source/latex/avremu/
# Documenation directory
mkdir -p avremu/doc/latex/avremu
cp source/avremu.pdf avremu/doc/latex/avremu
zip -r avremu.zip avremu
rm -rf avremu
.PHONY: test-simple source/avremu.pdf avremu.zip

View File

@ -9,7 +9,7 @@ programming language. TeX can compute anything, that is
computable. Computeability is a concept from theoretical computer computable. Computeability is a concept from theoretical computer
science. After visiting a theoretical CS course, you will know that science. After visiting a theoretical CS course, you will know that
there are things that cannot be solved by a machine. Never. Look out there are things that cannot be solved by a machine. Never. Look out
for the halting machine. So, Turing-complete does not say "It's a for the halting problem. So, Turing-complete does not say "It's a
proper programming language", but more "someone can write a proper proper programming language", but more "someone can write a proper
interpreter for any programming language in it, theoretically". interpreter for any programming language in it, theoretically".
@ -28,6 +28,8 @@ future, if you start this. But, we can use a normal C compiler to
compile the C code to some simple platform. Like AVR[4]. Since I have compile the C code to some simple platform. Like AVR[4]. Since I have
other things to do than writing an AVR Emulator in TeX, here it is! other things to do than writing an AVR Emulator in TeX, here it is!
The newest source can be found at https://gitlab.brokenpipe.de/stettberger/avr_tex.
## You are writing an CPU emulator in TeX, the TYPESETTING system? ## ## You are writing an CPU emulator in TeX, the TYPESETTING system? ##
Yep. Yep.

View File

@ -4,6 +4,13 @@
\usepackage{hyperref} \usepackage{hyperref}
\usepackage{filecontents} \usepackage{filecontents}
\usepackage{tcolorbox} \usepackage{tcolorbox}
\usepackage{ydoc}
\makeatletter
\def\cmd#1{\cs{\expandafter\cmd@to@cs\string#1}}
\def\cmd@to@cs#1#2{\char\number`#2\relax}
\DeclareRobustCommand\cs[1]{\texttt{\char`\\#1}}
\makeatother
\begin{filecontents*}{hello-world.c} \begin{filecontents*}{hello-world.c}
#include <avr/io.h> #include <avr/io.h>
@ -22,7 +29,8 @@ main(void)
\title{The \texttt{avremu} Package} \title{The \texttt{avremu} Package}
\author{Christian Dietrich\\ \author{Christian Dietrich\\
\url{stettberger@dokucode.de}} \url{stettberger@dokucode.de}\\
\url{https://gitlab.brokenpipe.de/stettberger/avr_tex}}
\begin{document} \begin{document}
@ -42,6 +50,60 @@ UDR='\avrUDR' in \avrinstrcount\ instructions
UDR='\avrUDR' in \avrinstrcount\ instructions UDR='\avrUDR' in \avrinstrcount\ instructions
\end{tcolorbox} \end{tcolorbox}
\LaTeX\ is known as a typesetting system. But the underlying \TeX\ system is a powerful macro
processor. In fact, TeX is a Turing-complete programming language. \TeX\ can compute anything that
is computable. Computeability is a concept from theoretical computer science. After visiting a
theoretical computer-science course, you will know that there are things that cannot be solved by a
machine. Never. Look out for the halting problem.
This package does contain an \emph{CPU emulator} for the 8-bit microcontroller platform Atmel AVR, more
precisely it implements the instruction-set architecture of the \texttt{ATmega8}.
\section{Provided Commands}
\DescribeMacro{\avrloadihex}{\meta{filename}}
Load an Intel HEX formatted image of the flash into the code memory of the AVR
emulator. Additionally the state of the AVR emulator is set back to zero.
\DescribeMacro{\avrloadc}[\meta{compiler options}]{\meta{filename}}
Requires \verb|--shell-escape|. Compiles C source code file with \verb|avr-gcc| and the given
compiler options. The default compiler option set is \verb|-mmcu=atmega8 -Os|. The resulting
\texttt{.elf} file is transformed to an Intel HEX file and loaded into the code memory of the
emulator.
\DescribeMacro{\avrrun}
Run the emulator until a \textbf{break} instruction occurs.
\DescribeMacro{\avrstep}[\meta{steps}=1]
Run the emulator for N instructions. The default is a single step. The stepping does automatically
end, if a \textbf{break} instruction is executed.
\DescribeMacro{\avrinstrcount}
Expands to the number of executed instructions.
\DescribeMacro{\avrsinglestep}
Starts an interactive single-stepping mode, which was mainly used for implementing the emulator.
\DescribeMacro{\usravremulibrary}{\meta{list of libraryies}}
\subsection{Access to the Serial Console}
If the program write to the \verb|UDR| IO register, the emulator catched those characters in an
internal buffer.
\DescribeMacro{\avrUDR}
Expands to the internal UDR buffer.
\DescribeMacro{\avrUDRclear}
Clears the internal UDR buffer.
\subsection{Draw Library}
\DescribeMacro{\useavremulibrary}{avr.draw}
See source/test-suite/mandelbrot.c for more details.
\section{Implementation Details}
Read the source.
\end{document} \end{document}
%%% Local Variables: %%% Local Variables:

View File

@ -1,5 +1,5 @@
\documentclass{article} \documentclass{article}
\usepackage{avremu} \usepackage[debug]{avremu}
\begin{document} \begin{document}
\makeatletter \makeatletter

View File

@ -1,7 +1,7 @@
\documentclass{article} \documentclass{article}
\usepackage{graphicx} \usepackage{graphicx}
\usepackage{avremu} \usepackage[debug]{avremu}
\useavremulibrary{avr.draw} \useavremulibrary{avr.draw}
\errorcontextlines=23 \errorcontextlines=23