MMIX-Expand (Using as) (original) (raw)
9.29.2 Instruction expansion ¶
When as
encounters an instruction with an operand that is either not known or does not fit the operand size of the instruction,as
(and ld
) will expand the instruction into a sequence of instructions semantically equivalent to the operand fitting the instruction. Expansion will take place for the following instructions:
‘GETA’
Expands to a sequence of four instructions: SETL
, INCML
,INCMH
and INCH
. The operand must be a multiple of four.
Conditional branches
A branch instruction is turned into a branch with the complemented condition and prediction bit over five instructions; four instructions setting $255
to the operand value, which like with GETA
must be a multiple of four, and a final GO <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>255</mn><mo separator="true">,</mo></mrow><annotation encoding="application/x-tex">255,</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8389em;vertical-align:-0.1944em;"></span><span class="mord">255</span><span class="mpunct">,</span></span></span></span>255,0
.
‘PUSHJ’
Similar to expansion for conditional branches; four instructions set$255
to the operand value, followed by a PUSHGO <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>255</mn><mo separator="true">,</mo></mrow><annotation encoding="application/x-tex">255,</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8389em;vertical-align:-0.1944em;"></span><span class="mord">255</span><span class="mpunct">,</span></span></span></span>255,0
.
‘JMP’
Similar to conditional branches and PUSHJ
. The final instruction is GO <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>255</mn><mo separator="true">,</mo></mrow><annotation encoding="application/x-tex">255,</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8389em;vertical-align:-0.1944em;"></span><span class="mord">255</span><span class="mpunct">,</span></span></span></span>255,0
.
The linker ld
is expected to shrink these expansions for code assembled with ‘--relax’ (though not currently implemented).