CIA old/new?

From: Francesco Messineo <francesco.messineo_at_gmail.com>
Date: Sun, 3 Jan 2021 21:15:39 +0100
Message-ID: <CAESs-_ydQyzMLX33YVF_YnD9JZ4E8SCKqbKFUNNGGtU+=0WE1g_at_mail.gmail.com>
Hi all,
I always thought the old (6526 I guess) and the new (8521) CIAs were identical,
then I've seen this code:

testCIAVersion:
    //; Set NMI vector
    lda #<continue
    sta $fffa
    lda #>continue
    sta $fffb

    lda #$81  //;also don't forget to set mask. Setting $01 to an
appropriate value will also help :-) (Bitbreaker/Oxyron)
    sta $dd0d

    //; Set timer to 5 cycles
    lda #4
    sta $dd04
    lda #0
    sta $dd05

    //; Clear the detection flag
    sta oldCIA

    //; Fire a 1-shot timer
    lda #%10011001
    sta $dd0e

    //; This should be interrupted before the INC
    //; only if it's a newer chip.
    lda $dd0d
    lda $dd0d
    inc oldCIA

    jmp * //; just in case

So it seems the NMI triggered by some CIA revisions has an off-by-one
cycle error?
Can anyone explain what's the difference between the two CIAs?

Thanks
Frank
continue:
    lda $dd0d
    pla
    pla
    pla

    rts
Received on 2021-01-03 22:00:02

Archive generated by hypermail 2.3.0.