work on intel hex support

This commit is contained in:
Kyle Isom 2023-10-03 12:28:45 -07:00
parent 08d702bd97
commit 0e42524d76
4 changed files with 64 additions and 20 deletions

View File

@ -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

View File

@ -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.

View File

@ -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;

View File

@ -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.