kcpmtk/ihex.pas

60 lines
926 B
Plaintext
Raw Normal View History

2023-10-03 10:07:21 +00:00
const
2023-10-03 19:28:45 +00:00
MaxLnLen : Integer = 64;
MaxRLen : Integer = 32;
DumpBytes: Integer = 16;
IRecEOF : String[11] = ':00000001FF';
2023-10-03 10:07:21 +00:00
type
2023-10-03 19:28:45 +00:00
LnStr = String[64];
2023-10-03 10:07:21 +00:00
{irec stores an individual record.}
irec = record
Addr : Integer;
2023-10-03 19:28:45 +00:00
Data : array [1..32] of Byte;
Count : Byte;
MaxCount : Byte;
end;
function GetDumpCnt(Line : LnStr): Byte;
begin
end;
function RdDumpLn(Line : LnStr): irec;
var
lrec : irec;
begin
lrec.Addr := ReadWord(Line);
while (lrec.Count < DumpBytes) do
begin
lrec.Count := lrec.Count + 1;
end;
RdDumpLn := lrec;
end;
function IRecCS(rec : irec) : Byte;
var
cksm : Integer = 0;
begin
cksm := rec.Addr + rec.Count;
IRecCS := Byte(cksm and $00FF);
end;
procedure wrirec(rec : irec);
var
I : Byte;
begin
Write(':');
Write(WriteByte(rec.Count));
Write(WriteWord(rec.Addr));
for I := 1 to rec.Count do
Write(WriteByte(rec.Data[I]));
2023-10-03 10:07:21 +00:00
2023-10-03 19:28:45 +00:00
Writeln(WriteByte(IRecCS(rec)));
end;