beautypg.com

MagTek TTL User Manual

Page 18

background image

I/O Interface for TTL Magnetic Stripe Readers


14

Calculation of LRC for an encoder, using a Micro Processor (Intel 8751), is as follows:

START:

MOV R2,#0 ;ZERO REGISTER 2 (LRC ACCUMULATOR)
MOV R0,#START_SEN ;POINT AT FIRST CARD CHARACTER (START SENTINEL)


LOOP1:

MOVX A,@R0 ;PUT A CARD CHARACTER INTO THE ACCUMULATOR
ANL A,#0FH ;MASK OFF THE PARITY BIT
XCH A,R2 ;EXCHANGE THE ACCUMULATOR & REG 2
XRL A,R2 ;"EXCLUSIVE OR" ACC WITH R2
XCH A,R2 ;RUNNING TOTAL OF LRC IS NOW IN REG 2, CARD CHARACTER IN ACC.
INC R0 ;POINT AT THE NEXT CHARACTER
CJNE A,0FH,LOOP1 ;COMPARE, JUMP TO LOOP1 IF NOT EQUAL TO A END SENTINEL.
;WHEN THE PROGRAM FALLS THROUGH THE ABOVE INSTRUCTION THE FINAL LRC IS
;IN REGISTER 2, WE CALL THE ODD PARITY ROUTINE TO AFFIX ODD PARITY TO THE
;LRC AND WE ARE READY TO WRITE THE LRC ON A CARD.