mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-27 13:32:08 +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:
@@ -1728,7 +1728,8 @@ z80_ld_mem : T_Z80_LD op_mem_ind comma T_MODE_SP
|
||||
}
|
||||
| T_Z80_LD op_mem_ind comma T_MODE_A
|
||||
{
|
||||
if ((!rpn_isReloc(&$2)) && ($2.nVal >= 0xFF00)) {
|
||||
if (CurrentOptions.optimizeloads &&
|
||||
(!rpn_isReloc(&$2)) && ($2.nVal >= 0xFF00)) {
|
||||
out_AbsByte(0xE0);
|
||||
out_AbsByte($2.nVal & 0xFF);
|
||||
} else {
|
||||
@@ -1781,7 +1782,8 @@ z80_ld_a : T_Z80_LD reg_r comma T_MODE_C_IND
|
||||
| T_Z80_LD reg_r comma op_mem_ind
|
||||
{
|
||||
if ($2 == REG_A) {
|
||||
if ((!rpn_isReloc(&$4)) && ($4.nVal >= 0xFF00)) {
|
||||
if (CurrentOptions.optimizeloads &&
|
||||
(!rpn_isReloc(&$4)) && ($4.nVal >= 0xFF00)) {
|
||||
out_AbsByte(0xF0);
|
||||
out_AbsByte($4.nVal & 0xFF);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user