Mercurial > pub > dyncall > dyncall
changeset 98:db0b2f19e165
- MIPS o32 manual appendix
- todo update for future manual work
author | cslag |
---|---|
date | Sat, 04 Jun 2016 21:42:40 +0200 |
parents | d0787f3b81fb |
children | 7aab1a3cb172 |
files | ToDo doc/manual/callconvs/callconv_mips.tex doc/manual/manual_literature.tex |
diffstat | 3 files changed, 88 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/ToDo Sat Jun 04 19:35:58 2016 +0200 +++ b/ToDo Sat Jun 04 21:42:40 2016 +0200 @@ -86,8 +86,11 @@ manual: ------- -- fix up all the callconv diagrams - the brackets seem to not match the row height, and are sometimes - completely off... good idea to review it all, anyways, fix up the frames (from fp to sp), etc. +- callconv diagrams + * for html output, the brackets are completely off... doesn't happen for pdf + output, which is weird + * good idea to review it all, anyways, if the calling conventions are actually + represented correctly - provide more examples on how to use dyncall, dynload and dyncallback * e.g. enhance manual with a couple of examples (e.g. calling MessageBoxA on windows, etc.) - manuals for bindings (as stated in bindings-section, above)
--- a/doc/manual/callconvs/callconv_mips.tex Sat Jun 04 19:35:58 2016 +0200 +++ b/doc/manual/callconvs/callconv_mips.tex Sat Jun 04 21:42:40 2016 +0200 @@ -34,7 +34,7 @@ \end{description} Unfortunately, there is actually no such thing as "The MIPS Calling Convention". Many possible conventions are used -by many different environments such as \emph{O32}, \emph{O64}, \emph{N32}, \emph{N64} and \emph{EABI}.\\ +by many different environments such as \emph{O32}\cite{MIPSo32}, \emph{O64}, \emph{N32}, \emph{N64} and \emph{EABI}.\\ \paragraph{\product{dyncall} support} @@ -66,12 +66,13 @@ {\bf \$f1,\$f3,\$f4-\$f11,\$f20-\$f23} & & Float temporaries \\ {\bf \$f12-\$f19} & & Float arguments \\ \end{tabular*} -\caption{Register usage on mips32 eabi calling convention} +\caption{Register usage on MIPS32 EABI calling convention} \end{table} \paragraph{Parameter passing} \begin{itemize} +\item Stack grows down \item Stack parameter order: right-to-left \item Caller cleans up the stack \item Stack always aligned to 8 bytes. @@ -79,7 +80,7 @@ \item if either integer or float registers are consumed up, the stack is used. \item 64-bit floats and integers are passed on two integer registers starting at an even register number, probably skipping one odd register. \item \$a0-\$a7 and \$f12-\$f19 are not required to be preserved. -\item results are returned in \$v0 (32-bit integer), \$v0 and \$v1 (64-bit integer/float), \$f0 (32 bit float) and \$f0 and \$f2 (2 $\times$ 32 bit float e.g. complex). +\item results are returned in \$v0 (32-bit), \$v0 and \$v1 (64-bit), \$f0 (32 bit float) and \$f0 and \$f2 (2 $\times$ 32 bit float e.g. complex). \end{itemize} \paragraph{Stack layout} @@ -108,15 +109,86 @@ & \vdots & & \\ \hhline{~-~~} \end{tabular} -\\ -\\ -\\ \caption{Stack layout on mips32 eabi calling convention} \end{figure} +\newpage + \subsubsection{MIPS O32 32-bit Calling Convention} -@@@ +\paragraph{Register usage} + +\begin{table}[h] +\begin{tabular*}{0.95\textwidth}{lll} +Name & Alias & Brief description\\ +\hline +{\bf \$0} & {\bf \$zero} & Hardware zero \\ +{\bf \$1} & {\bf \$at} & Assembler temporary \\ +{\bf \$2-\$3} & {\bf \$v0-\$v1} & Integer results, scratch \\ +{\bf \$4-\$7} & {\bf \$a0-\$a3} & Integer arguments, scratch\\ +{\bf \$8-\$15,\$24,\$25} & {\bf \$t0-\$t7,\$t8,\$t9} & Integer temporaries, scratch \\ +{\bf \$16-\$23} & {\bf \$s0-\$s7} & Preserved \\ +{\bf \$26,\$27} & {\bf \$k0,\$k1} & Reserved for kernel \\ +{\bf \$28} & {\bf \$gp} & Global pointer, preserve \\ +{\bf \$29} & {\bf \$sp} & Stack pointer, preserve \\ +{\bf \$30} & {\bf \$fp} & Frame pointer, preserve \\ +{\bf \$31} & {\bf \$ra} & Return address \\ + + +\end{tabular*} +\caption{Register usage on MIPS O32 calling convention} +\end{table} + +\paragraph{Parameter passing} + +\begin{itemize} +\item Stack grows down +\item Stack parameter order: right-to-left +\item Caller cleans up the stack +\item The different stack areas (e.g. parameter area, register save area, ...) are always aligned to 8 bytes. +\item first 4 32bit arguments are passed in registers \$a0-\$a3, respectively +\item subsequent parameters are passed vie the stack +\item @@@unsure... 64-bit floats and integers are passed on two integer registers starting at an even register number, probably skipping one odd register. +\item results are returned in \$v0 (32-bit integer), \$v0 and \$v1 (64-bit integer/float) +\item note that only the first s0-s? preserved registers that are modified by the function need to be put on the save area +\end{itemize} + +\paragraph{Stack layout} + +Stack directly after function prolog:\\ + +\begin{figure}[h] +\begin{tabular}{5|3|1 1} +\hhline{~-~~} + & \vdots & & \\ +\hhline{~=~~} +local data & \hspace{4cm} & & \mrrbrace{12}{caller's frame} \\ +\hhline{~-~~} +register save area & return address & & \\ + & s7 & & \\ + & \vdots & & \\ + & s0 & & \\ +\hhline{~-~~} +\mrlbrace{7}{parameter area} & \ldots & \mrrbrace{3}{stack parameters} & \\ + & \ldots & & \\ + & \ldots & & \\ + & a3 & \mrrbrace{4}{spill area} & \\ + & a2 & & \\ + & a1 & & \\ + & a0 & & \\ +\hhline{~=~~} +local data & & & \mrrbrace{5}{current frame} \\ +\hhline{~-~~} +register save area (with return address) & & & \\ +\hhline{~-~~} +parameter area & & & \\ + & \vdots & & \\ +\hhline{~-~~} +\end{tabular} +\caption{Stack layout on MIPS O32 calling convention} +\end{figure} + +\newpage \subsubsection{MIPS N32 32-bit Calling Convention}
--- a/doc/manual/manual_literature.tex Sat Jun 04 19:35:58 2016 +0200 +++ b/doc/manual/manual_literature.tex Sat Jun 04 21:42:40 2016 +0200 @@ -154,6 +154,10 @@ 64-bit PowerPC ELF Application Binary Interface Supplement 1.9\\ \url{http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html} +\bibitem{MIPSo32} + MIPS Calling Conventions Summary\\ + \url{http://courses.cs.washington.edu/courses/cse410/09sp/examples/MIPSCallingConventionsSummary.pdf} + \bibitem{devkitPro} devkitPro - homebrew game development\\ \url{http://www.devkitpro.org/}