ogomf.pas 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. {
  2. Copyright (c) 2015 by Nikolay Nikolov
  3. Contains the binary Relocatable Object Module Format (OMF) reader and writer
  4. This is the object format used on the i8086-msdos platform.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit ogomf;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. { common }
  23. cclasses,globtype,
  24. { target }
  25. systems,
  26. { assembler }
  27. cpuinfo,cpubase,aasmbase,assemble,link,
  28. { OMF definitions }
  29. omfbase,
  30. { output }
  31. ogbase,
  32. owbase;
  33. type
  34. TOmfObjData = class(TObjData)
  35. public
  36. function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
  37. procedure writeReloc(Data:aint;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);override;
  38. end;
  39. TOmfObjOutput = class(tObjOutput)
  40. protected
  41. function writeData(Data:TObjData):boolean;override;
  42. public
  43. constructor create(AWriter:TObjectWriter);override;
  44. end;
  45. TOmfAssembler = class(tinternalassembler)
  46. constructor create(smart:boolean);override;
  47. end;
  48. implementation
  49. uses
  50. SysUtils,
  51. cutils,verbose,globals,
  52. fmodule,aasmtai,aasmdata,
  53. ogmap,
  54. version
  55. ;
  56. {****************************************************************************
  57. TOmfObjData
  58. ****************************************************************************}
  59. function TOmfObjData.sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;
  60. begin
  61. result:=aname;
  62. end;
  63. procedure TOmfObjData.writeReloc(Data:aint;len:aword;p:TObjSymbol;Reloctype:TObjRelocationType);
  64. begin
  65. end;
  66. {****************************************************************************
  67. TOmfObjOutput
  68. ****************************************************************************}
  69. function TOmfObjOutput.writeData(Data:TObjData):boolean;
  70. var
  71. RawRecord: TOmfRawRecord;
  72. Header: TOmfRecord_THEADR;
  73. begin
  74. { write header record }
  75. RawRecord:=TOmfRawRecord.Create;
  76. Header:=TOmfRecord_THEADR.Create;
  77. Header.ModuleName:=Data.Name;
  78. Header.EncodeTo(RawRecord);
  79. RawRecord.WriteTo(FWriter);
  80. Header.Free;
  81. RawRecord.Free;
  82. result:=true;
  83. end;
  84. constructor TOmfObjOutput.create(AWriter:TObjectWriter);
  85. begin
  86. inherited create(AWriter);
  87. cobjdata:=TOmfObjData;
  88. end;
  89. {****************************************************************************
  90. TOmfAssembler
  91. ****************************************************************************}
  92. constructor TOmfAssembler.Create(smart:boolean);
  93. begin
  94. inherited Create(smart);
  95. CObjOutput:=TOmfObjOutput;
  96. end;
  97. {*****************************************************************************
  98. Initialize
  99. *****************************************************************************}
  100. {$ifdef i8086}
  101. const
  102. as_i8086_omf_info : tasminfo =
  103. (
  104. id : as_i8086_omf;
  105. idtxt : 'OMF';
  106. asmbin : '';
  107. asmcmd : '';
  108. supported_targets : [system_i8086_msdos];
  109. flags : [af_outputbinary,af_needar,af_no_debug];
  110. labelprefix : '..@';
  111. comment : '; ';
  112. dollarsign: '$';
  113. );
  114. {$endif i8086}
  115. initialization
  116. {$ifdef i8086}
  117. RegisterAssembler(as_i8086_omf_info,TOmfAssembler);
  118. {$endif i8086}
  119. end.