10 XMT(1)=&H2 : XMT(2)=&H7 : N=2 20 GOSUB *CRC16 30 END 100 *CRC16 110 CRCTMP=&HFFFF 120 FOR I=1 TO 8 130 CRCTMP=CRCTMP XOR XMT(I) 140 FOR J=1 TO 8 150 CT=CRCTMP AND &H1 160 IF CRCTMP<0 THEN CH=1 ELSE CH=0 : GOTO 180 170 CRCTMP=CRCTMP AND &H7FFF 180 CRCTMP=CRCTMP 2 190 IF CH=1 THEN CRCTMP=CRCTMP OR &H4000 200 IF CT=1 THEN CRCTMP=CRCTMP XOR &HA001 210 NEXT J, I 220 IF CRCTMP<0 THEN CL=1 : CRCTMP=CRCTMP AND &H7FFF ELSE CL=0 230 CI=CRCTMP AND &HEF : C2=(CRCTMP AND &H7F00) 256 240 IF CL=1 THEN C2=C2 OR &H80 250 XMT(N+1)=C1 : XMT(N+2)=C2 260 XMT$(N+1)=HEX$(XMT(N+1)) 270 XMT$(N+2)=HEX$(XMT(N+2)) 280 RETURN 5.2 () 07HG5 07H.
5.3 CRC-16