Press enter to see results or esc to cancel.

Importing LINNUM Object File Record

This procedure processes LINNUM object file record ($94) and stores statement code sizes to the symbol table.

Procedure OMF_LINNUM; Far;
Var UsedFilesRecord: PUsedFilesBlockRecord;
    TempPtr: Pointer;

  Procedure StoreStatementCodeSizes;
  Var CurrentCodeSize, CurrentSourceLineNumber, StatementCodeSize, SourceLineNumberDifference, Previous_OMF_CodeSize: Word;
  begin
    Repeat
      CurrentSourceLineNumber := Word (Pointer (ObjectFilePtr)^);
      Inc (PChar (ObjectFilePtr), 2);
      CurrentCodeSize := Word (Pointer (ObjectFilePtr)^);
      Inc (PChar (ObjectFilePtr), 2);
      SourceLineNumberDifference := CurrentSourceLineNumber - Current_OMF_SourceLineNumber;
      If SourceLineNumberDifference > 0 then
        begin
          Previous_OMF_CodeSize        := Current_OMF_CodeSize;
          Current_OMF_SourceLineNumber := CurrentSourceLineNumber;
          Current_OMF_CodeSize         := CurrentCodeSize;
          StatementCodeSize := CurrentCodeSize - Previous_OMF_CodeSize;
          TempPtr := IncreaseSymbolTable (stSourceLineCodeOffsets, SourceLineNumberDifference + 1);
          If StatementCodeSize >= $0080 then
            begin
              Byte (TempPtr^) := Hi (StatementCodeSize) or $80;
              Inc (PChar (TempPtr));
            end;
          Byte (TempPtr^) := Lo (StatementCodeSize);
          Inc (PChar (TempPtr));
          FillChar (TempPtr^, SourceLineNumberDifference - 1, 0);
          SymbolTable [stSourceLineCodeOffsets].UsedSize := Ofs (TempPtr) + SourceLineNumberDifference - 1;
        end;
    until Ofs (ObjectFilePtr^) = ObjectRecordChecksumOffset;
  end;

begin

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

  If SourceFileNumber <> 1 then Exit;
  Inc (PChar (ObjectFilePtr), 4);
  If Byte (Pointer (ObjectFilePtr)^) <> CodeSegmentIndex then Exit;;
  Inc (PChar (ObjectFilePtr));
  If SymbolTable [stSourceLineCodeOffsets].UsedSize <> LastBlock_stSourceLineCodeOffsets_Size then
    begin
      StoreStatementCodeSizes;
      Exit;
    end;
  Current_OMF_SourceLineNumber := Word (Pointer (ObjectFilePtr)^);
  Inc (PChar (ObjectFilePtr), 2);
  Current_OMF_CodeSize := Word (Pointer (ObjectFilePtr)^);
  Inc (PChar (ObjectFilePtr), 2);
  UsedFilesRecord := StoreFileNameToFilesBlock (FileBuffer, ufIncludeFile);
  UsedFilesRecord^.L3 := OMF_SourceFileDateTime;
  TempPtr := IncreaseSymbolTable (stSourceLineCodeOffsets, 12);
  Word (Ptr (Seg (TempPtr^), Ofs (TempPtr^))^) := 0;
  Word (Ptr (Seg (TempPtr^), Ofs (TempPtr^) + 2)^) := Ofs (UsedFilesRecord^);
  Word (Ptr (Seg (TempPtr^), Ofs (TempPtr^) + 4)^) := 0;
  Word (Ptr (Seg (TempPtr^), Ofs (TempPtr^) + 6)^) := Current_OMF_CodeSize;
  Word (Ptr (Seg (TempPtr^), Ofs (TempPtr^) + 8)^) := Current_OMF_SourceLineNumber;
  Word (Ptr (Seg (TempPtr^), Ofs (TempPtr^) + 10)^) := 0;
  If Ofs (ObjectFilePtr^) >= ObjectRecordChecksumOffset then Exit;
  StoreStatementCodeSizes;
end;