mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Add flag to rgbasm to disable LD->LDH optimization
rgbasm tries to optimize any loads from/to $FF00-$FFFF and generate LDH 2-byte opcodes instead of regular LD 3-byte opcodes. This is a bit inconsistent as it only works for constant values. If a load is trying to access a label in a HRAM floating section, or a section found in a different object file, this optimization doesn't work. This means that a simple refactor or code could allow rgbasm to perform the optimzation or prevent it from doing so. For certain projects, like disassemblies, this is a problem. This patch adds flag -L to rgbasm to disable the optimization, and doesn't change the behaviour of any other existing code. Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
<table class="Nm">
|
||||
<tr>
|
||||
<td><b class="Nm" title="Nm">rgbasm</b></td>
|
||||
<td>[<span class="Op"><b class="Fl" title="Fl">-EhVvw</b></span>]
|
||||
<td>[<span class="Op"><b class="Fl" title="Fl">-EhLVvw</b></span>]
|
||||
[<span class="Op"><b class="Fl" title="Fl">-b</b>
|
||||
<var class="Ar" title="Ar">chars</var></span>]
|
||||
[<span class="Op"><b class="Fl" title="Fl">-D</b>
|
||||
@@ -89,6 +89,13 @@ The <b class="Nm" title="Nm">rgbasm</b> program creates an object file from an
|
||||
<dd class="It-tag">Add an include path.</dd>
|
||||
<dt class="It-tag"> </dt>
|
||||
<dd class="It-tag"> </dd>
|
||||
<dt class="It-tag"><a class="selflink" href="#L"><b class="Fl" title="Fl" id="L">-L</b></a></dt>
|
||||
<dd class="It-tag">Disable the optimization that turns loads of the form
|
||||
<b class="Sy" title="Sy">LD [$FF00+n8],A</b> into the opcode
|
||||
<b class="Sy" title="Sy">LDH [$FF00+n8],A</b> in order to have full
|
||||
control of the result in the final ROM.</dd>
|
||||
<dt class="It-tag"> </dt>
|
||||
<dd class="It-tag"> </dd>
|
||||
<dt class="It-tag"><a class="selflink" href="#M"><b class="Fl" title="Fl" id="M">-M</b></a>
|
||||
<var class="Ar" title="Ar">dependfile</var></dt>
|
||||
<dd class="It-tag">Print <a class="Xr" title="Xr">make(1)</a> dependencies to
|
||||
@@ -120,7 +127,11 @@ The <b class="Nm" title="Nm">rgbasm</b> program creates an object file from an
|
||||
<h1 class="Sh" title="Sh" id="EXAMPLES"><a class="selflink" href="#EXAMPLES">EXAMPLES</a></h1>
|
||||
Assembling a basic source file is simple:
|
||||
<div class="Pp"></div>
|
||||
<div class="D1">$ rgbasm -o bar.o foo.asm</div>
|
||||
<div class="Bd" style="margin-left: 5.00ex;">
|
||||
<pre class="Li">
|
||||
$ rgbasm -o bar.o foo.asm
|
||||
</pre>
|
||||
</div>
|
||||
<div class="Pp"></div>
|
||||
The resulting object file is not yet a usable ROM image — it must first
|
||||
be run through <a class="Xr" title="Xr">rgblink(1)</a> and
|
||||
@@ -138,7 +149,7 @@ The resulting object file is not yet a usable ROM image — it must first
|
||||
<a class="Lk" title="Lk" href="https://github.com/rednex/rgbds">https://github.com/rednex/rgbds</a>.</div>
|
||||
<table class="foot">
|
||||
<tr>
|
||||
<td class="foot-date">January 26, 2018</td>
|
||||
<td class="foot-date">February 24, 2018</td>
|
||||
<td class="foot-os">RGBDS Manual</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -125,7 +125,10 @@ Possible section types are as follows:
|
||||
<b class="Sy" title="Sy">LDH [$FF00+n8],A</b> and
|
||||
<b class="Sy" title="Sy">LDH A,[$FF00+n8]</b> syntax instead. This forces
|
||||
the assembler to emit the correct instruction and the linker to check if
|
||||
the value is in the correct range.</dd>
|
||||
the value is in the correct range. This optimization can be disabled by
|
||||
passing the <b class="Fl" title="Fl">-L</b> flag to
|
||||
<b class="Sy" title="Sy">rgbasm</b> as explained in
|
||||
<a class="Xr" title="Xr">rgbasm(1)</a>.</dd>
|
||||
</dl>
|
||||
<div class="Pp"></div>
|
||||
A section is usually defined as a floating one, but the code can restrict where
|
||||
@@ -1462,7 +1465,7 @@ The options that OPT can modify are currently: <b class="Sy" title="Sy">b</b>,
|
||||
<a class="Lk" title="Lk" href="https://github.com/rednex/rgbds">https://github.com/rednex/rgbds</a>.</div>
|
||||
<table class="foot">
|
||||
<tr>
|
||||
<td class="foot-date">January 27, 2018</td>
|
||||
<td class="foot-date">February 24, 2018</td>
|
||||
<td class="foot-os">RGBDS Manual</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -26,9 +26,13 @@
|
||||
<h1 class="Sh" title="Sh" id="EXAMPLES"><a class="selflink" href="#EXAMPLES">EXAMPLES</a></h1>
|
||||
To get a working ROM image from a single assembly source file:
|
||||
<div class="Pp"></div>
|
||||
<div class="D1">$ rgbasm -o bar.o foo.asm</div>
|
||||
<div class="D1">$ rgblink -o baz.gb bar.o</div>
|
||||
<div class="D1">$ rgbfix -v -p 0 baz.gb</div>
|
||||
<div class="Bd" style="margin-left: 5.00ex;">
|
||||
<pre class="Li">
|
||||
$ rgbasm -o bar.o foo.asm
|
||||
$ rgblink -o baz.gb bar.o
|
||||
$ rgbfix -v -p 0 baz.gb
|
||||
</pre>
|
||||
</div>
|
||||
<h1 class="Sh" title="Sh" id="SEE_ALSO"><a class="selflink" href="#SEE_ALSO">SEE
|
||||
ALSO</a></h1>
|
||||
<a class="Xr" title="Xr">rgbasm(1)</a>, <a class="Xr" title="Xr">rgbfix(1)</a>,
|
||||
@@ -58,7 +62,7 @@ To get a working ROM image from a single assembly source file:
|
||||
</div>
|
||||
<table class="foot">
|
||||
<tr>
|
||||
<td class="foot-date">January 26, 2018</td>
|
||||
<td class="foot-date">February 24, 2018</td>
|
||||
<td class="foot-os">RGBDS Manual</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user