Skip to content

Commit

Permalink
describe the nop instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
Mesabloo committed Jan 8, 2021
1 parent 8169362 commit 83813d6
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 29 deletions.
29 changes: 28 additions & 1 deletion part2-nstar.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ \section{\texttt{ret}}\label{sec:nstar-instructionset-ret}
\label{fig:nstar-instructionset-ret-typerules}
\end{figure}
\section{\texttt{push}}\label{fig:nstar-instructionset-push}
\section{\texttt{push}}\label{sec:nstar-instructionset-push}
The \texttt{push} instruction inserts sized data on top of the stack.
Grammar for it is given in Figure~\ref{fig:nstar-instructionset-push-grammar} and inference rules are given in Figure~\ref{fig:nstar-instructionset-push-typerules}.
Expand Down Expand Up @@ -1095,6 +1095,33 @@ \section{\texttt{push}}\label{fig:nstar-instructionset-push}
\label{fig:nstar-instructionset-push-typerules}
\end{figure}
\section{\texttt{nop}}\label{sec:nstar-instructionset-nop}
The \texttt{nop} instruction does absolutely nothing else than skipping a CPU cycle.
Grammar and type inference rules are respectively given in Figure~\ref{fig:nstar-instructionset-nop-grammar} and Figure~\ref{fig:nstar-instructionset-nop-typerules}.
\begin{figure}[H]
\centering
\scalebox{.5}{
\includegraphics{nstar/instructions/nop-grammar}
}
\caption{Grammar for the \texttt{nop} instruction.}
\label{fig:nstar-instructionset-nop-grammar}
\end{figure}
\begin{figure}[H]
\centering
\begin{prooftree}
\infer0{\Delta,\Xi\vdash^I$ nop $\dashv\Delta}
\end{prooftree}
\caption{Type inference rules for the \texttt{nop} instruction.}
\label{fig:nstar-instructionset-nop-typerules}
\end{figure}
\chapter{Target-dependent features}\label{chap:nstar-specific}
\section{x86, amd64}\label{sec:nstar-specific-x86amd64}
Expand Down
63 changes: 35 additions & 28 deletions railroad-diagrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,39 +36,46 @@ def mk_diagram(name, nodes):

def character_immediate():
inner = Sequence(
Terminal("'"),
Choice(
1,
Sequence(
Terminal('\\'),
Terminal("'"),
Choice(
1,
Sequence(
Terminal('x'),
NonTerminal('hex-digit'),
NonTerminal('hex-digit')
),
HorizontalChoice(
Terminal('n'),
Terminal('r'),
Terminal('\\'),
Terminal('0')
),
HorizontalChoice(
Terminal('t'),
Terminal('v'),
Terminal('e')
),
)
),
NonTerminal('ascii-character')
),
Terminal("'")
1,
Sequence(
Terminal('\\'),
Choice(
1,
Sequence(
Terminal('x'),
NonTerminal('hex-digit'),
NonTerminal('hex-digit')
),
HorizontalChoice(
Terminal('n'),
Terminal('r'),
Terminal('\\'),
Terminal('0')
),
HorizontalChoice(
Terminal('t'),
Terminal('v'),
Terminal('e')
),
)
),
NonTerminal('ascii-character')
),
Terminal("'")
)

return mk_diagram('character-immediate', inner)

def character_constant():
return character_immediate()

character_immediate().writeSvg(sys.stdout.write)
def nop_instruction():
inner = Sequence(
Terminal('nop')
)

return mk_diagram('nop-instruction', inner)

nop_instruction().writeSvg(sys.stdout.write)
Binary file added res/nstar/instructions/nop-grammar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 83813d6

Please sign in to comment.