mirror of
https://github.com/fadden/6502bench.git
synced 2025-01-19 08:29:48 +00:00
Show "idx" for indexed accesses in References window
Sometimes it's useful to know whether an address referenced by a function is a direct access, or is being used as a base address. (I'm somewhat undecided on this one, since it clutters up the list a bit. Giving it a try.)
This commit is contained in:
parent
facaa721de
commit
47c773dcdf
@ -236,6 +236,22 @@ namespace Asm65 {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True for instructions that index off of the operand. The goal is to identify
|
||||
/// instructions like "LDA $1234,Y" that may not access the address specified by
|
||||
/// their operand. So "(dp,X)" returns true, but "(dp),Y" does not.
|
||||
/// </summary>
|
||||
public bool IsIndexedAccessInstruction {
|
||||
get {
|
||||
return AddrMode == AddressMode.AbsIndexX ||
|
||||
AddrMode == AddressMode.AbsIndexXInd ||
|
||||
AddrMode == AddressMode.AbsIndexY ||
|
||||
AddrMode == AddressMode.DPIndexX ||
|
||||
AddrMode == AddressMode.DPIndexXInd ||
|
||||
AddrMode == AddressMode.DPIndexY;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if the operand's width is uniquely determined by the opcode mnemonic, even
|
||||
/// if the operation supports operands with varying widths.
|
||||
|
@ -1484,6 +1484,7 @@ namespace SourceGen {
|
||||
|
||||
XrefSet.XrefType xrefType = XrefSet.XrefType.Unknown;
|
||||
OpDef.MemoryEffect accType = OpDef.MemoryEffect.Unknown;
|
||||
bool isIndexedDirect = false;
|
||||
if (attr.IsInstruction) {
|
||||
OpDef op = CpuDef.GetOpDef(FileData[offset]);
|
||||
if (op.IsSubroutineCall) {
|
||||
@ -1493,6 +1494,7 @@ namespace SourceGen {
|
||||
} else {
|
||||
xrefType = XrefSet.XrefType.MemAccessOp;
|
||||
accType = op.MemEffect;
|
||||
isIndexedDirect = op.IsIndexedAccessInstruction;
|
||||
}
|
||||
} else if (attr.IsData || attr.IsInlineData) {
|
||||
xrefType = XrefSet.XrefType.RefFromData;
|
||||
@ -1520,8 +1522,8 @@ namespace SourceGen {
|
||||
mAnattribs[operandOffset].Address;
|
||||
}
|
||||
|
||||
AddXref(symOffset,
|
||||
new XrefSet.Xref(offset, true, xrefType, accType, adj));
|
||||
AddXref(symOffset, new XrefSet.Xref(offset, true, xrefType, accType,
|
||||
isIndexedDirect, adj));
|
||||
if (adj == 0) {
|
||||
hasZeroOffsetSym = true;
|
||||
}
|
||||
@ -1532,8 +1534,8 @@ namespace SourceGen {
|
||||
if (operandOffset >= 0) {
|
||||
adj = defSym.Value - operandOffset;
|
||||
}
|
||||
defSym.Xrefs.Add(
|
||||
new XrefSet.Xref(offset, true, xrefType, accType, adj));
|
||||
defSym.Xrefs.Add(new XrefSet.Xref(offset, true, xrefType, accType,
|
||||
isIndexedDirect, adj));
|
||||
}
|
||||
} else if (SymbolTable.TryGetValue(dfd.SymbolRef.Label, out Symbol sym)) {
|
||||
// Is this a reference to a project/platform symbol?
|
||||
@ -1559,8 +1561,8 @@ namespace SourceGen {
|
||||
// e.g. "LDA #>BLAH" would grab the high part. We'd need
|
||||
// to tweak the adjustment math appropriately.
|
||||
}
|
||||
defSym.Xrefs.Add(
|
||||
new XrefSet.Xref(offset, true, xrefType, accType, adj));
|
||||
defSym.Xrefs.Add(new XrefSet.Xref(offset, true, xrefType, accType,
|
||||
isIndexedDirect, adj));
|
||||
} else {
|
||||
// Can get here if somebody creates an address operand symbol
|
||||
// that refers to a local variable.
|
||||
@ -1599,8 +1601,8 @@ namespace SourceGen {
|
||||
} else {
|
||||
Debug.WriteLine("HEY: found unlabeled addr ref at +" +
|
||||
offset.ToString("x6"));
|
||||
AddXref(targetOffset,
|
||||
new XrefSet.Xref(offset, false, xrefType, accType, 0));
|
||||
AddXref(targetOffset, new XrefSet.Xref(offset, false, xrefType,
|
||||
accType, isIndexedDirect, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1609,8 +1611,8 @@ namespace SourceGen {
|
||||
// just leave a duplicate entry. (The symbolic ref wins because we need
|
||||
// it for the label localizer and possibly the label refactorer.)
|
||||
if (!hasZeroOffsetSym && attr.IsInstructionStart && attr.OperandOffset >= 0) {
|
||||
AddXref(attr.OperandOffset,
|
||||
new XrefSet.Xref(offset, false, xrefType, accType, 0));
|
||||
AddXref(attr.OperandOffset, new XrefSet.Xref(offset, false, xrefType,
|
||||
accType, isIndexedDirect, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3513,6 +3513,7 @@ namespace SourceGen {
|
||||
for (int i = 0; i < xrefs.Count; i++) {
|
||||
XrefSet.Xref xr = xrefs[i];
|
||||
|
||||
string idxStr = string.Empty;
|
||||
string typeStr;
|
||||
switch (xr.Type) {
|
||||
case XrefSet.XrefType.SubCallOp:
|
||||
@ -3544,6 +3545,9 @@ namespace SourceGen {
|
||||
typeStr = "??! ";
|
||||
break;
|
||||
}
|
||||
if (xr.IsIndexedAccess) {
|
||||
idxStr = "idx ";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Debug.Assert(false);
|
||||
@ -3554,7 +3558,7 @@ namespace SourceGen {
|
||||
MainWindow.ReferencesListItem rli = new MainWindow.ReferencesListItem(xr.Offset,
|
||||
formatter.FormatOffset24(xr.Offset),
|
||||
formatter.FormatAddress(mProject.GetAnattrib(xr.Offset).Address, showBank),
|
||||
(xr.IsByName ? "Sym " : "Oth ") + typeStr +
|
||||
(xr.IsByName ? "Sym " : "Oth ") + typeStr + idxStr +
|
||||
formatter.FormatAdjustment(-xr.Adjustment));
|
||||
|
||||
mMainWin.ReferencesList.Add(rli);
|
||||
|
@ -256,6 +256,9 @@ data operand, and provides an indication of the nature of the reference:</p>
|
||||
<li>data - reference to address by data
|
||||
(e.g. <code>.DD2 addr</code>)</li>
|
||||
</ul>
|
||||
<p>References from instructions that use indexed addressing
|
||||
(e.g. <code>LDA addr,Y</code>) will also show "idx" to indicate that
|
||||
the instruction is using the location as a base address.</p>
|
||||
<p>This will be prefixed with "Sym" or "Oth" to indicate whether or not
|
||||
the reference used the label at the current address. To understand
|
||||
this, consider that addresses can be referenced in different ways.
|
||||
|
@ -69,6 +69,12 @@ namespace SourceGen {
|
||||
/// </summary>
|
||||
public Asm65.OpDef.MemoryEffect AccType { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// For Type==MemAccessOp, true if the instruction applies an index offset, to
|
||||
/// the operand, meaning the referenced address might not actually be accessed.
|
||||
/// </summary>
|
||||
public bool IsIndexedAccess { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Adjustment to symbol. For example, "LDA label+2" adds an xref entry to
|
||||
/// "label", with an adjustment of +2.
|
||||
@ -76,17 +82,19 @@ namespace SourceGen {
|
||||
public int Adjustment { get; private set; }
|
||||
|
||||
public Xref(int offset, bool isByName, XrefType type,
|
||||
Asm65.OpDef.MemoryEffect accType, int adjustment) {
|
||||
Asm65.OpDef.MemoryEffect accType, bool isIndexedAccess, int adjustment) {
|
||||
Offset = offset;
|
||||
IsByName = isByName;
|
||||
Type = type;
|
||||
AccType = accType;
|
||||
IsIndexedAccess = isIndexedAccess;
|
||||
Adjustment = adjustment;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return "Xref off=+" + Offset.ToString("x6") + " sym=" + IsByName +
|
||||
" type=" + Type + " accType= " + AccType + " adj=" + Adjustment;
|
||||
" type=" + Type + " accType= " + AccType + " idx=" + IsIndexedAccess +
|
||||
" adj=" + Adjustment;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user