Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
Note that address region isolation doesn't prevent explicit label
references from working (add update the test to prove it).

Added a note about pre-label xrefs.
  • Loading branch information
fadden committed May 22, 2024
1 parent 7a7ff44 commit 3b20566
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 11 deletions.
8 changes: 7 additions & 1 deletion SourceGen/DisasmProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ private void GenerateXrefs() {
//
// We want to tag both. So if "LDA $1000" becomes "LDA label-2", we want to
// add a numeric reference to the code at $1000, and a symbolic reference to the
// labe at $1002, that point back to the LDA instruction. These are presented
// label at $1002, that point back to the LDA instruction. These are presented
// slightly differently to the user. For a symbolic reference with no adjustment,
// we don't add the (redundant) numeric reference.
//
Expand Down Expand Up @@ -1648,6 +1648,12 @@ private void GenerateXrefs() {
mAnattribs[operandOffset].Address;
}

// TODO: to handle pre-labels correctly, we need to associate an
// XrefSet with an address region, and add the reference there. We
// currently attach it to the offset of the first byte in the region,
// which means you don't see anything in the references window when
// the pre-label line is selected.

AddXref(symOffset, new XrefSet.Xref(offset, true, xrefType, accType,
accessFlags, adj));
if (adj == 0) {
Expand Down
7 changes: 4 additions & 3 deletions SourceGen/MainController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3947,7 +3947,8 @@ private void UpdateReferencesPanel() {
return;
}
int lineIndex = mMainWin.CodeListView_GetFirstSelectedIndex();
LineListGen.Line.Type type = CodeLineList[lineIndex].LineType;
LineListGen.Line line = CodeLineList[lineIndex];
LineListGen.Line.Type type = line.LineType;
if (type != LineListGen.Line.Type.Code &&
type != LineListGen.Line.Type.Data &&
type != LineListGen.Line.Type.EquDirective &&
Expand All @@ -3960,10 +3961,10 @@ private void UpdateReferencesPanel() {

// Find the appropriate xref set.
if (type == LineListGen.Line.Type.LocalVariableTable) {
DefSymbol defSym = CodeLineList.GetLocalVariableFromLine(CodeLineList[lineIndex]);
DefSymbol defSym = CodeLineList.GetLocalVariableFromLine(line);
xrefs = (defSym == null) ? null : defSym.Xrefs;
} else {
int offset = CodeLineList[lineIndex].FileOffset;
int offset = line.FileOffset;
if (offset < 0) {
// EQU in header
int index = LineListGen.DefSymIndexFromOffset(offset);
Expand Down
10 changes: 8 additions & 2 deletions SourceGen/SGTestData/20290-region-isolation.dis65
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
},

"Comments":{
},
"9":"operand label set manually"},

"LongComments":{
},
Expand Down Expand Up @@ -396,7 +396,13 @@
"LabelAnno":"None"}},

"OperandFormats":{
},
"9":{
"Length":3,
"Format":"NumericLE",
"SubFormat":"Symbol",
"SymbolRef":{
"Label":"region4",
"Part":"Low"}}},

"LvTables":{
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ IN_4 = $c000
jsr region1
jsr region2
jsr THREE_K
jsr $4000
jsr region4 ;operand label set manually
lda L9005
lda LA008
lda IN_3+11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ IN_4 = $c000
jsr region1
jsr region2
jsr THREE_K
jsr $4000
jsr region4 ;operand label set manually
lda L9005
lda LA008
lda IN_3+11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ IN_4 = $c000
jsr region1
jsr region2
jsr THREE_K
jsr $4000
jsr region4 ;operand label set manually
lda L9005
lda LA008
lda IN_3+11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ IN_4 equ $c000
jsr region1
jsr region2
jsr THREE_K
jsr $4000
jsr region4 ;operand label set manually
lda L9005
lda LA008
lda IN_3+11
Expand Down
2 changes: 1 addition & 1 deletion SourceGen/XrefSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public Xref(int offset, bool isByName, XrefType type,

public override string ToString() {
return "Xref off=+" + Offset.ToString("x6") + " sym=" + IsByName +
" type=" + Type + " accType= " + AccType + " flags=" + Flags +
" type=" + Type + " accType=" + AccType + " flags=" + Flags +
" adj=" + Adjustment;
}
}
Expand Down
4 changes: 4 additions & 0 deletions docs/sgmanual/intro-details.html
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,10 @@ <h3 id="region-isolation">Isolation</h3>
resolution enabled so that we can reference the table from the code
that copies it to RAM.</p>

<p>Note this only affects automatic operand resolution. You can set
operand symbols manually to any location, regardless of the isolation
flags.</p>


<h3 id="non-addr">Non-Addressable Areas</h3>

Expand Down

0 comments on commit 3b20566

Please sign in to comment.