diff --git a/Makefile b/Makefile index 1421eba..d7ec1f2 100644 --- a/Makefile +++ b/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 + diff --git a/hello.pas b/hello.pas deleted file mode 100644 index 0e1aaf3..0000000 --- a/hello.pas +++ /dev/null @@ -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. diff --git a/ihex.pas b/ihex.pas index aed3542..6e4215f 100644 --- a/ihex.pas +++ b/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; - MaxCount : 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; diff --git a/undump.pas b/undump.pas index 576f81b..4fd0431 100644 --- a/undump.pas +++ b/undump.pas @@ -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.