Press enter to see results or esc to cancel.

Importing LEDATA and LIDATA Object File Records

This procedure processes LEDATA object file record ($A0) and copies data from object file to symbol table.

Procedure OMF_LEDATA; Far;
Var DestinationOffset: Word;
begin

{$IFDEF DEBUGOMF}
  Writeln ('        LEDATA');
{$ENDIF}

  If FindSegmentForEnumeratedData (DestinationOffset) then
    Move (ObjectFilePtr^.EnumData, Ptr (DataBlockSegment, DestinationOffset)^,
            ObjectRecordChecksumOffset - Ofs (ObjectFilePtr^.EnumData));
end;

This procedure processes LIDATA object file record ($A2) and copies data from object file to symbol table.

Procedure OMF_LIDATA; Far;
Type PDataBlock = ^TDataBlock;
     TDataBlock = Record
                    RepeatCount: Word;
                    BlockCount: Word;
                    Case Byte of
                      0: (BlockSize: Byte; Block: Byte);
                      1: (NextDataBlock: Byte);
                  end;
Var DestinationOffset: Word;

  Procedure RepeatBlocks (Var BlockStartPtr: PDataBlock);
  Var RepeatCount, BlockCount, N, M: Word;
      NextBlockStartPtr: PDataBlock;
  begin
    RepeatCount := BlockStartPtr^.RepeatCount;
    BlockCount := BlockStartPtr^.BlockCount;
    For N := 1 to RepeatCount do
      Case BlockCount of
        0: begin
             Move (BlockStartPtr^.Block, Ptr (DataBlockSegment, DestinationOffset)^, BlockStartPtr^.BlockSize);
             Inc (DestinationOffset, BlockStartPtr^.BlockSize);
             NextBlockStartPtr := PDataBlock (PChar (BlockStartPtr) + BlockStartPtr^.BlockSize + 5);
           end;
        else For M := 1 to BlockCount do
               begin
                 RepeatBlocks (BlockStartPtr);
                 NextBlockStartPtr := BlockStartPtr
               end;
      end;
    BlockStartPtr := NextBlockStartPtr
  end;

begin

{$IFDEF DEBUGOMF}
  Writeln ('        LIDATA');
{$ENDIF}

  If FindSegmentForEnumeratedData (DestinationOffset) then
    begin
      Inc (PChar (ObjectFilePtr), 3);
      Repeat
        RepeatBlocks (PDataBlock (ObjectFilePtr));
      until Ofs (ObjectFilePtr^) >= ObjectRecordChecksumOffset;
    end;
end;

This function returns True nad sets data if EnumSegmentIndex is either for code or typed constants.

Function FindSegmentForEnumeratedData (Var DI: Word): Boolean;
begin
  FindSegmentForEnumeratedData := False;
  ReferencesSymbolTable := stMain;
  If ObjectFilePtr^.EnumSegmentIndex = CodeSegmentIndex then
    begin
      EnumeratedDataOffset := ObjectFilePtr^.EnumeratedDataOffset;
      LastBlockSize := LastProgramBlockCodeSize;
      DataBlockSegment := SymbolTable [stCode].Segment;
      ReferencesSymbolTable := stCodeReferences;
      DI := LastProgramBlockCodeSize + ObjectFilePtr^.EnumeratedDataOffset;
      FindSegmentForEnumeratedData := True;
    end else If ObjectFilePtr^.EnumSegmentIndex = TypedConstantsSegmentIndex then
               begin
                 EnumeratedDataOffset := ObjectFilePtr^.EnumeratedDataOffset;
                 LastBlockSize := LastTypedConstantsSize;
                 DataBlockSegment := SymbolTable [stTypedConstants].Segment;
                 ReferencesSymbolTable := stTypedConstantsReferences;
                 DI := LastTypedConstantsSize + ObjectFilePtr^.EnumeratedDataOffset;
                 FindSegmentForEnumeratedData := True;
               end;
end;