123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- MODULE FoxBinaryCode;
- IMPORT Basic := FoxBasic, Sections := FoxSections, Streams, ObjectFile, BitSets;
- CONST
- Absolute* = ObjectFile.Absolute;
- Relative* = ObjectFile.Relative;
- Byte = 8;
- TYPE
- Code* = BitSets.BitSet;
- Unit* = ObjectFile.Unit;
- Bits* = ObjectFile.Bits;
- FixupPatterns* = ObjectFile.FixupPatterns;
- Alias* = OBJECT
- VAR
- nextAlias-: Alias;
- identifier-: ObjectFile.Identifier;
- offset-: LONGINT;
- PROCEDURE ^ & InitAlias*(identifier: ObjectFile.Identifier; offset: LONGINT);
- PROCEDURE ^ Dump*(w: Streams.Writer);
- END Alias;
- AliasList* = OBJECT
- VAR
- firstAlias-, lastAlias-: Alias;
- aliases-: LONGINT;
- PROCEDURE ^ & InitAliasList*;
- PROCEDURE ^ AddAlias*(alias: Alias);
- PROCEDURE ^ Dump*(w: Streams.Writer);
- END AliasList;
- Fixup* = OBJECT
- VAR
- nextFixup-: Fixup;
- mode-: INTEGER;
- displacement-: Unit;
- scale-: ObjectFile.Bits;
- patterns-: SIZE;
- pattern-: FixupPatterns;
- offset-: Unit;
- symbol-: ObjectFile.Identifier;
- symbolOffset-: LONGINT;
- resolved*: Sections.Section;
- PROCEDURE ^ & InitFixup*(mode: INTEGER; fixupOffset: Unit; symbol: ObjectFile.Identifier; symbolOffset: LONGINT; displacement: Unit; scale: LONGINT; fixupPattern: ObjectFile.FixupPatterns);
- PROCEDURE ^ SetFixupOffset*(offset: Unit);
- PROCEDURE ^ SetSymbol*(symbol: Sections.SectionName; fp: ObjectFile.Fingerprint; symbolOffset: LONGINT; displacement: Unit);
- PROCEDURE ^ Dump*(w: Streams.Writer);
- END Fixup;
- FixupList* = OBJECT
- VAR
- firstFixup-, lastFixup-: Fixup;
- fixups-: LONGINT;
- PROCEDURE ^ & InitFixupList*;
- PROCEDURE ^ AddFixup*(fixup: Fixup);
- PROCEDURE ^ Dump*(w: Streams.Writer);
- END FixupList;
- LabelList* = POINTER TO RECORD
- offset-: LONGINT;
- position-: Basic.Position;
- prev-: LabelList;
- END;
- Section* = OBJECT
- VAR
- os*: ObjectFile.Section;
- labels-: LabelList;
- fixupList-: FixupList;
- aliasList-: AliasList;
- finally-: Unit;
- comments-: Sections.CommentWriter;
- bigEndian-: BOOLEAN;
- pc-: Unit;
- PROCEDURE ^ GetPC(): Unit;
- PROCEDURE ^ & InitBinarySection*(type: SHORTINT; unit: Bits; CONST name: Basic.SegmentedName; dump: BOOLEAN; bigEndian: BOOLEAN);
- PROCEDURE ^ Reset*;
- PROCEDURE ^ AddLabel*(position: Basic.Position);
- PROCEDURE ^ SetPC*(pc: Unit);
- PROCEDURE ^ Align*(alignment: Unit);
- PROCEDURE ^ SetFinally*(atPC: Unit);
- PROCEDURE ^ SetAlignment*(fixed: BOOLEAN; alignat: LONGINT);
- PROCEDURE ^ CheckSize(size: LONGINT);
- PROCEDURE ^ CopyBits*(src: BitSets.BitSet; srcPos, len: Bits);
- PROCEDURE ^ PutBits*(d: HUGEINT; size: Bits);
- PROCEDURE ^ PutBitsAt*(at: Unit; d: HUGEINT; size: Bits);
- PROCEDURE ^ PutByte*(b: WORD);
- PROCEDURE ^ PutWord*(w: WORD);
- PROCEDURE ^ PutDWord*(d: WORD);
- PROCEDURE ^ PutQWord*(q: HUGEINT);
- PROCEDURE ^ PutReal*(f: REAL);
- PROCEDURE ^ PutLongreal*(f: LONGREAL);
- PROCEDURE ^ PutByteAt*(at: Unit; d: WORD);
- PROCEDURE ^ PutWordAt*(at: Unit; d: WORD);
- PROCEDURE ^ PutDWordAt*(at: Unit; d: WORD);
- PROCEDURE ^ PutQWordAt*(at: Unit; d: HUGEINT);
- PROCEDURE ^ PutBytes*(data: HUGEINT; bytes: SHORTINT);
- PROCEDURE ^ GetByte*(pc: Unit): CHAR;
- PROCEDURE ^ GetWord*(pc: Unit): WORD;
- PROCEDURE ^ GetDWord*(pc: Unit): WORD;
- PROCEDURE ^ GetQWord*(pc: Unit): HUGEINT;
- PROCEDURE ^ GetReal*(pc: Unit): REAL;
- PROCEDURE ^ GetLongreal*(pc: Unit): LONGREAL;
- PROCEDURE ^ GetBits*(pc: Unit; size: Bits): WORD;
- PROCEDURE ^ ApplyFixup*(fixup: Fixup): BOOLEAN;
- PROCEDURE ^ DumpCode*(w: Streams.Writer; from, to: Unit);
- PROCEDURE ^ Dump*(w: Streams.Writer);
- END Section;
- PROCEDURE ^ ConvertReal*(value: REAL): LONGINT;
- PROCEDURE ^ ConvertLongreal*(value: LONGREAL): HUGEINT;
- PROCEDURE ^ ConvertToReal*(x: LONGINT): REAL;
- PROCEDURE ^ ConvertToLongreal*(x: HUGEINT): LONGREAL;
- PROCEDURE ^ NewFixup*(mode: INTEGER; fixupOffset: LONGINT; symbol: ObjectFile.Identifier; symbolOffset, displacement: LONGINT; scale: LONGINT; fixupPattern: ObjectFile.FixupPatterns): Fixup;
- PROCEDURE ^ NewBinarySection*(type: SHORTINT; unit: LONGINT; CONST name: Basic.SegmentedName; dump: BOOLEAN; bigEndian: BOOLEAN): Section;
- BEGIN
- END FoxBinaryCode.
|