/* F256 Linker Script */


/* fake C Stack */
PROVIDE(__stack = 0xC000);
/* entry point to my program */
PROVIDE(__f256_start = 0x300);
/* swappable block address */
PROVIDE(__SLOT_ADDR = 0xC000);

/* f256k uses first 16 bytes of ZP for mmu control? */
__rc0 = 0x10;
INCLUDE imag-regs.ld
ASSERT(__rc0 == 0x10, "Inconsistent zero page map.")
ASSERT(__rc31 == 0x2f, "Inconsistent zero page map.")

MEMORY {
    /* kernel uses 0xf0-0xff for parameter passing */
    zp : ORIGIN = __rc31 + 1, LENGTH = 0xF0 - (__rc31 + 1)
    ram (rw) : ORIGIN = __f256_start, LENGTH = 0xC000-__f256_start
}

REGION_ALIAS("c_writeable", ram)
REGION_ALIAS("c_readonly", ram)

SECTIONS {
  INCLUDE c.ld
}

OUTPUT_FORMAT {
  BYTE(0x5A)    /* pgZ */

/* ram segment */

  SHORT(ORIGIN(ram))              /* where to load it, 24 bits */
  BYTE(0x00)
  SHORT(__bss_start-ORIGIN(ram))  /* size to load */
  BYTE(0x00)
  TRIM(ram)

 /* Launch the program, at _start */
 SHORT(_start)
 LONG(0)
}

