基本信息
源码名称:bin2转S3格式文本
源码大小:1.21M
文件格式:.zip
开发语言:C/C++
更新时间:2020-09-05
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍
可在VS下打开。修改了bin2Srec里的源码。 使用说明,打开cmd 命令窗口,输入Debug目录下bin2Srec2.exe的路径 空格 bin文件路径。 回车。 在bin相同路径下会生成含有十六进制文件格式的TXT文件。 内容已经转换成S3格式的文本

int i;
dword max_addr, address;
int byte_count, this_line;
unsigned char checksum;
dword c;
int record_count = 0;

unsigned char buf[32];

max_addr = addr_offset (end_addr - begin_addr);

fseek(infile, begin_addr, SEEK_SET);

if ((max_addr > 0xffffl) && (addr_bytes < 3))
addr_bytes = 3;

if ((max_addr > 0xffffffl) && (addr_bytes < 4))
addr_bytes = 4;

if (verbose)
{
fprintf(stderr, HEADER1);
fprintf(stderr, HEADER2);
fprintf(stderr, "Input binary file: %s\n", filename);
fprintf(stderr, "Begin address   = %lXh\n", begin_addr);
fprintf(stderr, "End address     = %lXh\n", end_addr);
fprintf(stderr, "Address offset  = %lXh\n", addr_offset);
fprintf(stderr, "Maximum address = %lXh\n", max_addr);
fprintf(stderr, "Address bytes   = %d\n", addr_bytes);
}

if (do_headers)
printf("S00600004844521B\n");     /* Header record */

for (address = addr_offset; address <= max_addr; address = line_length)
{
if (verbose)
fprintf(stderr, "Processing %08lXh\r", address);

this_line = min(line_length, 1 max_addr - address);
byte_count = (addr_bytes this_line 1);
printf("S%d%02X", addr_bytes - 1, byte_count);
fprintf(fp, "S%d%02X", addr_bytes - 1, byte_count);

checksum = byte_count;

for (i = addr_bytes - 1; i >= 0; i--)
{
c = (address >> (i << 3)) & 0xff;
printf("%02X", c);
fprintf(fp, "%02X", c);
checksum = c;
}

fread(buf, 1, this_line, infile);

for (i = 0; i < this_line; i )
{
printf("%02X", buf[i]);
fprintf(fp, "%02X", buf[i]);
checksum = buf[i];
}

printf("%02X\n", 255 - checksum);
fprintf(fp, "%02X\n", 255 - checksum);

record_count ;
}

if (do_headers)
{
checksum = 3 (record_count & 0xff) ((record_count >> 8) & 0xff);
printf("S503%04X%02X\n", record_count, 255 - checksum);
fprintf(fp, "S503%04X%02X\n", record_count, 255 - checksum);

byte_count = (addr_bytes 1);
printf("S%d%02X", 11 - addr_bytes, byte_count);
fprintf(fp, "S%d%02X", 11 - addr_bytes, byte_count);
checksum = byte_count;

for (i = addr_bytes - 1; i >= 0; i--)
{
c = (addr_offset >> (i << 3)) & 0xff;
printf("%02X", c);
fprintf(fp, "%02X", c);
checksum = c;
}
printf("%02X\n", 255 - checksum);
fprintf(fp, "%02X\n", 255 - checksum);
}

if (verbose)
{
fprintf(stderr, "Processing complete \n");
fprintf(fp, "Processing complete \n");
}