       NAM CDAT-2
*MEM DIAGNOSTIC (JOHN CHRISTENSEN'S)
*MODIFIED FOR MIKBUG AND SWTBUG OPERATION
CONTRL EQU $E0E3
       ORG $A002
LOTEMP RMB 2 STARTING ADDRESS
HITEMP RMB 2 ENDING ADDRESS
       ORG $A014
IXRTMP RMB 2 IXR TEMPORARY STORAGE
START  LDX LOTEMP
       LDA A INIPAT
LOOP1  STA A 0,X
       CMP A 0,X
       BNE ERPNT1
       CPX HITEMP
       BEQ LOAPAT
       INX
       BRA LOOP1
LOAPAT LDX LOTEMP
       LDA B TESPAT
LOOP4  STA B 0,X
       BRA CHECK
       ORG $A048
       FDB START
CHECK  CMP B 0,X
       BNE ERPNT2
CHKLOW STX IXRTMP
LOOP2  CPX LOTEMP
       BEQ CHCKHI
       DEX
       CMP A 0,X
       BNE ERPNT3
       BRA LOOP2
CHCKHI LDX IXRTMP
       CPX HITEMP
       BEQ END
LOOP3  INX
       CMP A 0,X
       BNE ERPNT4
       CPX HITEMP
       BNE LOOP3
RESTRE LDX IXRTMP
       STA A 0,X
       INX
       BRA LOOP4
ERPNT1 SWI ERROR ON INITIAL PATTERN
ERPNT2 SWI ERROR ON TEST PATTERN
ERPNT3 SWI DUAL ADDRESS ERROR LOW
ERPNT4 SWI DUAL ADDRESS ERROR LO
END    JMP CONTRL

INIPAT FCB 0
TESPAT FCB 0
       END
