#include "extcode.h" CIN MgErr CINRun(LStrHandle SA, LStrHandle FC, LStrHandle AH, LStrHandle AL, LStrHandle VH, LStrHandle VL, LStrHandle CRCLoHi); CIN MgErr CINRun(LStrHandle SA, LStrHandle FC, LStrHandle AH, LStrHandle AL, LStrHandle VH, LStrHandle VL, LStrHandle CRCLoHi) { #include "stdafx.h" #include "math.h" unsigned char mess[9], reply[9]; void main() { unsigned char highbyte, lowbyte; unsigned short crc,thisbyte,i,shift,lastbit; mess[0]=0xSA; mess[1]=0xFC; mess[2]=0xAH; mess[3]=0xAL; mess[4]=0xVH; mess[5]=0xVL; crc = 0xffff; for(i=0; i<=5; i++) { thisbyte = mess[i]; crc = crc ^ thisbyte; for(shift = 0; shift<8;shift++) { lastbit = crc & 0x0001; crc = (crc >> 1) & 0x7fff; if (lastbit ==0x0001) { crc = crc ^ 0xa001; } } } highbyte = (crc >> 8) & 0xff; lowbyte = crc & 0xff; mess[6] = lowbyte; mess[7] = highbyte; mess[9] = mess[6],mess[7] printf("%x mess[9]"); } return noErr; }