Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:Amiga FD file

From ReverseEngineering.wiki
Format
Extensions .fd (usually <library>_lib.fd)
On this wiki Facts · Code · Notes · Topics

The .fd function description files that name each Amiga library function with its register arguments and a negative bias (LVO): ##base, ##bias 30, ##public/##private and name(args)(registers) lines; function k after the start sits at -(30 + 6k) from the library base.

Why they matter

An Amiga shared library is called with A6 holding the library base; in front of the base lies a jump table with one entry per function, entered at a negative offset, the LVO. The .fd file of a library gives each function name, its argument names and the registers that carry them, so it is the lookup table from JSR -$C6(A6) in a disassembly to a name such as OpenLibrary. fd2pragma's guide states that A6 holds the base, the table lies in front of it and the offsets are always negative.

Syntax

Three line types: commands starting ##, comments starting *, and function lines name(argnames)(registers), for example OpenWindowTagList(newWindow,tagList)(a0/a1). Registers are separated by / or ,; void functions have empty brackets. Commands: ##base _XxxBase (library base variable name), ##bias N (offset of the next function, at least 30 and a multiple of 6), ##public / ##private (private functions are skipped in headers), ##end; fd2pragma also knows ##abi (M68k, PPC, PPC0, PPC2) and Haage&Partner's ##shadow. See Fact:Amiga FD file/behavior/Bias numbering.

Numbering

The first function after ##bias 30 has LVO -30, every later one 6 bytes lower, and a new ##bias jumps. In exec_lib.fd (amitools copy): Supervisor is at -30, six private slots follow at -36 to -66, and InitCode is at -72. Unverified: the four standard slots Open, Close, Expunge and Reserved at -6 to -24 are not listed in the .fd because every library has them. Unverified: that entries are 6 bytes because each is a JMP abs.l (opcode 4EF9 + 32-bit address); the .fd guide only says the bias is a sum of 6.

Library base structure

The struct Library at the base: a Node (successor, predecessor pointers, type byte, priority byte, name pointer: 14 bytes), then flags (byte), pad (byte), NegSize (jump table size in bytes), PosSize (size of the structure after it), Version, Revision (words), IdString pointer, Sum (checksum, long) and OpenCnt (word): 34 bytes. See Fact:Amiga FD file/struct/struct Library. Offsets are computed from the field order in amitools LibraryStruct.

Register conventions

D0, D1, A0, A1 are scratch; D0 returns the value; all other registers are preserved; A4 holds the small-data base pointer for C compilers (fd2pragma guide, section 'How 680x0 processor registers are used'); A5 is used by C compilers for a field pointer.

Related

Platform:Amiga, Format:AmigaOS Hunk executable

Code & repositories

  • https://github.com/cnvogelg/amitools @ 3b57f2052ee76c28bbc5e4256227f62dca7b1c9f · license: unknown
    amitools (Python): amitools/binfmt/hunk parses every Hunk block type, amitools/data/fd holds the NDK .fd files, amitools/vamos/libstructs the exec structures.
    Tested on: source read, not run: source reading only · checked 2026-10-19
  • https://github.com/adtools/fd2pragma @ 8c0f352c348a3252f84170eab737919372562e82 · license: LicenseRef-PublicDomain (declared by the contributor; GitHub's detector did not recognize a license file)
    fd2pragma (public domain): turns .fd files into pragma, inline, LVO and proto files; fd2pragma.guide documents the .fd syntax and library register conventions.
    Tested on: source read, not run: source reading only · checked 2026-10-19