From 4b5c8982ff496d89a179061ac28cbd1413776ebd Mon Sep 17 00:00:00 2001 From: nickysn Date: Wed, 3 Jun 2020 15:35:42 +0000 Subject: [PATCH] + implemented IHX writing in the Z80 internal linker git-svn-id: trunk@45575 - --- compiler/ogrel.pas | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/compiler/ogrel.pas b/compiler/ogrel.pas index 15f67326c5..0481d6f5e3 100644 --- a/compiler/ogrel.pas +++ b/compiler/ogrel.pas @@ -121,6 +121,9 @@ interface { TIntelHexExeOutput } TIntelHexExeOutput = class(TExeOutput) + private + procedure writeString(const S: ansistring); + procedure writeLine(const S: ansistring); protected function writeData:boolean;override; procedure DoRelocationFixup(objsec:TObjSection);override; @@ -1198,9 +1201,61 @@ implementation TIntelHexExeOutput *****************************************************************************} + procedure TIntelHexExeOutput.writeString(const S: ansistring); + begin + FWriter.write(S[1],Length(S)); + end; + + procedure TIntelHexExeOutput.writeLine(const S: ansistring); + begin + writeString(S+#10) + end; + function TIntelHexExeOutput.writeData: boolean; + const + MaxRecLen=16; + var + exesec: TExeSection; + objsec: TObjSection; + exesec_i, objsec_i: Integer; + s: string; + blocklen, i: integer; + buf: array [0..MaxRecLen-1] of Byte; + blockaddr: Word; + checksum: Byte; begin result:=false; + for exesec_i:=0 to ExeSectionList.Count-1 do + begin + exesec:=TExeSection(ExeSectionList[exesec_i]); + for objsec_i:=0 to exesec.ObjSectionList.Count-1 do + begin + objsec:=TObjSection(exesec.ObjSectionList[objsec_i]); + if oso_Data in objsec.SecOptions then + begin + objsec.Data.seek(0); + while objsec.Data.Posblocklen then + internalerror(2020060301); + for i:=0 to blocklen-1 do + begin + s:=s+HexStr(buf[i],2); + checksum:=Byte(checksum+buf[i]); + end; + checksum:=$100-checksum; + s:=s+HexStr(checksum,2); + writeLine(s); + end; + end; + end; + end; + writeLine(':00000001FF'); + result:=true; end; procedure TIntelHexExeOutput.DoRelocationFixup(objsec: TObjSection);