From 0abea2beacfa8d82d248d997a469e23bb1a40c52 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Mon, 19 Aug 2019 16:09:11 -0700 Subject: [PATCH] Update 64tass handling of StackInt ops The operands for BRK and COP must be expressed as immediate mode constants, with a leading '#'. --- SourceGen/AsmGen/AsmTass64.cs | 5 +++-- SourceGen/AsmGen/GenCommon.cs | 5 +++++ SourceGen/AsmGen/IGenerator.cs | 5 +++++ .../SGTestData/Expected/1000-allops-value-65816_64tass.S | 2 +- .../SGTestData/Expected/1001-allops-zero-65816_64tass.S | 2 +- SourceGen/SGTestData/Expected/2014-label-dp_64tass.S | 2 +- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/SourceGen/AsmGen/AsmTass64.cs b/SourceGen/AsmGen/AsmTass64.cs index 395b97c..dead43d 100644 --- a/SourceGen/AsmGen/AsmTass64.cs +++ b/SourceGen/AsmGen/AsmTass64.cs @@ -153,6 +153,7 @@ namespace SourceGen.AsmGen { Project = project; Quirks = new AssemblerQuirks(); + Quirks.StackIntOperandIsImmediate = true; mWorkDirectory = workDirectory; mFileNameBase = fileNameBase; @@ -326,8 +327,8 @@ namespace SourceGen.AsmGen { return null; } } - if (op == OpDef.OpCOP_StackInt || op == OpDef.OpWDM_WDM) { - // 64tass doesn't like these to have an operand. Output as hex. + if (op == OpDef.OpWDM_WDM) { + // 64tass v1.54 doesn't like this to have an operand. Output as hex. return null; } return string.Empty; // indicate original is fine diff --git a/SourceGen/AsmGen/GenCommon.cs b/SourceGen/AsmGen/GenCommon.cs index 3f9f1b8..4e46c92 100644 --- a/SourceGen/AsmGen/GenCommon.cs +++ b/SourceGen/AsmGen/GenCommon.cs @@ -267,6 +267,11 @@ namespace SourceGen.AsmGen { } string operandStr = formatter.FormatOperand(op, formattedOperand, wdis); + if (gen.Quirks.StackIntOperandIsImmediate && op.AddrMode == OpDef.AddressMode.StackInt) { + // COP $02 is standard, but some require COP #$02 + operandStr = '#' + operandStr; + } + string eolComment = proj.Comments[offset]; if (doAddCycles) { bool branchCross = (attr.Address & 0xff00) != (operandForSymbol & 0xff00); diff --git a/SourceGen/AsmGen/IGenerator.cs b/SourceGen/AsmGen/IGenerator.cs index 5172b36..ff09e20 100644 --- a/SourceGen/AsmGen/IGenerator.cs +++ b/SourceGen/AsmGen/IGenerator.cs @@ -178,6 +178,11 @@ namespace SourceGen.AsmGen { /// public bool BlockMoveArgsNoHash { get; set; } + /// + /// Do 8-bit constant args to StackInt ops (BRK/COP) require a leading '#'? + /// + public bool StackIntOperandIsImmediate { get; set; } + /// /// Does the assembler configure assembler widths based on SEP/REP, but doesn't /// track the emulation bit? diff --git a/SourceGen/SGTestData/Expected/1000-allops-value-65816_64tass.S b/SourceGen/SGTestData/Expected/1000-allops-value-65816_64tass.S index 76f9739..c49cedd 100644 --- a/SourceGen/SGTestData/Expected/1000-allops-value-65816_64tass.S +++ b/SourceGen/SGTestData/Expected/1000-allops-value-65816_64tass.S @@ -20,7 +20,7 @@ .byte $ff L101F ora ($ff,x) - .byte $02,$ff + cop #$ff ora $ff,s tsb $ff ora $ff diff --git a/SourceGen/SGTestData/Expected/1001-allops-zero-65816_64tass.S b/SourceGen/SGTestData/Expected/1001-allops-zero-65816_64tass.S index 9a4ec70..968251d 100644 --- a/SourceGen/SGTestData/Expected/1001-allops-zero-65816_64tass.S +++ b/SourceGen/SGTestData/Expected/1001-allops-zero-65816_64tass.S @@ -20,7 +20,7 @@ .byte $00 L101F ora ($00,x) - .byte $02,$00 + cop #$00 ora $00,s tsb $00 ora $00 diff --git a/SourceGen/SGTestData/Expected/2014-label-dp_64tass.S b/SourceGen/SGTestData/Expected/2014-label-dp_64tass.S index cfdd41b..b76f1d9 100644 --- a/SourceGen/SGTestData/Expected/2014-label-dp_64tass.S +++ b/SourceGen/SGTestData/Expected/2014-label-dp_64tass.S @@ -21,7 +21,7 @@ .byte $80 L101F ora (L0080,x) - .byte $02,$80 + cop #$80 ora $80,s tsb L0080 ora L0080