Error checking, track 2, with an intel 8751 – MagTek TTL User Manual
Page 20
I/O Interface for TTL Magnetic Stripe Readers
16
ERROR CHECKING, TRACK 2, WITH AN INTEL 8751
Example of error checking in a Track 2 reader, using an Intel 8751 CPU:
; INITAILIZE REGISTERS AND FLAG BITS.
CHECK: MOV R2,#0 ;ZERO REGISTER 2 (LRC ACCUMULATOR)
CLR PARITY_FLAG ;CLEAR THE PARITY ERROR FLAG
MOV R0,#START_SEN ;POINT AT FIRST CARD CHARACTER IN RAM (START SENTINEL)
; START PARITY AND LRC CHECK (LONGITUDINAL REDUNDANCY CHECK CHARACTER).
CK0: CALL CK1 ;GO TEST A CHARACTER
CJNZ A,0FH,CK0 ;COMPARE ACCUMULATOR TO END SENTINEL, GO TO CK0 IF NOT ES
;IF IT'S A END SENTINEL THE PROGRAM DROPS THROUGH
CALL CK1 ;GO UPDATE THE LRC CHARACTER
MOV A,R2 ;MOVE REGISTER 2 TO THE ACCUMULATOR, GET THE LRC SUM
JNZ ERROR ;IF LRC SUM IS NOT ZERO, THIS EQUALS AN ERROR
JB PARITY_FLAG,ERROR ;SKIP TO ERROR IF PARITY FLAG IS SET
NOP ;IF THIS POINT IS REACHED THE CARD WAS READ CORRECTLY
;END OF TEST
; CK1--LRC SUBROUTINE
; THIS ROUTINE KEEPS THE RUNNING SUM OF THE LRC IN REGISTER 2
CK1: MOVX A,@R0 ;PUT A CARD CHARACTER FROM RAM INTO THE ACCUMULATOR
CALL PARITY_CK ;CHECK FOR ODD PARITY
MOVX A,@R0 ;GET THE SAME CHARACTER AGAIN
ANL A,#0FH ;ZERO THE FIRST 4 BITS, INCLUDING THE PARITY BIT
XCH A,R2 ;EXCHANGE ACCUMULATOR AND REGISTER 2
XRL A,R2 ;"EXCLUSIVE OR" THE ACCUMULATOR WITH REGISTER 2
XCH A,R2 ;EXCHANGE ACCUMULATOR AND REGISTER 2
INC R0 ;POINT AT THE NEXT CHARACTER
RET ;RETURN, AT THIS TIME THE RUNNING LRC IS IN REGISTER 2