diff --git a/Merlin-16-REL-Format.md b/Merlin-16-REL-Format.md index aab5e26..bc667f9 100644 --- a/Merlin-16-REL-Format.md +++ b/Merlin-16-REL-Format.md @@ -12,6 +12,17 @@ This is followed by 0 or more relation records, a 0 byte, 0 or more label entrie Relocation records are 4 bytes long. The first bytes is a flag byte. This is followed by a 16-bit offset, and an 8-bit operand byte. For external references, the operand byte is the external symbol number. For local references, the operand byte is the low 8-bits of the assembled operand. +### Flag Byte + +* bits 0-3 always populated (`$0f`) +* bit 4 (`$10`) indicates an external label +* bit 7 (`$80) indicates a 2-byte relocation +* bit 5 (`$20) indicates a 3-byte relocation +* `$ff` indicates a shift (see below) + +This is followed by the 16-bit offset to patch. + +For external symbols, the 4th bytes is the symbol number (which starts at 0). For local symbols, the 4th byte is the low byte of the operand at the offset. ### Shifting @@ -44,7 +55,7 @@ For local and EQU labels, this is the label address (based on the `$8000` origin For external labels, this is the external label number + `$8000`. ## References -* Merlin 816 Macro Assembler Manual +* Merlin 8/16 User's Manual * Merlin 16+ source code * Quick Asm source code * Empirical testing \ No newline at end of file