1 \section{Calling Convention}
3 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.
7 \begin{tabular}{|c|c|c|} \hline
8 \textbf{register} & \textbf{saved by} & \textbf{usage} \\ \hline
9 r0 & caller & return \\ \hline
10 r1 & caller & first parameter \\ \hline
11 r2 & caller & second parameter \\ \hline
12 r3 & caller & third parameter \\ \hline
13 r4 & caller & fourth parameter \\ \hline
14 r5 & caller & fifth parameter \\ \hline
15 r6 & caller & \\ \hline
16 r7 & caller & \\ \hline
17 r8 & caller & \\ \hline
18 r9 & caller & \\ \hline
19 r10 & callee & \\ \hline
20 r11 & callee & \\ \hline
21 r12 & callee & \\ \hline
22 r13 & callee & \\ \hline
23 r14 & callee & \\ \hline
24 r15 & callee & \\ \hline
26 \caption{Calling Convention}
30 \subsection{Assembler Syntax}
32 \item \textbf{Immediate s}: decimal \texttt{12345}, hex \texttt{0xabcde123},
33 binary \texttt{0b10101110}\\
34 If an immediate is to large for the given instruction the assembler terminates
37 \item \textbf{High and Low Half Word}: you can use the suffix \texttt{@hi} to
38 access the upper 16 bit of an immediate, or \texttt{@lo} to access the lower 16
41 \item \textbf{Memory access}: to access data on an address which is located in a
42 register, you have to write \texttt{0(rS)}. Alternatively you can specify
43 a signed displacement.
45 \item \textbf{Expressions}: Usual expressions like \texttt{+}, \texttt{-},
46 \texttt{*} or \texttt{<<} will be evaluated by the assembler, e.g. \texttt{ldw
47 r1, 0x20-8(r3)} is a valid instruction
50 \subsection{Directives}
51 In order to gain extra comfort, several directives are interpreted by the
52 assembler, a list is given in table~\ref{tab:asmdirs}.
55 \begin{tabular}{|l|p{10cm}|} \hline
56 \textbf{Name} & \textbf{Description} \\ \hline
57 \texttt{.data} & subsequent data is desired for the data memory\\ \hline
58 \texttt{.text} & subsequent code is desired for the instruction memory\\ \hline
59 \verb+.include "file.s"+ & include a further file \\ \hline
60 \texttt{.org \textit{addr}} & move \textit{forward} to a specific
61 address in data or instruction memory, depending on the current
64 \texttt{.fill \textit{repeat}, \textit{value}} & place a
65 32 bit value \texttt{\textit{repeat}}-times, while
66 \texttt{\textit{repeat}} is optional.
68 When one parameter is given, the value is placed at the current address.
69 Note that a given value will be rounded up to a full byte, e.g.
70 \texttt{0x123} occupy two bytes.
72 When two parameters are given, the first equals \texttt{\textit{repeat}}
73 and the second corresponds to \texttt{\textit{value}} \\ \hline
75 \texttt{.define \textit{name}, \textit{value}} & define a constant. Note
76 that a define isn't equal to a label\\ \hline
78 \texttt{label: <instr/data>} & label an instruction or data. The label
79 can be used as an alias for the address of this instruction in the
80 instruction memory or as a reference in the data memory, depending on
81 the current section\\ \hline
83 \caption{supported directives by the assembler}