diff --git a/src/Arch/i8051/i8051Disassembler.cs b/src/Arch/i8051/i8051Disassembler.cs index b4c8d43364..e60e0c2746 100644 --- a/src/Arch/i8051/i8051Disassembler.cs +++ b/src/Arch/i8051/i8051Disassembler.cs @@ -18,18 +18,14 @@ */ #endregion -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Reko.Core; using Reko.Core.Expressions; using Reko.Core.Machine; using Reko.Core.Memory; using Reko.Core.Services; using Reko.Core.Types; +using System; +using System.Collections.Generic; namespace Reko.Arch.i8051 { diff --git a/src/Arch/i8051/i8051Rewriter.cs b/src/Arch/i8051/i8051Rewriter.cs index 7fd9021646..5861d78899 100644 --- a/src/Arch/i8051/i8051Rewriter.cs +++ b/src/Arch/i8051/i8051Rewriter.cs @@ -29,6 +29,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Diagnostics; namespace Reko.Arch.i8051 { @@ -459,7 +460,10 @@ private Expression OpSrc(MachineOperand op, RegisterStorage? dataMemory) case AddressOperand addr: return addr.Address; case MemoryOperand mem: - var ea = EffectiveAddress(mem); + var (ea, alias) = EffectiveAddress(mem); + if (alias is not null) + return alias; + Debug.Assert(ea is not null); if (dataMemory != null) { return m.SegMem(mem.Width, binder.EnsureRegister(dataMemory), ea); @@ -487,7 +491,7 @@ private Expression OpSrc(MachineOperand op, RegisterStorage? dataMemory) } } - private Expression EffectiveAddress(MemoryOperand mem) + private (Expression?, Expression?) EffectiveAddress(MemoryOperand mem) { Expression ea; if (mem.DirectAddress != null) @@ -500,7 +504,7 @@ private Expression EffectiveAddress(MemoryOperand mem) { var alias = AliasedSpecialFunctionRegister(c.ToUInt16()); if (alias != null) - return alias; + return (null, alias); ea = c; } else @@ -537,7 +541,7 @@ private Expression EffectiveAddress(MemoryOperand mem) { ea = m.Convert(ea, PrimitiveType.Byte, PrimitiveType.Word16); } - return ea; + return (ea, null); } ///