1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-10-02 21:54:31 +00:00

Rename project/platform symbols that clash with opcode mnemonics

We're doing this for user labels but not for project/platform
symbols.  So if you have a constant named "BCC" you can't assemble
your code with certain assemblers.  Now we rename it automatically.

Added a quick test to 2007-labels-and-symbols.  (No change to ACME,
which barfs on the test.)
This commit is contained in:
Andy McFadden 2020-01-17 18:29:20 -08:00
parent ea94839bf6
commit da5833caef
6 changed files with 1036 additions and 261 deletions

View File

@ -159,7 +159,8 @@ namespace SourceGen.AsmGen {
string valueStr = PseudoOp.FormatNumericOperand(formatter, proj.SymbolTable, string valueStr = PseudoOp.FormatNumericOperand(formatter, proj.SymbolTable,
gen.Localizer.LabelMap, defSym.DataDescriptor, defSym.Value, 1, gen.Localizer.LabelMap, defSym.DataDescriptor, defSym.Value, 1,
PseudoOp.FormatNumericOpFlags.OmitLabelPrefixSuffix); PseudoOp.FormatNumericOpFlags.OmitLabelPrefixSuffix);
gen.OutputEquDirective(defSym.Label, valueStr, defSym.Comment); string labelStr = gen.Localizer.ConvLabel(defSym.Label);
gen.OutputEquDirective(labelStr, valueStr, defSym.Comment);
prevConst = defSym.IsConstant; prevConst = defSym.IsConstant;
} }

View File

@ -293,6 +293,17 @@ namespace SourceGen.AsmGen {
allGlobalLabels.Add(newLabel, newLabel); allGlobalLabels.Add(newLabel, newLabel);
} }
// Remap any project/platform symbols that clash with opcode mnemonics.
foreach (DefSymbol defSym in mProject.ActiveDefSymbolList) {
if (opNames != null && opNames.ContainsKey(defSym.Label.ToUpperInvariant())) {
// Clashed with mnemonic. Uniquify it.
Debug.WriteLine("Renaming clashing def sym: " + defSym.Label);
string newLabel = MakeUnique(defSym.Label, allGlobalLabels);
LabelMap[defSym.Label] = newLabel;
allGlobalLabels.Add(newLabel, newLabel);
}
}
// //
// Step 4: remap local labels. There are two operations here. // Step 4: remap local labels. There are two operations here.
// //

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,7 @@
.cpu "65816" .cpu "65816"
.enc sg_ascii .enc sg_ascii
.cdef $20,$7e,$20 .cdef $20,$7e,$20
BMI1 = $30 ;opcode mnemonic
zip = $cd zip = $cd
absl = $1029 absl = $1029
absh = $feed absh = $feed
@ -201,7 +202,7 @@ _string .text "This is a long string. Put a label and comment on it to confir"
_L118E lda #<thirty2+2 _L118E lda #<thirty2+2
lda #(>thirty2)+3 lda #(>thirty2)+3
lda #`thirty2 lda #`thirty2
rep #$30 rep #BMI1
.al .al
.xl .xl
lda #(thirty2 & $ffff)+3 lda #(thirty2 & $ffff)+3

View File

@ -1,5 +1,6 @@
;Project was edited to add a label in the middle of a dense hex region, and add ;Project was edited to add a label in the middle of a dense hex region, and add
;a duplicate label. ;a duplicate label.
BMI equ $30 ;opcode mnemonic
zip equ $cd zip equ $cd
absl equ $1029 absl equ $1029
absh equ $feed absh equ $feed
@ -191,7 +192,7 @@ start clc
:L118E lda #<thirty2+2 :L118E lda #<thirty2+2
lda #>thirty2+$300 lda #>thirty2+$300
lda #^thirty2 lda #^thirty2
rep #$30 rep #BMI
mx %00 mx %00
lda #thirty2+3 lda #thirty2+3
lda #>thirty2+$400 lda #>thirty2+$400

View File

@ -1,6 +1,7 @@
;Project was edited to add a label in the middle of a dense hex region, and add ;Project was edited to add a label in the middle of a dense hex region, and add
;a duplicate label. ;a duplicate label.
.setcpu "65816" .setcpu "65816"
BMI1 = $30 ;opcode mnemonic
zip = $cd zip = $cd
absl = $1029 absl = $1029
absh = $feed absh = $feed
@ -201,7 +202,7 @@ start: clc
@L118E: lda #<thirty2+2 @L118E: lda #<thirty2+2
lda #>thirty2+3 lda #>thirty2+3
lda #^thirty2 lda #^thirty2
rep #$30 rep #BMI1
.a16 .a16
.i16 .i16
lda #thirty2 & $ffff +3 lda #thirty2 & $ffff +3