1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-06-11 02:29:53 +00:00

Fix ANDImm flag updater

For nonzero values we were leaving Z=prev, which is wrong when Z=0
because the AND result might be zero.  Now if Z=1 we leave it alone,
but if Z=0 we now set it to Z=?.

Test 1003-flags-and-branches was testing for the (incorrect)
behavior, so we're now running into a BRK.  This is fine.
This commit is contained in:
Andy McFadden 2020-02-01 16:24:14 -08:00
parent 717e32d881
commit 5b75ae35fc
6 changed files with 9 additions and 6 deletions

View File

@ -667,10 +667,12 @@ namespace Asm65 {
}
private static StatusFlags FlagUpdater_ANDImm(StatusFlags flags, int immVal,
ref StatusFlags condBranchTakenFlags) {
// AND #00 --> Z=1, else Z=prev
// AND #00 --> Z=1, else if Z=0 then Z=?
// AND #7f --> N=0, else N=prev
if (immVal == 0) {
flags.Z = 1;
flags.Z = 1; // acc is now zero
} else if (flags.Z == 0) {
flags.Z = TriState16.INDETERMINATE; // acc *might* now be zero
}
bool hiBitClear;
if (immVal >= 0) {

View File

@ -31,6 +31,7 @@ RWTS_TRACK_NUM @ $b7ec ;track number (0 - 34)
RWTS_SECTOR_NUM @ $b7ed ;sector number (0-15)
RWTS_DCT @ $b7ee 2 ;pointer to Device Characteristics Table
RWTS_BUF @ $b7f0 2 ;pointer to data buffer for READ/WRITE
;RWTS_UNUSED @ $b7f2
RWTS_PARTIAL_COUNT @ $b7f3 ;byte count for partial sector
RWTS_CMD_CODE @ $b7f4 ;0=seek, 1=read, 2=write, 4=format
RWTS_ERR_CODE @ $b7f5 ;err code (when carry set)

View File

@ -154,8 +154,8 @@ _L10AB lda #$00
_L10B3 lda #$ff
and #$7f
bne _L10BB
brk
.byte $00
.byte $db
_L10BB bpl _L10BF

View File

@ -149,8 +149,8 @@ L105F sep #$80
:L10B3 lda #$ff
and #$7f
bne :L10BB
brk
dfb $00
dfb $db
:L10BB bpl :L10BF

View File

@ -154,8 +154,8 @@ L105F sep #$80
@L10B3 lda #$ff
and #$7f
bne @L10BB
brk
!byte $00
!byte $db
@L10BB bpl @L10BF

View File

@ -155,8 +155,8 @@ L105F: sep #$80
@L10B3: lda #$ff
and #$7f
bne @L10BB
brk
.byte $00
.byte $db
@L10BB: bpl @L10BF