.Page ;++ ; ; VfyCksum -- Verify checksum that was just read. ; ; VfyCksum will undo the mess that CreCksum created by xor'ing the ; checksum into the data bytes. See teh CreCksum description for the ; alogrithm used to understand what is being undone here. ; ; REGISTERS ; IN ; All = Any value ; OUT ; All = Destroyed ; ccC = 0 if checksum matches ; 1 if checksum does not match ; ; CALLS ; NONE ; ;-- VfyCksum .Equ * ; Entry point for all callers Lda #00 ; Init temporary checksums to zero Sta TCksm1 Sta TCksm2 Sta InxPtrl Sta InxPtrH Inc InxPtrH ; Start at page 1 Ldy #0F4 ; Only last 12 bytes VfTop .Equ * Asl A ; Rotate the third checksum byte Php ; Save the status bits Adc #00 ; Put carry bit into low bit (8 bit rotate) Sta TCksm3 ; Save 3rd checksum byte Plp ; Restore status bits Lda @InxPtrL,y ; Read 1st byte of 3 byte loop Eor TCksm3 ; restore original data Sta @InxPtrL,y Adc TCksm1 Sta TCksm1 ; And update the checksum Iny Bne $20 Inc InxPtrH ; Next page $20 Lda @InxPtrL,y ; 2nd of 3 byte loop Eor TCksm1 ; Restore originl data Sta @InxPtrL,y Adc TCksm2 Sta TCksm2 ; And update the checksum Iny Beq $60 ; Last byte to sum Lda @InxPtrL,y ; 3rd byte of 3 byte loop Eor TCksm2 ; Restore original data Sta @InxPtrL,y Adc TckSm3 ; Update checksum and leave in A Iny Bne VfTop ; Not at page boundary, loop Inc InxPtrH ; Next page Bne VfTop ; Branch always taken $60 Cmp CkSm2 ; 'A' reg has TCksm2 Bne $80 Lda TCksm3 Cmp Cksum3 Bne $80 Lda TCksm1 Cmp Cksum1 Bne $80 Clc Rts $80 Sec Rts