progs/sum: reducing code size
[calu.git] / 2_isa / callingconv.tex
index ade1f8262783999ffa4d6b0ba186f7bb4ba7c26d..951ef0beec7fc9a4288017aa7eb4e7057c36cbcc 100644 (file)
@@ -1,9 +1,11 @@
-\section{calling convention}
+\section{Calling Convention}
+
+Programs and functions implementing this instruction set, should implement the following calling conventions. The register usage should be done as stated in table~\ref{tab:callcon}. If the callee should be given more than five parameters, other parameters should be passed over by the stack.
 
 \begin{table}[ht]
        \centering
        \begin{tabular}{|c|c|c|} \hline
-               Register & saved by & usage  \\ \hline
+               \textbf{register} & \textbf{saved by} & \textbf{usage} \\ \hline
                r0       & caller   & return \\ \hline
                r1       & caller   & first parameter \\ \hline
                r2       & caller   & second parameter \\ \hline
                r14      & callee   & \\ \hline
                r15      & callee   & \\ \hline
        \end{tabular}
-       \caption{Register save \ldots}
-%      \label{tab:<+label+>}
+       \caption{Calling Convention}
+       \label{tab:callcon}
 \end{table}
 
-\subsection{Assembler Syntax}
+\subsection{Assembler  Syntax}
 \begin{itemize}
-\item \textbf{Immediates}: decimal \texttt{12345}, hex \texttt{0xabcde123},
+\item \textbf{Immediate s}: decimal \texttt{12345}, hex \texttt{0xabcde123},
 binary \texttt{0b10101110}\\
 If an immediate is to large for the given instruction the assembler terminates
 with an error
@@ -45,26 +47,40 @@ a signed displacement.
 r1, 0x20-8(r3)} is a valid instruction
 \end{itemize}
 
-\subsubsection{Directives}
+\subsection{Directives}
 In order to gain extra comfort, several directives are interpreted by the
-assembler:
+assembler, a list is given in table~\ref{tab:asmdirs}.
 \begin{table}[ht]
        \centering
        \begin{tabular}{|l|p{10cm}|} \hline
-               Name & Description \\ \hline
+               \textbf{Name} & \textbf{Description} \\ \hline
                \texttt{.data} & subsequent data is desired for the data memory\\ \hline
                \texttt{.text} & subsequent code is desired for the instruction memory\\ \hline
                \verb+.include "file.s"+ & include a further file \\ \hline
-               \texttt{.define <name> <value>} & define a constant. Note that a define
-               isn't equal to a label\\ \hline
+               \texttt{.org \textit{addr}} & move \textit{forward} to a specific
+               address in data or instruction memory, depending on the current
+               section \\ \hline
+
+               \texttt{.fill \textit{repeat}, \textit{value}} & place a
+               32 bit value \texttt{\textit{repeat}}-times, while
+               \texttt{\textit{repeat}} is optional.
+
+               When one parameter is given, the value is placed at the current address.
+               Note that a given value will be rounded up to a full byte, e.g.
+               \texttt{0x123} occupy two bytes.
+
+               When two parameters are given, the first equals \texttt{\textit{repeat}}
+               and the second corresponds to \texttt{\textit{value}} \\ \hline
+
+               \texttt{.define \textit{name}, \textit{value}} & define a constant. Note
+               that a define isn't equal to a label\\ \hline
+
                \texttt{label: <instr/data>} & label an instruction or data. The label
                can be used as an alias for the address of this instruction in the
                instruction memory or as a reference in the data memory, depending on
                the current section\\ \hline
-               %TODO: those are maybe handy: .fill(
-               %http://www.myri.com/scs/L3/doc/as_7.html#SEC85)
        \end{tabular}
        \caption{supported directives by the assembler}
-%      \label{tab:<+label+>}
+       \label{tab:asmdirs}
 \end{table}