mirror of
https://github.com/fadden/6502bench.git
synced 2025-02-20 06:29:04 +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:
parent
717e32d881
commit
5b75ae35fc
@ -667,10 +667,12 @@ namespace Asm65 {
|
|||||||
}
|
}
|
||||||
private static StatusFlags FlagUpdater_ANDImm(StatusFlags flags, int immVal,
|
private static StatusFlags FlagUpdater_ANDImm(StatusFlags flags, int immVal,
|
||||||
ref StatusFlags condBranchTakenFlags) {
|
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
|
// AND #7f --> N=0, else N=prev
|
||||||
if (immVal == 0) {
|
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;
|
bool hiBitClear;
|
||||||
if (immVal >= 0) {
|
if (immVal >= 0) {
|
||||||
|
@ -31,6 +31,7 @@ RWTS_TRACK_NUM @ $b7ec ;track number (0 - 34)
|
|||||||
RWTS_SECTOR_NUM @ $b7ed ;sector number (0-15)
|
RWTS_SECTOR_NUM @ $b7ed ;sector number (0-15)
|
||||||
RWTS_DCT @ $b7ee 2 ;pointer to Device Characteristics Table
|
RWTS_DCT @ $b7ee 2 ;pointer to Device Characteristics Table
|
||||||
RWTS_BUF @ $b7f0 2 ;pointer to data buffer for READ/WRITE
|
RWTS_BUF @ $b7f0 2 ;pointer to data buffer for READ/WRITE
|
||||||
|
;RWTS_UNUSED @ $b7f2
|
||||||
RWTS_PARTIAL_COUNT @ $b7f3 ;byte count for partial sector
|
RWTS_PARTIAL_COUNT @ $b7f3 ;byte count for partial sector
|
||||||
RWTS_CMD_CODE @ $b7f4 ;0=seek, 1=read, 2=write, 4=format
|
RWTS_CMD_CODE @ $b7f4 ;0=seek, 1=read, 2=write, 4=format
|
||||||
RWTS_ERR_CODE @ $b7f5 ;err code (when carry set)
|
RWTS_ERR_CODE @ $b7f5 ;err code (when carry set)
|
||||||
|
@ -154,8 +154,8 @@ _L10AB lda #$00
|
|||||||
_L10B3 lda #$ff
|
_L10B3 lda #$ff
|
||||||
and #$7f
|
and #$7f
|
||||||
bne _L10BB
|
bne _L10BB
|
||||||
|
brk
|
||||||
|
|
||||||
.byte $00
|
|
||||||
.byte $db
|
.byte $db
|
||||||
|
|
||||||
_L10BB bpl _L10BF
|
_L10BB bpl _L10BF
|
||||||
|
@ -149,8 +149,8 @@ L105F sep #$80
|
|||||||
:L10B3 lda #$ff
|
:L10B3 lda #$ff
|
||||||
and #$7f
|
and #$7f
|
||||||
bne :L10BB
|
bne :L10BB
|
||||||
|
brk
|
||||||
|
|
||||||
dfb $00
|
|
||||||
dfb $db
|
dfb $db
|
||||||
|
|
||||||
:L10BB bpl :L10BF
|
:L10BB bpl :L10BF
|
||||||
|
@ -154,8 +154,8 @@ L105F sep #$80
|
|||||||
@L10B3 lda #$ff
|
@L10B3 lda #$ff
|
||||||
and #$7f
|
and #$7f
|
||||||
bne @L10BB
|
bne @L10BB
|
||||||
|
brk
|
||||||
|
|
||||||
!byte $00
|
|
||||||
!byte $db
|
!byte $db
|
||||||
|
|
||||||
@L10BB bpl @L10BF
|
@L10BB bpl @L10BF
|
||||||
|
@ -155,8 +155,8 @@ L105F: sep #$80
|
|||||||
@L10B3: lda #$ff
|
@L10B3: lda #$ff
|
||||||
and #$7f
|
and #$7f
|
||||||
bne @L10BB
|
bne @L10BB
|
||||||
|
brk
|
||||||
|
|
||||||
.byte $00
|
|
||||||
.byte $db
|
.byte $db
|
||||||
|
|
||||||
@L10BB: bpl @L10BF
|
@L10BB: bpl @L10BF
|
||||||
|
Loading…
x
Reference in New Issue
Block a user