diff --git a/Asm65/OpDef.cs b/Asm65/OpDef.cs
index b5d05af..aa995f9 100644
--- a/Asm65/OpDef.cs
+++ b/Asm65/OpDef.cs
@@ -821,6 +821,7 @@ namespace Asm65 {
BaseMemEffect = MemoryEffect.Read,
FlagsAffected = FlagsAffected_NVZC,
StatusFlagUpdater = FlagUpdater_NVZC
+ // We can assert C=0 after ADC #$00, but only if C=0 on entry. Doesn't seem useful.
};
private static OpDef OpAND = new OpDef() {
Mnemonic = OpName.AND,
diff --git a/SourceGen/CodeAnalysis.cs b/SourceGen/CodeAnalysis.cs
index 64b41bb..d687cea 100644
--- a/SourceGen/CodeAnalysis.cs
+++ b/SourceGen/CodeAnalysis.cs
@@ -757,14 +757,16 @@ namespace SourceGen {
// If we've already visited the next offset, and the updated status flags are
// the same as the previous status flags, then there's nothing to gain by
// continuing forward.
- if (mAnattribs[nextOffset].IsVisited) {
- if (!mAnattribs[nextOffset].IsChanged &&
- nextStatusBefore == mAnattribs[nextOffset].StatusFlags) {
+ if (mAnattribs[nextOffset].IsVisited && !mAnattribs[nextOffset].IsChanged) {
+ if (nextStatusBefore == mAnattribs[nextOffset].StatusFlags) {
// Instruction has been visited, hasn't been flagged as changed,
// and our status flag merge had no effect. No need to continue
// through.
LogV(offset, "Not re-examining " + nextOffset);
break;
+ } else {
+ // We changed the flags, need to re-evaluate conditional branches.
+ mAnattribs[nextOffset].IsChanged = true;
}
}
diff --git a/SourceGen/SGTestData/1003-flags-and-branches b/SourceGen/SGTestData/1003-flags-and-branches
index 9aa96bf..34e3a42 100644
Binary files a/SourceGen/SGTestData/1003-flags-and-branches and b/SourceGen/SGTestData/1003-flags-and-branches differ
diff --git a/SourceGen/SGTestData/Expected/1003-flags-and-branches_64tass.S b/SourceGen/SGTestData/Expected/1003-flags-and-branches_64tass.S
index 78d101c..713241c 100644
--- a/SourceGen/SGTestData/Expected/1003-flags-and-branches_64tass.S
+++ b/SourceGen/SGTestData/Expected/1003-flags-and-branches_64tass.S
@@ -228,32 +228,41 @@ L10FA clc
.byte $00
.byte $00
-L1102 rep #$20
- .al
- sep #$10
- jsr L111D
- rep #$30
- .xl
- jsr L1123
- sep #$30
- .as
- .xs
- jsr L1123
+L1102 sec
+ bcs L1106
+
+L1105 clc
+L1106 lda $33
+ beq L1105
+ bcs L110E
+ lda $44
+L110E nop
rep #$20
.al
sep #$10
- jsr L111D
+ jsr L112A
+ rep #$30
+ .xl
+ jsr L1130
+ sep #$30
+ .as
+ .xs
+ jsr L1130
+ rep #$20
+ .al
+ sep #$10
+ jsr L112A
sep #$30
.as
rts
.al
-L111D lda #$1234
+L112A lda #$1234
ldx #$ff
rts
.as
-L1123 lda #$ff
+L1130 lda #$ff
ldx #$ee
ldy #$dd
rts
diff --git a/SourceGen/SGTestData/Expected/1003-flags-and-branches_Merlin32.S b/SourceGen/SGTestData/Expected/1003-flags-and-branches_Merlin32.S
index 19262e2..2ca46ef 100644
--- a/SourceGen/SGTestData/Expected/1003-flags-and-branches_Merlin32.S
+++ b/SourceGen/SGTestData/Expected/1003-flags-and-branches_Merlin32.S
@@ -223,31 +223,40 @@ L10FA clc
dfb $00
dfb $00
-L1102 rep #$20
- mx %01
- sep #$10
- jsr L111D
- rep #$30
- mx %00
- jsr L1123
- sep #$30
- mx %11
- jsr L1123
+L1102 sec
+ bcs L1106
+
+L1105 clc
+L1106 lda $33
+ beq L1105
+ bcs L110E
+ lda $44
+L110E nop
rep #$20
mx %01
sep #$10
- jsr L111D
+ jsr L112A
+ rep #$30
+ mx %00
+ jsr L1130
+ sep #$30
+ mx %11
+ jsr L1130
+ rep #$20
+ mx %01
+ sep #$10
+ jsr L112A
sep #$30
mx %11
rts
mx %01
-L111D lda #$1234
+L112A lda #$1234
ldx #$ff
rts
mx %11
-L1123 lda #$ff
+L1130 lda #$ff
ldx #$ee
ldy #$dd
rts
diff --git a/SourceGen/SGTestData/Expected/1003-flags-and-branches_acme.S b/SourceGen/SGTestData/Expected/1003-flags-and-branches_acme.S
index 5bf56a3..3477c65 100644
--- a/SourceGen/SGTestData/Expected/1003-flags-and-branches_acme.S
+++ b/SourceGen/SGTestData/Expected/1003-flags-and-branches_acme.S
@@ -228,32 +228,41 @@ L10FA clc
!byte $00
!byte $00
-L1102 rep #$20
- !al
- sep #$10
- jsr L111D
- rep #$30
- !rl
- jsr L1123
- sep #$30
- !as
- !rs
- jsr L1123
+L1102 sec
+ bcs L1106
+
+L1105 clc
+L1106 lda $33
+ beq L1105
+ bcs L110E
+ lda $44
+L110E nop
rep #$20
!al
sep #$10
- jsr L111D
+ jsr L112A
+ rep #$30
+ !rl
+ jsr L1130
+ sep #$30
+ !as
+ !rs
+ jsr L1130
+ rep #$20
+ !al
+ sep #$10
+ jsr L112A
sep #$30
!as
rts
!al
-L111D lda #$1234
+L112A lda #$1234
ldx #$ff
rts
!as
-L1123 lda #$ff
+L1130 lda #$ff
ldx #$ee
ldy #$dd
rts
diff --git a/SourceGen/SGTestData/Expected/1003-flags-and-branches_cc65.S b/SourceGen/SGTestData/Expected/1003-flags-and-branches_cc65.S
index 94b7de1..f9d5c70 100644
--- a/SourceGen/SGTestData/Expected/1003-flags-and-branches_cc65.S
+++ b/SourceGen/SGTestData/Expected/1003-flags-and-branches_cc65.S
@@ -229,32 +229,41 @@ L10FA: clc
.byte $00
.byte $00
-L1102: rep #$20
- .a16
- sep #$10
- jsr L111D
- rep #$30
- .i16
- jsr L1123
- sep #$30
- .a8
- .i8
- jsr L1123
+L1102: sec
+ bcs L1106
+
+L1105: clc
+L1106: lda $33
+ beq L1105
+ bcs L110E
+ lda $44
+L110E: nop
rep #$20
.a16
sep #$10
- jsr L111D
+ jsr L112A
+ rep #$30
+ .i16
+ jsr L1130
+ sep #$30
+ .a8
+ .i8
+ jsr L1130
+ rep #$20
+ .a16
+ sep #$10
+ jsr L112A
sep #$30
.a8
rts
.a16
-L111D: lda #$1234
+L112A: lda #$1234
ldx #$ff
rts
.a8
-L1123: lda #$ff
+L1130: lda #$ff
ldx #$ee
ldy #$dd
rts
diff --git a/SourceGen/SGTestData/Expected/1003-flags-and-branches_cc65.cfg b/SourceGen/SGTestData/Expected/1003-flags-and-branches_cc65.cfg
index 04e794a..1fd5402 100644
--- a/SourceGen/SGTestData/Expected/1003-flags-and-branches_cc65.cfg
+++ b/SourceGen/SGTestData/Expected/1003-flags-and-branches_cc65.cfg
@@ -1,7 +1,7 @@
# 6502bench SourceGen generated linker script for 1003-flags-and-branches
MEMORY {
MAIN: file=%O, start=%S, size=65536;
-# MEM000: file=%O, start=$1000, size=298;
+# MEM000: file=%O, start=$1000, size=311;
}
SEGMENTS {
CODE: load=MAIN, type=rw;
diff --git a/SourceGen/SGTestData/Source/1003-flags-and-branches.S b/SourceGen/SGTestData/Source/1003-flags-and-branches.S
index 80513bc..059510f 100644
--- a/SourceGen/SGTestData/Source/1003-flags-and-branches.S
+++ b/SourceGen/SGTestData/Source/1003-flags-and-branches.S
@@ -204,6 +204,18 @@ ok_rol1
brk $00
ok_plp
+; regression test for bug in analyzer
+ sec ;here carry is clear
+ bcs flg2
+flg1 clc
+
+flg2 lda $33
+ beq flg1
+ bcs flg3 ;this should NOT be branch-always
+ lda $44
+flg3 nop
+
+; test tracking across subroutine calls
rep #$20 ;long a
sep #$10 ;short x/y
mx %01
diff --git a/SourceGen/WpfGui/EditInstructionOperand.xaml b/SourceGen/WpfGui/EditInstructionOperand.xaml
index 0f5a3e1..0972580 100644
--- a/SourceGen/WpfGui/EditInstructionOperand.xaml
+++ b/SourceGen/WpfGui/EditInstructionOperand.xaml
@@ -35,15 +35,15 @@ limitations under the License.
[invalid symbol name]
?
- Create Local Variable
- Edit Local Variable
+ Create Local _Variable
+ Edit Local _Variable
Match found (ZP address):
Match found (StackRel constant):
- Create Label
- Edit Label
- Create Project Symbol
- Edit Project Symbol
+ Create _Label
+ Edit _Label
+ Create _Project Symbol
+ Edit _Project Symbol
Current label:
Current label (adjusted {0}):
@@ -67,7 +67,7 @@ limitations under the License.
@@ -79,17 +79,17 @@ limitations under the License.
-
-
-
-
-
-
@@ -104,7 +104,7 @@ limitations under the License.
+ Content="_Symbol" IsChecked="{Binding FormatSymbol}"/>
-
@@ -221,7 +221,7 @@ limitations under the License.
-
diff --git a/SourceGen/WpfGui/EditInstructionOperand.xaml.cs b/SourceGen/WpfGui/EditInstructionOperand.xaml.cs
index bc99dbb..7d4032e 100644
--- a/SourceGen/WpfGui/EditInstructionOperand.xaml.cs
+++ b/SourceGen/WpfGui/EditInstructionOperand.xaml.cs
@@ -946,6 +946,10 @@ namespace SourceGen.WpfGui {
CreateEditLabelText = EDIT_LABEL;
NarTargetLabel = mEditedLabel.Label;
}
+
+ // Sort nice to just hit return twice after entering a label, so move the focus
+ // to the OK button.
+ okButton.Focus();
}
private void EditProjectSymbol_Click(object sender, RoutedEventArgs e) {