;Program crc16()›INCLUDE "D2:RT_NOGR.ACT"›card v,p=[$A001];THE POLYNOMIAL›card array crc16tab(255)›char array filespec(18),filename(18),›           direntry(18),outfile(18)›char array outfilename="Dx:CRC16V2.DAT"›int i,cnt›card bytecnt›byte b›card iocb2=[$360]››proc ciov()››[$20 $56 $E4 $8C $FF $06 $60]››return››;**********************************›proc maketable()››for i = 0 to 255 do››   v := i›   for b = 1 to 8 do›     if (v & 1) then›       v := (v RSH 1) xor p›     else›       v :==  RSH 1›     fi›   od›v := v & $FFFF›crc16tab(i) := v›print(".")  ›od›pute()›return›››;*********************************›Proc Docrc()››card element,j›char c››for i = 4 to cnt-1 do›  c := filename(i)›  put(c)›  if outfile(1) <> 0 then›    putd(3,c)›  fi›od›for i = cnt to 18 do›  c := 32›  put(c)›  if outfile(1) <> 0 then›    putd(3,c)›  fi›od››bytecnt=0›v := $0›poke(iocb2+2,7)›poke(iocb2+4,1)›poke(iocb2+5,$80)›poke(iocb2+8,255)›poke(iocb2+9,0)›poke($6FF,1)›DO ;CONTROL STATEMENT BELOW ***›[$A9 $20 $AA]  ;put 16 in x register›ciov()›j := peek($28)  ;# of bytes actually›                ; read into buffer.›for i = 1 to j do›b := peek($8000+i)›bytecnt :== +1›element := (v xor b) and $FF›v :== rsh 8›v :== xor crc16tab(element)›od ;end for i›IF PEEK($6FF)  <> 1 THEN EXIT ;***›FI›OD ;›;do outputs›PRINTF("%H",v)›print("        ")›printc(bytecnt)›pute()›if outfile(1) <> 0 then›device=3›PRINTF("%H",v)›print("        ")›printc(bytecnt)›pute()›device=0›fi››return››;***********************************›proc main()››put(125)›maketable()›put(125)›pute()›printe("           CRC-16")›printe("            v2.0")›printe("        by Russ Gilbert")›printe("            12/94")›pute()›printe("A utility to obtain CRC16 values")           ›printe("of files/directories. Intended to")›printe("aid in detecting corrupted files.")›printe("NOTE: The crc16 obtained by version")›printe("2 agrees with ARC and other crc-16s")›pute()›pute()››printe("Input filespec")›printe("eg. D2:*.* or D3:FILE.EXT")›inputs(filespec)›printe("Program will print to screen.")›printe("Do you want a CRC16.DAT file?")›printe("Y/N?")›close(3)›open(3,"K:",4,0)›outfile(2) := getd(3)›if outfile(2) = 110 or outfile(2) = 78 then›  outfile(1) := 0›fi›if outfile(2) <>110 and outfile(2) <>78 then›  printe("Output drive #?")›  scopy(outfile,outfilename)›  outfile(2) := getd(3)›  outfile(15) := 155›  close(3)›  open(3,outfile,8,0)›fi›close(1)›open(1,filespec,6,0)›printe("Filename       CRC16        # Bytes")›printe("___________________________________")›if outfile(1) <> 0 then›  printde(3,"Filename       CRC16        # Bytes")›  printde(3,"___________________________________")›fi›DO  ; CONTROL STATEMENT BELOW ;*›  inputsd(1,direntry)›  IF DIRENTRY(1) <> 32 THEN EXIT FI;*›  filename(1) := 68›  filename(2) := filespec(2)›  if filespec(2) = 58 then       ›    filename(2) := 49›  fi›  filename(3) := 58›  cnt := 3›  for i = 3 to 10 do›    cnt :== + 1›    filename(cnt) := direntry(i)›    if direntry(i+1) = 32 then›      i := 10›    fi›  od›  cnt :== + 1›  filename(cnt) := 46›  for i = 11 to 13 do›    if direntry(i) = 32 then i := 13 fi›    cnt :== +1›    filename(cnt) := direntry(i)›  od›  cnt :== +1›  filename(cnt) := 155›  close(2)›  open(2,filename,4,0)›  Docrc()›od›  close(1)›  close(2)›  close(3)›[$6C $0A $00]›return››