mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
GP-2480 Console mode inst_next2 support and documentation update
This commit is contained in:
parent
8d4a6c213e
commit
d33cd8a92e
23 changed files with 348 additions and 275 deletions
|
@ -4,7 +4,7 @@
|
|||
<title>7. Constructors</title>
|
||||
<link rel="stylesheet" type="text/css" href="Frontpage.css">
|
||||
<link rel="stylesheet" type="text/css" href="languages.css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<link rel="home" href="sleigh.html" title="SLEIGH">
|
||||
<link rel="up" href="sleigh.html" title="SLEIGH">
|
||||
<link rel="prev" href="sleigh_tokens.html" title="6. Tokens and Fields">
|
||||
|
@ -60,7 +60,7 @@ multiple constructors into a single table are addressed in <a class="xref" href=
|
|||
</p>
|
||||
<div class="sect2">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="idm140526920750848"></a>7.1. The Five Sections of a Constructor</h3></div></div></div>
|
||||
<a name="sleigh_sections_constructor"></a>7.1. The Five Sections of a Constructor</h3></div></div></div>
|
||||
<p>
|
||||
A single complex statement in the specification file describes a
|
||||
constructor. This statement is always made up of five distinct
|
||||
|
@ -92,7 +92,7 @@ in turn.
|
|||
</div>
|
||||
<div class="sect2">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="idm140526920746272"></a>7.2. The Table Header</h3></div></div></div>
|
||||
<a name="sleigh_table_header"></a>7.2. The Table Header</h3></div></div></div>
|
||||
<p>
|
||||
Every constructor must be part of a table, which is the element with
|
||||
an actual family symbol identifier associated with it. So each
|
||||
|
@ -230,7 +230,7 @@ no such requirement.
|
|||
</div>
|
||||
<div class="sect3">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="idm140526920716688"></a>7.3.2. The '^' character</h4></div></div></div>
|
||||
<a name="sleigh_caret"></a>7.3.2. The '^' character</h4></div></div></div>
|
||||
<p>
|
||||
The ‘^’ character in the display section is used to separate
|
||||
identifiers from other characters where there shouldn’t be white space
|
||||
|
@ -278,7 +278,7 @@ to <span class="emphasis"><em>match</em></span> the constructor being defined.
|
|||
</p>
|
||||
<div class="sect3">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="idm140526920705248"></a>7.4.1. Constraints</h4></div></div></div>
|
||||
<a name="sleigh_constraints"></a>7.4.1. Constraints</h4></div></div></div>
|
||||
<p>
|
||||
The patterns required for processor specifications can almost always
|
||||
be described as a mask and value pair. Given a specific instruction
|
||||
|
@ -337,7 +337,7 @@ requires two or more mask/value style checks to correctly implement.
|
|||
</div>
|
||||
<div class="sect3">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="idm140526920691312"></a>7.4.3. Defining Operands and Invoking Subtables</h4></div></div></div>
|
||||
<a name="sleigh_defining_operands"></a>7.4.3. Defining Operands and Invoking Subtables</h4></div></div></div>
|
||||
<p>
|
||||
The principle way of defining a constructor operand, left undefined
|
||||
from the display section, is done in the bit pattern section. If an
|
||||
|
@ -396,7 +396,7 @@ statement of the grouping of old symbols into the new constructor.
|
|||
</div>
|
||||
<div class="sect3">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="idm140526920679904"></a>7.4.4. Variable Length Instructions</h4></div></div></div>
|
||||
<a name="sleigh_variable_length"></a>7.4.4. Variable Length Instructions</h4></div></div></div>
|
||||
<p>
|
||||
There are some additional complexities to designing a specification
|
||||
for a processor with variable length instructions. Some initial
|
||||
|
@ -419,7 +419,7 @@ designer control over how tokens fit together.
|
|||
</p>
|
||||
<div class="sect4">
|
||||
<div class="titlepage"><div><div><h5 class="title">
|
||||
<a name="idm140526920676432"></a>7.4.4.1. The ';' Operator</h5></div></div></div>
|
||||
<a name="sleigh_semicolon"></a>7.4.4.1. The ';' Operator</h5></div></div></div>
|
||||
<p>
|
||||
The most important operator for patterns defining variable length
|
||||
instructions is the concatenation operator ‘;’. When building a
|
||||
|
@ -481,7 +481,7 @@ operator, so parentheses may be necessary to get the intended meaning.
|
|||
</div>
|
||||
<div class="sect4">
|
||||
<div class="titlepage"><div><div><h5 class="title">
|
||||
<a name="idm140526920661120"></a>7.4.4.2. The '...' Operator</h5></div></div></div>
|
||||
<a name="sleigh_ellipsis"></a>7.4.4.2. The '...' Operator</h5></div></div></div>
|
||||
<p>
|
||||
The ellipsis operator ‘...’ is used to satisfy the token matching
|
||||
requirements of the ‘&’ and ‘|’ operators (described in the previous
|
||||
|
@ -557,7 +557,7 @@ don’t quite match the assembly.
|
|||
</div>
|
||||
<div class="sect3">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="idm140526920640560"></a>7.4.6. Empty Patterns</h4></div></div></div>
|
||||
<a name="sleigh_empty_patterns"></a>7.4.6. Empty Patterns</h4></div></div></div>
|
||||
<p>
|
||||
Occasionally there is a need for an empty pattern when building
|
||||
tables. An empty pattern matches everything. There is a predefined
|
||||
|
@ -567,7 +567,7 @@ to indicate an empty pattern.
|
|||
</div>
|
||||
<div class="sect3">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="idm140526920638720"></a>7.4.7. Advanced Constraints</h4></div></div></div>
|
||||
<a name="sleigh_advanced_constraints"></a>7.4.7. Advanced Constraints</h4></div></div></div>
|
||||
<p>
|
||||
A constraint does not have to be of the form “field = constant”,
|
||||
although this is almost always what is needed. In certain situations,
|
||||
|
@ -593,7 +593,7 @@ the following:
|
|||
<div class="informalexample">
|
||||
<div class="table">
|
||||
<a name="constraints.htmltable"></a><p class="title"><b>Table 3. Constraint Operators</b></p>
|
||||
<div class="table-contents"><table width="50%" frame="box" rules="all">
|
||||
<div class="table-contents"><table xml:id="constraints.htmltable" width="50%" frame="box" rules="all">
|
||||
<col width="50%">
|
||||
<col width="50%">
|
||||
<thead><tr>
|
||||
|
@ -720,7 +720,7 @@ is built up out of the following typical operators:
|
|||
<div class="informalexample">
|
||||
<div class="table">
|
||||
<a name="patexp.htmltable"></a><p class="title"><b>Table 4. Pattern Expression Operators</b></p>
|
||||
<div class="table-contents"><table width="50%" frame="box" rules="all">
|
||||
<div class="table-contents"><table xml:id="patexp.htmltable" width="50%" frame="box" rules="all">
|
||||
<col width="50%">
|
||||
<col width="50%">
|
||||
<thead><tr>
|
||||
|
@ -756,7 +756,7 @@ is built up out of the following typical operators:
|
|||
<td>Bitwise and</td>
|
||||
<td>
|
||||
<div class="informaltable">
|
||||
<a name="bitwiseand.htmltable"></a><table frame="none"><tbody>
|
||||
<a name="bitwiseand.htmltable"></a><table xml:id="bitwiseand.htmltable" frame="none"><tbody>
|
||||
<tr>
|
||||
<td>$and</td>
|
||||
</tr>
|
||||
|
@ -771,7 +771,7 @@ is built up out of the following typical operators:
|
|||
<td>Bitwise or</td>
|
||||
<td>
|
||||
<div class="informaltable">
|
||||
<a name="bitwiseor.htmltable"></a><table frame="none"><tbody>
|
||||
<a name="bitwiseor.htmltable"></a><table xml:id="bitwiseor.htmltable" frame="none"><tbody>
|
||||
<tr>
|
||||
<td>$or</td>
|
||||
</tr>
|
||||
|
@ -786,7 +786,7 @@ is built up out of the following typical operators:
|
|||
<td>Bitwise xor</td>
|
||||
<td>
|
||||
<div class="informaltable">
|
||||
<a name="bitwisexor.htmltable"></a><table frame="none"><tbody>
|
||||
<a name="bitwisexor.htmltable"></a><table xml:id="bitwisexor.htmltable" frame="none"><tbody>
|
||||
<tr>
|
||||
<td>$xor</td>
|
||||
</tr>
|
||||
|
@ -939,7 +939,7 @@ varnode is <span class="emphasis"><em>r1</em></span>.
|
|||
</p>
|
||||
<div class="sect3">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="idm140526920530304"></a>7.7.1. Expressions</h4></div></div></div>
|
||||
<a name="sleigh_expressions"></a>7.7.1. Expressions</h4></div></div></div>
|
||||
<p>
|
||||
Expressions are built out of symbols and the binary and unary
|
||||
operators listed in <a class="xref" href="sleigh_ref.html#syntaxref.htmltable" title="Table 5. Semantic Expression Operators and Syntax">Table 5, “Semantic Expression Operators and Syntax”</a> in the
|
||||
|
@ -954,7 +954,7 @@ within expressions to affect this order.
|
|||
</p>
|
||||
<div class="sect4">
|
||||
<div class="titlepage"><div><div><h5 class="title">
|
||||
<a name="idm140526920527872"></a>7.7.1.1. Arithmetic, Logical and Boolean Operators</h5></div></div></div>
|
||||
<a name="sleigh_arithmetic_logical"></a>7.7.1.1. Arithmetic, Logical and Boolean Operators</h5></div></div></div>
|
||||
<p>
|
||||
For the most part these operators should be familiar to software
|
||||
developers. The only real differences arise from the fact that
|
||||
|
@ -1017,7 +1017,7 @@ set to something other than one.
|
|||
</div>
|
||||
<div class="sect4">
|
||||
<div class="titlepage"><div><div><h5 class="title">
|
||||
<a name="idm140526920515552"></a>7.7.1.3. Extension</h5></div></div></div>
|
||||
<a name="sleigh_extension"></a>7.7.1.3. Extension</h5></div></div></div>
|
||||
<p>
|
||||
Most processors have instructions that extend small values into big
|
||||
values, and many instructions do these minor data manipulations
|
||||
|
@ -1039,7 +1039,7 @@ the <span class="bold"><strong>sext</strong></span> operator.
|
|||
</div>
|
||||
<div class="sect4">
|
||||
<div class="titlepage"><div><div><h5 class="title">
|
||||
<a name="idm140526920508832"></a>7.7.1.4. Truncation</h5></div></div></div>
|
||||
<a name="sleigh_truncation"></a>7.7.1.4. Truncation</h5></div></div></div>
|
||||
<p>
|
||||
There are two forms of syntax indicating a truncation of the input
|
||||
varnode. In one the varnode is followed by a colon ‘:’ and an integer
|
||||
|
@ -1119,7 +1119,7 @@ these are automatically set to zero.
|
|||
</p>
|
||||
<p>
|
||||
This operator can also be used on the left-hand side of assignments
|
||||
with similar behavior and caveats (see <a class="xref" href="sleigh_constructors.html#sleigh_bitrange_assign" title="7.7.2.7. Bit Range Assignments">Section 7.7.2.7, “Bit Range Assignments”</a>).
|
||||
with similar behavior and caveats (see <a class="xref" href="sleigh_constructors.html#sleigh_bitrange_assign" title="7.7.2.8. Bit Range Assignments">Section 7.7.2.8, “Bit Range Assignments”</a>).
|
||||
</p>
|
||||
</div>
|
||||
<div class="sect4">
|
||||
|
@ -1169,7 +1169,7 @@ the offset portion of the address, and to copy the desired value, the
|
|||
</div>
|
||||
<div class="sect4">
|
||||
<div class="titlepage"><div><div><h5 class="title">
|
||||
<a name="idm140526920484032"></a>7.7.1.7. Managed Code Operations</h5></div></div></div>
|
||||
<a name="sleigh_managed_code"></a>7.7.1.7. Managed Code Operations</h5></div></div></div>
|
||||
<p>
|
||||
SLEIGH provides basic support for instructions where encoding and context
|
||||
don't provide a complete description of the semantics. This is the case
|
||||
|
@ -1231,7 +1231,7 @@ define pcodeop arctan;
|
|||
</div>
|
||||
<div class="sect3">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="idm140526920471120"></a>7.7.2. Statements</h4></div></div></div>
|
||||
<a name="sleigh_statements"></a>7.7.2. Statements</h4></div></div></div>
|
||||
<p>
|
||||
We describe the types of semantic statements that are allowed in SLEIGH.
|
||||
</p>
|
||||
|
@ -1305,7 +1305,7 @@ and may be enforced in future compiler versions.
|
|||
</div>
|
||||
<div class="sect4">
|
||||
<div class="titlepage"><div><div><h5 class="title">
|
||||
<a name="idm140526920458176"></a>7.7.2.2. Storage Statements</h5></div></div></div>
|
||||
<a name="sleigh_storage_statements"></a>7.7.2.2. Storage Statements</h5></div></div></div>
|
||||
<p>
|
||||
SLEIGH supports fairly standard <span class="emphasis"><em>storage statement</em></span>
|
||||
syntax to complement the load operator. The left-hand side of an
|
||||
|
@ -1336,7 +1336,7 @@ attribute is set to something other than one.
|
|||
</div>
|
||||
<div class="sect4">
|
||||
<div class="titlepage"><div><div><h5 class="title">
|
||||
<a name="idm140526920452240"></a>7.7.2.3. Exports</h5></div></div></div>
|
||||
<a name="sleigh_exports"></a>7.7.2.3. Exports</h5></div></div></div>
|
||||
<p>
|
||||
The semantic section doesn’t just specify how to generate p-code for a
|
||||
constructor. Except for those constructors in the root table, this
|
||||
|
@ -1388,7 +1388,7 @@ varnode being modified to be exported as an integer constant.
|
|||
</div>
|
||||
<div class="sect4">
|
||||
<div class="titlepage"><div><div><h5 class="title">
|
||||
<a name="idm140526920441008"></a>7.7.2.4. Dynamic References</h5></div></div></div>
|
||||
<a name="sleigh_dynamic_references"></a>7.7.2.4. Dynamic References</h5></div></div></div>
|
||||
<p>
|
||||
The only other operator allowed as part of
|
||||
an <span class="bold"><strong>export</strong></span> statement, is the ‘*’
|
||||
|
@ -1447,7 +1447,7 @@ levels.
|
|||
</div>
|
||||
<div class="sect4">
|
||||
<div class="titlepage"><div><div><h5 class="title">
|
||||
<a name="idm140526920427360"></a>7.7.2.5. Branching Statements</h5></div></div></div>
|
||||
<a name="sleigh_branching_statements"></a>7.7.2.5. Branching Statements</h5></div></div></div>
|
||||
<p>
|
||||
This section discusses statements that generate p-code branching
|
||||
operations. These are listed in <a class="xref" href="sleigh_ref.html#branchref.htmltable" title="Table 7. Branching Statements">Table 7, “Branching Statements”</a>, in the Appendix.
|
||||
|
@ -1677,7 +1677,28 @@ or <span class="emphasis"><em>CALL</em></span> operation.
|
|||
</div>
|
||||
<div class="sect4">
|
||||
<div class="titlepage"><div><div><h5 class="title">
|
||||
<a name="sleigh_bitrange_assign"></a>7.7.2.7. Bit Range Assignments</h5></div></div></div>
|
||||
<a name="sleigh_skip_instruction_branching"></a>7.7.2.7. Skip Instruction Branching</h5></div></div></div>
|
||||
<p>
|
||||
Many processors have a conditional-skip-instruction which must branch over the next instruction
|
||||
based upon some condition. The <span class="emphasis"><em>inst_next2</em></span> symbol has been provided for
|
||||
this purpose.
|
||||
</p>
|
||||
<div class="informalexample"><pre class="programlisting">
|
||||
:skip.eq is opcode=10 {
|
||||
if (zeroflag!=0) goto inst_next2;
|
||||
}
|
||||
</pre></div>
|
||||
<p>
|
||||
</p>
|
||||
<p>
|
||||
In the example above, the branch address will be determined by adding the parsed-length of the next
|
||||
instruction to the value of <span class="emphasis"><em>inst_next</em></span> causing a branch over the next
|
||||
instruction when the condition is satisfied.
|
||||
</p>
|
||||
</div>
|
||||
<div class="sect4">
|
||||
<div class="titlepage"><div><div><h5 class="title">
|
||||
<a name="sleigh_bitrange_assign"></a>7.7.2.8. Bit Range Assignments</h5></div></div></div>
|
||||
<p>
|
||||
The bit range operator can appear on the left-hand side of an
|
||||
assignment. But as with the ‘*’ operator, its meaning is slightly
|
||||
|
@ -1802,7 +1823,7 @@ each followed by a variation which corrects the error.
|
|||
</div>
|
||||
<div class="sect3">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="idm140526920360336"></a>7.7.4. Unimplemented Semantics</h4></div></div></div>
|
||||
<a name="sleigh_unimplemented_semantics"></a>7.7.4. Unimplemented Semantics</h4></div></div></div>
|
||||
<p>
|
||||
The semantic section must be present for every constructor in the
|
||||
specification. But the designer can leave the semantics explicitly
|
||||
|
@ -1962,7 +1983,7 @@ should generally be avoided.
|
|||
</div>
|
||||
<div class="sect3">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="idm140526920333184"></a>7.8.2. Specific Symbol Trees</h4></div></div></div>
|
||||
<a name="sleigh_specific_symbol_trees"></a>7.8.2. Specific Symbol Trees</h4></div></div></div>
|
||||
<p>
|
||||
When the SLEIGH parser analyzes an instruction, it starts with the
|
||||
root symbol <span class="emphasis"><em>instruction</em></span>, and decides which of the
|
||||
|
@ -2045,7 +2066,7 @@ and p-code for these encodings by walking the trees.
|
|||
</p>
|
||||
<div class="sect4">
|
||||
<div class="titlepage"><div><div><h5 class="title">
|
||||
<a name="idm140526920314640"></a>7.8.2.1. Disassembly Trees</h5></div></div></div>
|
||||
<a name="sleigh_disassembly_trees"></a>7.8.2.1. Disassembly Trees</h5></div></div></div>
|
||||
<p>
|
||||
If the nodes of each tree are replaced with the display information of
|
||||
the corresponding specific symbol, we see how the disassembly
|
||||
|
@ -2068,7 +2089,7 @@ statements corresponding to the original instruction encodings.
|
|||
</div>
|
||||
<div class="sect4">
|
||||
<div class="titlepage"><div><div><h5 class="title">
|
||||
<a name="idm140526920308256"></a>7.8.2.2. P-code Trees</h5></div></div></div>
|
||||
<a name="sleigh_pcode_trees"></a>7.8.2.2. P-code Trees</h5></div></div></div>
|
||||
<p>
|
||||
A similar procedure produces the resulting p-code translation of the
|
||||
instruction. If each node in the specific symbol tree is replaced with
|
||||
|
@ -2147,7 +2168,7 @@ directive however should not be used in a macro.
|
|||
</div>
|
||||
<div class="sect2">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="idm140526920290640"></a>7.10. Build Directives</h3></div></div></div>
|
||||
<a name="sleigh_build_directives"></a>7.10. Build Directives</h3></div></div></div>
|
||||
<p>
|
||||
Because the nodes of a specific symbol tree are traversed in a
|
||||
depth-first order, the p-code for a child node in general comes before
|
||||
|
@ -2202,7 +2223,7 @@ normal action of the instruction.
|
|||
</div>
|
||||
<div class="sect2">
|
||||
<div class="titlepage"><div><div><h3 class="title">
|
||||
<a name="idm140526920281024"></a>7.11. Delay Slot Directives</h3></div></div></div>
|
||||
<a name="sleigh_delayslot_directives"></a>7.11. Delay Slot Directives</h3></div></div></div>
|
||||
<p>
|
||||
For processors with a pipe-lined architecture, multiple instructions
|
||||
are typically executing simultaneously. This can lead to processor
|
||||
|
@ -2245,7 +2266,8 @@ by the condition.
|
|||
<p>
|
||||
Because the <span class="bold"><strong>delayslot</strong></span> directive
|
||||
combines two or more instructions into one, the meaning of the
|
||||
symbol <span class="emphasis"><em>inst_next</em></span> becomes ambiguous. It is not
|
||||
symbols <span class="emphasis"><em>inst_next</em></span> and <span class="emphasis"><em>inst_next2</em></span>
|
||||
become ambiguous. It is not
|
||||
clear anymore what exactly the “next instruction” is. SLEIGH uses the
|
||||
following conventions for interpreting
|
||||
an <span class="emphasis"><em>inst_next</em></span> symbol. If it is used in the
|
||||
|
@ -2253,7 +2275,12 @@ semantic section, the symbol refers to the address of the instruction
|
|||
after any instructions in the delay slot. However, if it is used in a
|
||||
disassembly action, the <span class="emphasis"><em>inst_next</em></span> symbol refers
|
||||
to the address of the instruction immediately after the first
|
||||
instruction, even if there is a delay slot.
|
||||
instruction, even if there is a delay slot. The use of the
|
||||
<span class="emphasis"><em>inst_next2</em></span> symbol may be inappropriate in conjunction
|
||||
with <span class="bold"><strong>delayslot</strong></span> use. While its use of the
|
||||
next instruction address is identified by <span class="emphasis"><em>inst_next</em></span>,
|
||||
the length of the next instruction ignores any delay slots it may have
|
||||
when computing the value of <span class="emphasis"><em>inst_next2</em></span>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue