| 1 |
\section{Assemblers} |
| 2 |
|
| 3 |
\subsubsection{Overview} |
| 4 |
Assemblers in MLRISC satisfy the signature |
| 5 |
\mlrischref{emit/instruction-emitter.sig}{INSTRUCTION\_EMITTER}, |
| 6 |
which is defined as: |
| 7 |
\begin{SML} |
| 8 |
signature INSTRUCTION_EMITTER = |
| 9 |
sig |
| 10 |
structure I : \href{instructions.html}{INSTRUCTIONS} |
| 11 |
structure C : \href{cells.html}{CELLS} |
| 12 |
structure S : \href{streams.html}{INSTRUCTION_STREAM} |
| 13 |
structure P : \href{pseudo-ops.html}{PSEUDO_OPS} |
| 14 |
sharing I.C = C |
| 15 |
sharing S.P = P |
| 16 |
|
| 17 |
val makeStream : Annotations.annotations -> |
| 18 |
((int -> int) -> I.instruction -> unit, |
| 19 |
unit,'b,'c,'d,'e) S.stream |
| 20 |
end |
| 21 |
\end{SML} |
| 22 |
|
| 23 |
The function \sml{makeStream} returns an instruction stream. |
| 24 |
By default the output is bound to the stream \sml{AsmStream.asmOutStream} |
| 25 |
defined in the structure |
| 26 |
\mlrischref{emit/asmStream.sml}{AsmStream} at creation time. |
| 27 |
|
| 28 |
The structure \sml{AsmStream} satisfy the following signature. |
| 29 |
\begin{SML} |
| 30 |
signature ASM_STREAM = sig |
| 31 |
val asmOutStream : TextIO.outstream ref |
| 32 |
val withStream : TextIO.outstream -> ('a -> 'b) -> 'a -> 'b |
| 33 |
end |
| 34 |
\end{SML} |
| 35 |
\subsubsection{Redirecting the Output} |
| 36 |
It is possible to redirect the output of an instruction stream. |
| 37 |
For example, the following statement |
| 38 |
\begin{SML} |
| 39 |
val asm = makeStream [] |
| 40 |
\end{SML} |
| 41 |
binds the output of \sml{asm} to \sml{AsmStream.asmOutStream}, which |
| 42 |
by default is just \sml{TextIO.stdOut}. On the other hand, the |
| 43 |
statement |
| 44 |
\begin{SML} |
| 45 |
val asm = AsmStream.withStream mystream makeStream [] |
| 46 |
\end{SML} |
| 47 |
binds the output of asm to \sml{mystream}. |
| 48 |
|
| 49 |
\subsubsection{More Details} |
| 50 |
|
| 51 |
Assemblers are automatically generated by the |
| 52 |
\href{mlrisc-md.html}{MDGen} tool. Some specific generated |
| 53 |
assemblers are listed below: |
| 54 |
\begin{enumerate} |
| 55 |
\item \mlrischref{sparc/emit/sparcAsm.sml}{Sparc} |
| 56 |
\item \mlrischref{hppa/emit/hppaAsm.sml}{Hppa} |
| 57 |
\item \mlrischref{alpha/emit/alphaAsm.sml}{Alpha} |
| 58 |
\item \mlrischref{ppc/emit/ppcAsm.sml}{Power PC} |
| 59 |
\item \mlrischref{x86/emit/x86Asm.sml}{X86} |
| 60 |
\end{enumerate} |