forked from difcareer/010templates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SRecTemplate.bt
executable file
·70 lines (66 loc) · 1.81 KB
/
SRecTemplate.bt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//--------------------------------------
//--- 010 Editor v5.0 Binary Template
//
// File: SRecTemplate.bt
// Author: Mario Ghecea
// Revision: 1A
// Purpose: Parses Motorola S-REC
//--------------------------------------
typedef char RECORDTYPE [2];
typedef char COUNT [2];
typedef char ADDRESS16 [4];
typedef char ADDRESS24 [6];
typedef char ADDRESS32 [8];
typedef char CHECKSUM [2];
local char hexval [10];
local uint addrwidth;
local uint rec = 1;
typedef struct
{
RECORDTYPE recordType;
COUNT count;
switch(recordType)
{
case "S0": // header
case "S1": // 16-bit address record
case "S5": // total record count
case "S9": // termination 16-bit
ADDRESS16 address16;
addrwidth = 4;
break;
case "S2": // 24-bit address record
case "S8": // termination 24-bit
ADDRESS24 address24;
addrwidth = 6;
break;
case "S3": // 32-bit address record
case "S7": // termination 32-bit
ADDRESS32 adress32;
addrwidth = 8;
break;
//case "S4":
//case "S6":
default:
break;
}
local int i;
local int intval = 0;
local uint pow = 0;
local uint hexlen = 2;
local uint digit = 0;
for (i = 0; i < hexlen; i ++)
{
digit = (count[i] - '0' > 9) ? count[i] - '7' : count[i] - '0';
intval += ((uint32) digit * (1 << 4 * ((hexlen - 1) - i)));
}
local uint bytesPerLine = (uint32) ((intval - 1) * 2) - addrwidth;
if (bytesPerLine != 0)
char data [(bytesPerLine)];
//Printf("rec# %d bpl: %d %X count : %s\n\r", rec++, bytesPerLine, intval, count);
char checksum [2];
char crlf[2];
}SREC;
while( !FEof() )
{
SREC srec;
}