work on intel hex support
This commit is contained in:
parent
08d702bd97
commit
0e42524d76
6
Makefile
6
Makefile
|
@ -1,4 +1,4 @@
|
|||
TARGETS := hello test
|
||||
TARGETS := hello test undump
|
||||
LIBS := binary.pas ihex.pas
|
||||
FPC_FLAGS := -g
|
||||
FPC := fpc $(FPC_FLAGS)
|
||||
|
@ -15,3 +15,7 @@ hello: hello.pas
|
|||
|
||||
test: test.pas $(LIBS)
|
||||
$(FPC) $@.pas
|
||||
|
||||
undump: undump.pas binary.pas ihex.pas
|
||||
$(FPC) $@.pas
|
||||
|
||||
|
|
14
hello.pas
14
hello.pas
|
@ -1,14 +0,0 @@
|
|||
program hello;
|
||||
|
||||
procedure SayHello(name : String);
|
||||
begin
|
||||
Writeln('Hello, ', name);
|
||||
end;
|
||||
|
||||
var
|
||||
name : String[16];
|
||||
begin
|
||||
Write('What is your name? ');
|
||||
Readln(name);
|
||||
SayHello(name);
|
||||
end.
|
55
ihex.pas
55
ihex.pas
|
@ -1,12 +1,59 @@
|
|||
const
|
||||
MaxRLen = 32;
|
||||
MaxLnLen : Integer = 64;
|
||||
MaxRLen : Integer = 32;
|
||||
DumpBytes: Integer = 16;
|
||||
IRecEOF : String[11] = ':00000001FF';
|
||||
|
||||
type
|
||||
LnStr = String[64];
|
||||
|
||||
{irec stores an individual record.}
|
||||
irec = record
|
||||
Addr : Integer;
|
||||
Data : array[1...MaxRLen] of Byte;
|
||||
Data : array [1..32] of Byte;
|
||||
Count : Byte;
|
||||
MaxCount : Byte;
|
||||
end;
|
||||
|
||||
{procedure RdDumpLn;}
|
||||
{procedure wrirec;}
|
||||
|
||||
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]));
|
||||
|
||||
Writeln(WriteByte(IRecCS(rec)));
|
||||
end;
|
||||
|
|
|
@ -3,3 +3,10 @@ program undump;
|
|||
undump is a program to take the output from dump
|
||||
and put it into binary format.
|
||||
}
|
||||
|
||||
{$I 'binary.pas'}
|
||||
{$I 'ihex.pas'}
|
||||
|
||||
begin
|
||||
Writeln('UNDUMP V1.0');
|
||||
end.
|
||||
|
|
Loading…
Reference in New Issue