全文预览

C8051F350更新两种方法

上传者:徐小白 |  格式:doc  |  页数:11 |  大小:151KB

文档介绍
Рwhile (!source.eof())Р(Рsource, get(ch);Рif (ch ==':')Рvalidline = 1; //A valid record must be started with :Рelse if (ch == V)Р(Рvalidline = 0;РLine++;Р}РelseРvalidline = 0; // Omit the commentРif (validline)Р(Рbufptr = linebuff;Рsource.get((char*)bufptr, int(MAXLENTH),РLine++;Р// Do the ChecksumРchecksum = 0;Рtemp = 1;РdoР*bufptr 二 hexval(*bufptr);Рtemp++;Рif (temp % 2)Рchecksum += *bufptr + *(bufptr -1)*16;Р}Рwhile (*++bufptr);Р// checksum+=*(bufptr-1);Рif (checksum)Р(Рcerr « "Checksum in Line " « Line « " is Error.\n"; exit(2);Р}Рbufptr 二 linebuff;Рareclen = getcode(); // First 2 bytes are record length offset 二 getcode(); // Second 4 bytes are record offset offset =(offset & Oxff) « 8; // Avoid sign extension offset |= getcodeQ;Рattrib = getcode(); // If attrib = 1 then the file end.

收藏

分享

举报
下载此文档